diff --git "a/train.csv" "b/train.csv" --- "a/train.csv" +++ "b/train.csv" @@ -1,10 +1,10 @@ Q_CreationDate,Title,Question,Answer,Score,Is_accepted,N_answers,Q_Id 2008-08-05 22:26:00.797,Create a directly-executable cross-platform GUI app using Python,"Python works on multiple platforms and can be used for desktop and web applications, thus I conclude that there is some way to compile it into an executable for Mac, Windows and Linux. +The problem being I have no idea where to start or how to write a GUI with it, can anybody shed some light on this and point me in the right direction please?","I'm not sure that this is the best way to do it, but when I'm deploying Ruby GUI apps (not Python, but has the same ""problem"" as far as .exe's are concerned) on Windows, I just write a short launcher in C# that calls on my main script. It compiles to an executable, and I then have an application executable.",0.1249325528793103,False,2,0 +2008-08-05 22:26:00.797,Create a directly-executable cross-platform GUI app using Python,"Python works on multiple platforms and can be used for desktop and web applications, thus I conclude that there is some way to compile it into an executable for Mac, Windows and Linux. The problem being I have no idea where to start or how to write a GUI with it, can anybody shed some light on this and point me in the right direction please?","Since python is installed on nearly every non-Windows OS by default now, the only thing you really need to make sure of is that all of the non-standard libraries you use are installed. Having said that, it is possible to build executables that include the python interpreter, and any libraries you use. This is likely to create a large executable, however. MacOS X even includes support in the Xcode IDE for creating full standalone GUI apps. These can be run by any user running OS X.",0.1861857744855677,False,2,0 -2008-08-05 22:26:00.797,Create a directly-executable cross-platform GUI app using Python,"Python works on multiple platforms and can be used for desktop and web applications, thus I conclude that there is some way to compile it into an executable for Mac, Windows and Linux. -The problem being I have no idea where to start or how to write a GUI with it, can anybody shed some light on this and point me in the right direction please?","I'm not sure that this is the best way to do it, but when I'm deploying Ruby GUI apps (not Python, but has the same ""problem"" as far as .exe's are concerned) on Windows, I just write a short launcher in C# that calls on my main script. It compiles to an executable, and I then have an application executable.",0.1249325528793103,False,2,0 2008-08-22 10:51:19.057,"How do content discovery engines, like Zemanta and Open Calais work?","I was wondering how as semantic service like Open Calais figures out the names of companies, or people, tech concepts, keywords, etc. from a piece of text. Is it because they have a large database that they match the text against? How would a service like Zemanta know what images to suggest to a piece of text for instance?","Open Calais probably use language parsing technology and language statics to guess which words or phrases are Names, Places, Companies, etc. Then, it is just another step to do some kind of search for those entities and return meta data. Zementa probably does something similar, but matches the phrases against meta-data attached to images in order to acquire related results. @@ -32,7 +32,16 @@ e.g.: or in your case: −2 mod 5 = (−2 + 5) mod 5 = 3",0.4431875092007125,False,6,4 2008-09-04 13:36:46.917,Modulus operation with negatives values - weird thing?,"Can you please tell me how much is (-2) % 5? According to my Python interpreter is 3, but do you have a wise explanation for this? -I've read that in some languages the result can be machine-dependent, but I'm not sure though.","Well, -2 divided by 5 would be 0 with a remainder of 3. I don't believe that should be very platform dependent, but I've seen stranger things.",0.0,False,6,4 +I've read that in some languages the result can be machine-dependent, but I'm not sure though.","There seems to be a common confusion between the terms ""modulo"" and ""remainder"". +In math, a remainder should always be defined consistent with the quotient, so that if a / b == c rem d then (c * b) + d == a. Depending on how you round your quotient, you get different remainders. +However, modulo should always give a result 0 <= r < divisor, which is only consistent with round-to-minus-infinity division if you allow negative integers. If division rounds towards zero (which is common), modulo and remainder are only equivalent for non-negative values. +Some languages (notably C and C++) don't define the required rounding/remainder behaviours and % is ambiguous. Many define rounding as towards zero, yet use the term modulo where remainder would be more correct. Python is relatively unusual in that it rounds to negative infinity, so modulo and remainder are equivalent. +Ada rounds towards zero IIRC, but has both mod and rem operators. +The C policy is intended to allow compilers to choose the most efficient implementation for the machine, but IMO is a false optimisation, at least these days. A good compiler will probably be able to use the equivalence for optimisation wherever a negative number cannot occur (and almost certainly if you use unsigned types). On the other hand, where negative numbers can occur, you almost certainly care about the details - for portability reasons you have to use very carefully designed overcomplex algorithms and/or checks to ensure that you get the results you want irrespective of the rounding and remainder behaviour. +In other words, the gain for this ""optimisation"" is mostly (if not always) an illusion, whereas there are very real costs in some cases - so it's a false optimisation.",0.0,False,6,4 +2008-09-04 13:36:46.917,Modulus operation with negatives values - weird thing?,"Can you please tell me how much is (-2) % 5? +According to my Python interpreter is 3, but do you have a wise explanation for this? +I've read that in some languages the result can be machine-dependent, but I'm not sure though.","The result depends on the language. Python returns the sign of the divisor, where for example c# returns the sign of the dividend (ie. -2 % 5 returns -2 in c#).",0.0,False,6,4 2008-09-04 13:36:46.917,Modulus operation with negatives values - weird thing?,"Can you please tell me how much is (-2) % 5? According to my Python interpreter is 3, but do you have a wise explanation for this? I've read that in some languages the result can be machine-dependent, but I'm not sure though.","Well, 0 % 5 should be 0, right? @@ -45,16 +54,7 @@ According to my Python interpreter is 3, but do you have a wise explanation for I've read that in some languages the result can be machine-dependent, but I'm not sure though.","By the way: most programming languages would disagree with Python and give the result -2. Depending on the interpretation of modulus this is correct. However, the most agreed-upon mathematical definition states that the modulus of a and b is the (strictly positive) rest r of the division of a / b. More precisely, 0 <= r < b by definition.",1.2,True,6,4 2008-09-04 13:36:46.917,Modulus operation with negatives values - weird thing?,"Can you please tell me how much is (-2) % 5? According to my Python interpreter is 3, but do you have a wise explanation for this? -I've read that in some languages the result can be machine-dependent, but I'm not sure though.","The result depends on the language. Python returns the sign of the divisor, where for example c# returns the sign of the dividend (ie. -2 % 5 returns -2 in c#).",0.0,False,6,4 -2008-09-04 13:36:46.917,Modulus operation with negatives values - weird thing?,"Can you please tell me how much is (-2) % 5? -According to my Python interpreter is 3, but do you have a wise explanation for this? -I've read that in some languages the result can be machine-dependent, but I'm not sure though.","There seems to be a common confusion between the terms ""modulo"" and ""remainder"". -In math, a remainder should always be defined consistent with the quotient, so that if a / b == c rem d then (c * b) + d == a. Depending on how you round your quotient, you get different remainders. -However, modulo should always give a result 0 <= r < divisor, which is only consistent with round-to-minus-infinity division if you allow negative integers. If division rounds towards zero (which is common), modulo and remainder are only equivalent for non-negative values. -Some languages (notably C and C++) don't define the required rounding/remainder behaviours and % is ambiguous. Many define rounding as towards zero, yet use the term modulo where remainder would be more correct. Python is relatively unusual in that it rounds to negative infinity, so modulo and remainder are equivalent. -Ada rounds towards zero IIRC, but has both mod and rem operators. -The C policy is intended to allow compilers to choose the most efficient implementation for the machine, but IMO is a false optimisation, at least these days. A good compiler will probably be able to use the equivalence for optimisation wherever a negative number cannot occur (and almost certainly if you use unsigned types). On the other hand, where negative numbers can occur, you almost certainly care about the details - for portability reasons you have to use very carefully designed overcomplex algorithms and/or checks to ensure that you get the results you want irrespective of the rounding and remainder behaviour. -In other words, the gain for this ""optimisation"" is mostly (if not always) an illusion, whereas there are very real costs in some cases - so it's a false optimisation.",0.0,False,6,4 +I've read that in some languages the result can be machine-dependent, but I'm not sure though.","Well, -2 divided by 5 would be 0 with a remainder of 3. I don't believe that should be very platform dependent, but I've seen stranger things.",0.0,False,6,4 2008-09-15 21:11:30.050,Using boost-python with C++ in Linux,"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. Building 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: ImportError: libboost_python-gcc41-d-1_35.so.1.35.0: cannot open shared object file: No such file or directory @@ -63,8 +63,9 @@ libboost_python-gcc41-mt-1_35.so libboost_python-gcc41-mt-1_35.so.1.35.0 libboos Obviously 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. When 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. I'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. -Response 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.","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. -On 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.",0.2655860252697744,False,2,5 +Response 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.","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. +It'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. +Thanks for the other suggestions!",0.2655860252697744,False,2,5 2008-09-15 21:11:30.050,Using boost-python with C++ in Linux,"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. Building 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: ImportError: libboost_python-gcc41-d-1_35.so.1.35.0: cannot open shared object file: No such file or directory @@ -73,9 +74,13 @@ libboost_python-gcc41-mt-1_35.so libboost_python-gcc41-mt-1_35.so.1.35.0 libboos Obviously 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. When 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. I'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. -Response 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.","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. -It'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. -Thanks for the other suggestions!",0.2655860252697744,False,2,5 +Response 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.","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. +On 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.",0.2655860252697744,False,2,5 +2008-09-16 07:07:42.550,Can I implement a web user authentication system in python without POST?,"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? +If it's not, how would you do it with POST? Just out of curiosity. +Cheers!","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. +In 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. :) +(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.)",1.2,True,3,6 2008-09-16 07:07:42.550,Can I implement a web user authentication system in python without POST?,"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? If it's not, how would you do it with POST? Just out of curiosity. Cheers!","You could use HTTP Authentication, if supported. @@ -84,16 +89,15 @@ GET is basically just like POST, it just has a limit on the amount of data you c As 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",0.0679224682270276,False,3,6 2008-09-16 07:07:42.550,Can I implement a web user authentication system in python without POST?,"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? If it's not, how would you do it with POST? Just out of curiosity. -Cheers!","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. -In 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. :) -(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.)",1.2,True,3,6 -2008-09-16 07:07:42.550,Can I implement a web user authentication system in python without POST?,"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? -If it's not, how would you do it with POST? Just out of curiosity. Cheers!","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.",0.0,False,3,6 2008-09-16 09:44:59.477,How to prompt for user input and read command-line arguments,How do I have a Python script that a) can accept user input and how do I make it b) read in arguments if run from the command line?,"Careful not to use the input function, unless you know what you're doing. Unlike raw_input, input will accept any python expression, so it's kinda like eval",0.5691458279783562,False,1,7 2008-09-16 12:46:28.150,Using the docstring from one method to automatically overwrite that of another method,"The problem: I have a class which contains a template method execute which calls another method _execute. Subclasses are supposed to overwrite _execute to implement some specific functionality. This functionality should be documented in the docstring of _execute. Advanced users can create their own subclasses to extend the library. However, another user dealing with such a subclass should only use execute, so he won't see the correct docstring if he uses help(execute). Therefore it would be nice to modify the base class in such a way that in a subclass the docstring of execute is automatically replaced with that of _execute. Any ideas how this might be done? +I was thinking of metaclasses to do this, to make this completely transparent to the user.","Look at the functools.wraps() decorator; it does all of this, but I don't know offhand if you can get it to run in the right context",0.0814518047658113,False,2,8 +2008-09-16 12:46:28.150,Using the docstring from one method to automatically overwrite that of another method,"The problem: I have a class which contains a template method execute which calls another method _execute. Subclasses are supposed to overwrite _execute to implement some specific functionality. This functionality should be documented in the docstring of _execute. +Advanced users can create their own subclasses to extend the library. However, another user dealing with such a subclass should only use execute, so he won't see the correct docstring if he uses help(execute). +Therefore it would be nice to modify the base class in such a way that in a subclass the docstring of execute is automatically replaced with that of _execute. Any ideas how this might be done? I was thinking of metaclasses to do this, to make this completely transparent to the user.","Well the doc-string is stored in __doc__ so it wouldn't be too hard to re-assign it based on the doc-string of _execute after the fact. Basically: @@ -117,10 +121,6 @@ class SubClass(MyClass): Execute has to be re-declared to that the doc string gets attached to the version of execute for the SubClass and not for MyClass (which would otherwise interfere with other sub-classes). That's not a very tidy way of doing it, but from the POV of the user of a library it should give the desired result. You could then wrap this up in a meta-class to make it easier for people who are sub-classing.",0.0,False,2,8 -2008-09-16 12:46:28.150,Using the docstring from one method to automatically overwrite that of another method,"The problem: I have a class which contains a template method execute which calls another method _execute. Subclasses are supposed to overwrite _execute to implement some specific functionality. This functionality should be documented in the docstring of _execute. -Advanced users can create their own subclasses to extend the library. However, another user dealing with such a subclass should only use execute, so he won't see the correct docstring if he uses help(execute). -Therefore it would be nice to modify the base class in such a way that in a subclass the docstring of execute is automatically replaced with that of _execute. Any ideas how this might be done? -I was thinking of metaclasses to do this, to make this completely transparent to the user.","Look at the functools.wraps() decorator; it does all of this, but I don't know offhand if you can get it to run in the right context",0.0814518047658113,False,2,8 2008-09-16 20:11:22.217,Which of these scripting languages is more appropriate for pen-testing?,"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. If, 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. Right 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? @@ -131,18 +131,16 @@ Now to just answer the question, I would go with Perl, but I'm a linux guy so I If, 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. Right 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? Again, 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. -One 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.","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? -As 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.",0.0,False,7,9 -2008-09-16 20:11:22.217,Which of these scripting languages is more appropriate for pen-testing?,"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. -If, 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. -Right 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? -Again, 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. -One 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.","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.",0.0340004944420038,False,7,9 +One 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.",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.,0.0,False,7,9 2008-09-16 20:11:22.217,Which of these scripting languages is more appropriate for pen-testing?,"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. If, 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. Right 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? Again, 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. -One 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.","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.",0.0340004944420038,False,7,9 +One 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.","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. +If 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. +I would not recommend Perl as you will find very little tools/scripts/frameworks related to pen testing/fuzzing/exploits/... in Perl. +As your question is ""tool writing and exploit development"" I would recommend Ruby if you choose Metasploit or python if you choose CANVAS. +hope that helps :)",0.1016881243684853,False,7,9 2008-09-16 20:11:22.217,Which of these scripting languages is more appropriate for pen-testing?,"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. If, 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. Right 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? @@ -158,69 +156,71 @@ So I think Perl does have a very slight edge for your needs in particular, but o If, 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. Right 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? Again, 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. -One 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.","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. -If 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. -I would not recommend Perl as you will find very little tools/scripts/frameworks related to pen testing/fuzzing/exploits/... in Perl. -As your question is ""tool writing and exploit development"" I would recommend Ruby if you choose Metasploit or python if you choose CANVAS. -hope that helps :)",0.1016881243684853,False,7,9 +One 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.","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.",0.0340004944420038,False,7,9 2008-09-16 20:11:22.217,Which of these scripting languages is more appropriate for pen-testing?,"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. If, 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. Right 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? Again, 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. -One 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.",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.,0.0,False,7,9 +One 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.","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.",0.0340004944420038,False,7,9 +2008-09-16 20:11:22.217,Which of these scripting languages is more appropriate for pen-testing?,"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. +If, 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. +Right 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? +Again, 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. +One 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.","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? +As 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.",0.0,False,7,9 2008-09-16 21:05:26.673,"Which is faster, python webpages or php webpages?","Which is faster, python webpages or php webpages? Does anyone know how the speed of pylons(or any of the other frameworks) compares to a similar website made with php? I know that serving a python base webpage via cgi is slower than php because of its long start up every time. -I 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.","I would assume that PHP (>5.5) is faster and more reliable for complex web applications because it is optimized for website scripting. -Many 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.",0.2781854903257024,False,9,10 +I 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.","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.",0.0814518047658113,False,9,10 2008-09-16 21:05:26.673,"Which is faster, python webpages or php webpages?","Which is faster, python webpages or php webpages? Does anyone know how the speed of pylons(or any of the other frameworks) compares to a similar website made with php? I know that serving a python base webpage via cgi is slower than php because of its long start up every time. -I 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.","an IS organization would not ponder this unless availability was becoming an issue. -if so the case, look into replication, load balancing and lots of ram.",0.0407936753323291,False,9,10 +I 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.","If it ain't broke don't fix it. +Just write a quick test, but bear in mind that each language will be faster with certain functions then the other.",0.0407936753323291,False,9,10 2008-09-16 21:05:26.673,"Which is faster, python webpages or php webpages?","Which is faster, python webpages or php webpages? Does anyone know how the speed of pylons(or any of the other frameworks) compares to a similar website made with php? I know that serving a python base webpage via cgi is slower than php because of its long start up every time. -I 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.","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. -The 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. -It may also create a problem with maintainability, depending on who else has to work with the system, and their experience with Python.",0.9950547536867304,False,9,10 +I 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.","I would assume that PHP (>5.5) is faster and more reliable for complex web applications because it is optimized for website scripting. +Many 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.",0.2781854903257024,False,9,10 2008-09-16 21:05:26.673,"Which is faster, python webpages or php webpages?","Which is faster, python webpages or php webpages? Does anyone know how the speed of pylons(or any of the other frameworks) compares to a similar website made with php? I know that serving a python base webpage via cgi is slower than php because of its long start up every time. -I 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.","PHP and Python are similiar enough to not warrent any kind of switching. -Any 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.",0.0814518047658113,False,9,10 +I 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.","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. +Just saying ""we should switch to technology B because technology B is faster!"" doesn't really work. +Since 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.",0.0407936753323291,False,9,10 2008-09-16 21:05:26.673,"Which is faster, python webpages or php webpages?","Which is faster, python webpages or php webpages? Does anyone know how the speed of pylons(or any of the other frameworks) compares to a similar website made with php? I know that serving a python base webpage via cgi is slower than php because of its long start up every time. -I 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.","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. -Why 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. -As for performance, we are still having troubles.",-0.0407936753323291,False,9,10 +I 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.","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.",0.0,False,9,10 2008-09-16 21:05:26.673,"Which is faster, python webpages or php webpages?","Which is faster, python webpages or php webpages? Does anyone know how the speed of pylons(or any of the other frameworks) compares to a similar website made with php? I know that serving a python base webpage via cgi is slower than php because of its long start up every time. -I 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.","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. -Just saying ""we should switch to technology B because technology B is faster!"" doesn't really work. -Since 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.",0.0407936753323291,False,9,10 +I 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.","PHP and Python are similiar enough to not warrent any kind of switching. +Any 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.",0.0814518047658113,False,9,10 2008-09-16 21:05:26.673,"Which is faster, python webpages or php webpages?","Which is faster, python webpages or php webpages? Does anyone know how the speed of pylons(or any of the other frameworks) compares to a similar website made with php? I know that serving a python base webpage via cgi is slower than php because of its long start up every time. -I 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.","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.",0.0,False,9,10 +I 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.","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. +The 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. +It may also create a problem with maintainability, depending on who else has to work with the system, and their experience with Python.",0.9950547536867304,False,9,10 2008-09-16 21:05:26.673,"Which is faster, python webpages or php webpages?","Which is faster, python webpages or php webpages? Does anyone know how the speed of pylons(or any of the other frameworks) compares to a similar website made with php? I know that serving a python base webpage via cgi is slower than php because of its long start up every time. -I 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.","If it ain't broke don't fix it. -Just write a quick test, but bear in mind that each language will be faster with certain functions then the other.",0.0407936753323291,False,9,10 +I 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.","an IS organization would not ponder this unless availability was becoming an issue. +if so the case, look into replication, load balancing and lots of ram.",0.0407936753323291,False,9,10 2008-09-16 21:05:26.673,"Which is faster, python webpages or php webpages?","Which is faster, python webpages or php webpages? Does anyone know how the speed of pylons(or any of the other frameworks) compares to a similar website made with php? I know that serving a python base webpage via cgi is slower than php because of its long start up every time. -I 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.","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.",0.0814518047658113,False,9,10 +I 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.","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. +Why 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. +As for performance, we are still having troubles.",-0.0407936753323291,False,9,10 +2008-09-17 17:23:23.030,Search for host with MAC-address using Python,"I'd like to search for a given MAC address on my network, all from within a Python script. I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address. Any ideas?","You would want to parse the output of 'arp', but the kernel ARP cache will only contain those IP address(es) if those hosts have communicated with the host where the Python script is running. +ifconfig can be used to display the MAC addresses of local interfaces, but not those on the LAN.",0.0,False,4,11 2008-09-17 17:23:23.030,Search for host with MAC-address using Python,"I'd like to search for a given MAC address on my network, all from within a Python script. I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address. Any ideas?","I don't think there is a built in way to get it from Python itself. My question is, how are you getting the IP information from your network? To get it from your local machine you could parse ifconfig (unix) or ipconfig (windows) with little difficulty.",0.0509761841073563,False,4,11 2008-09-17 17:23:23.030,Search for host with MAC-address using Python,"I'd like to search for a given MAC address on my network, all from within a Python script. I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address. Any ideas?","Depends on your platform. If you're using *nix, you can use the 'arp' command to look up the mac address for a given IP (assuming IPv4) address. If that doesn't work, you could ping the address and then look, or if you have access to the raw network (using BPF or some other mechanism), you could send your own ARP packets (but that is probably overkill).",0.0,False,4,11 2008-09-17 17:23:23.030,Search for host with MAC-address using Python,"I'd like to search for a given MAC address on my network, all from within a Python script. I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address. Any ideas?","It seems that there is not a native way of doing this with Python. Your best bet would be to parse the output of ""ipconfig /all"" on Windows, or ""ifconfig"" on Linux. Consider using os.popen() with some regexps.",0.0509761841073563,False,4,11 -2008-09-17 17:23:23.030,Search for host with MAC-address using Python,"I'd like to search for a given MAC address on my network, all from within a Python script. I already have a map of all the active IP addresses in the network but I cannot figure out how to glean the MAC address. Any ideas?","You would want to parse the output of 'arp', but the kernel ARP cache will only contain those IP address(es) if those hosts have communicated with the host where the Python script is running. -ifconfig can be used to display the MAC addresses of local interfaces, but not those on the LAN.",0.0,False,4,11 2008-09-17 20:48:45.610,"If it is decided that our system needs an overhaul, what is the best way to go about it?","We are mainting a web application that is built on Classic ASP using VBScript as the primary language. We are in agreement that our backend (framework if you will) is out dated and doesn't provide us with the proper tools to move forward in a quick manner. We have pretty much embraced the current webMVC pattern that is all over the place, and cannot do it, in a reasonable manner, with the current technology. The big missing features are proper dispatching and templating with inheritance, amongst others. Currently there are two paths being discussed: @@ -228,9 +228,15 @@ Port the existing application to Classic ASP using JScript, which will allow us Completely rewrite the application using some other technology, right now the leader of the pack is Python WSGI with a custom framework, ORM, and a good templating solution. There is wiggle room here for even django and other pre-built solutions. This method would hopefully be the quickest solution, as we would probably run a beta beside the actual product, but it does have the potential for a big waste of time if we can't/don't get it right. This does not mean that our logic is gone, as what we have built over the years is fairly stable, as noted just difficult to deal with. It is built on SQL Server 2005 with heavy use of stored procedures and published on IIS 6, just for a little more background. -Now, the question. Has anyone taken either of the two paths above? If so, was it successful, how could it have been better, etc. We aren't looking to deviate much from doing one of those two things, but some suggestions or other solutions would potentially be helpful.","Use this as an opportunity to remove unused features! Definitely go with the new language. Call it 2.0. It will be a lot less work to rebuild the 80% of it that you really need. -Start by wiping your brain clean of the whole application. Sit down with a list of its overall goals, then decide which features are needed based on which ones are used. Then redesign it with those features in mind, and build. -(I love to delete code.)",0.1352210990936997,False,7,12 +Now, the question. Has anyone taken either of the two paths above? If so, was it successful, how could it have been better, etc. We aren't looking to deviate much from doing one of those two things, but some suggestions or other solutions would potentially be helpful.","It works out better than you'd believe. +Recently I did a large reverse-engineering job on a hideous old collection of C code. Function by function I reallocated the features that were still relevant into classes, wrote unit tests for the classes, and built up what looked like a replacement application. It had some of the original ""logic flow"" through the classes, and some classes were poorly designed [Mostly this was because of a subset of the global variables that was too hard to tease apart.] +It passed unit tests at the class level and at the overall application level. The legacy source was mostly used as a kind of ""specification in C"" to ferret out the really obscure business rules. +Last year, I wrote a project plan for replacing 30-year old COBOL. The customer was leaning toward Java. I prototyped the revised data model in Python using Django as part of the planning effort. I could demo the core transactions before I was done planning. +Note: It was quicker to build a the model and admin interface in Django than to plan the project as a whole. +Because of the ""we need to use Java"" mentality, the resulting project will be larger and more expensive than finishing the Django demo. With no real value to balance that cost. +Also, I did the same basic ""prototype in Django"" for a VB desktop application that needed to become a web application. I built the model in Django, loaded legacy data, and was up and running in a few weeks. I used that working prototype to specify the rest of the conversion effort. +Note: I had a working Django implementation (model and admin pages only) that I used to plan the rest of the effort. +The best part about doing this kind of prototyping in Django is that you can mess around with the model, unit tests and admin pages until you get it right. Once the model's right, you can spend the rest of your time fiddling around with the user interface until everyone's happy.",0.1352210990936997,False,7,12 2008-09-17 20:48:45.610,"If it is decided that our system needs an overhaul, what is the best way to go about it?","We are mainting a web application that is built on Classic ASP using VBScript as the primary language. We are in agreement that our backend (framework if you will) is out dated and doesn't provide us with the proper tools to move forward in a quick manner. We have pretty much embraced the current webMVC pattern that is all over the place, and cannot do it, in a reasonable manner, with the current technology. The big missing features are proper dispatching and templating with inheritance, amongst others. Currently there are two paths being discussed: @@ -238,9 +244,9 @@ Port the existing application to Classic ASP using JScript, which will allow us Completely rewrite the application using some other technology, right now the leader of the pack is Python WSGI with a custom framework, ORM, and a good templating solution. There is wiggle room here for even django and other pre-built solutions. This method would hopefully be the quickest solution, as we would probably run a beta beside the actual product, but it does have the potential for a big waste of time if we can't/don't get it right. This does not mean that our logic is gone, as what we have built over the years is fairly stable, as noted just difficult to deal with. It is built on SQL Server 2005 with heavy use of stored procedures and published on IIS 6, just for a little more background. -Now, the question. Has anyone taken either of the two paths above? If so, was it successful, how could it have been better, etc. We aren't looking to deviate much from doing one of those two things, but some suggestions or other solutions would potentially be helpful.","I would not recommend JScript as that is definitely the road less traveled. -ASP.NET MVC is rapidly maturing, and I think that you could begin a migration to it, simultaneously ramping up on the ASP.NET MVC framework as its finalization comes through. -Another option would be to use something like ASP.NET w/Subsonic or NHibernate.",0.0,False,7,12 +Now, the question. Has anyone taken either of the two paths above? If so, was it successful, how could it have been better, etc. We aren't looking to deviate much from doing one of those two things, but some suggestions or other solutions would potentially be helpful.","Use this as an opportunity to remove unused features! Definitely go with the new language. Call it 2.0. It will be a lot less work to rebuild the 80% of it that you really need. +Start by wiping your brain clean of the whole application. Sit down with a list of its overall goals, then decide which features are needed based on which ones are used. Then redesign it with those features in mind, and build. +(I love to delete code.)",0.1352210990936997,False,7,12 2008-09-17 20:48:45.610,"If it is decided that our system needs an overhaul, what is the best way to go about it?","We are mainting a web application that is built on Classic ASP using VBScript as the primary language. We are in agreement that our backend (framework if you will) is out dated and doesn't provide us with the proper tools to move forward in a quick manner. We have pretty much embraced the current webMVC pattern that is all over the place, and cannot do it, in a reasonable manner, with the current technology. The big missing features are proper dispatching and templating with inheritance, amongst others. Currently there are two paths being discussed: @@ -256,15 +262,9 @@ Port the existing application to Classic ASP using JScript, which will allow us Completely rewrite the application using some other technology, right now the leader of the pack is Python WSGI with a custom framework, ORM, and a good templating solution. There is wiggle room here for even django and other pre-built solutions. This method would hopefully be the quickest solution, as we would probably run a beta beside the actual product, but it does have the potential for a big waste of time if we can't/don't get it right. This does not mean that our logic is gone, as what we have built over the years is fairly stable, as noted just difficult to deal with. It is built on SQL Server 2005 with heavy use of stored procedures and published on IIS 6, just for a little more background. -Now, the question. Has anyone taken either of the two paths above? If so, was it successful, how could it have been better, etc. We aren't looking to deviate much from doing one of those two things, but some suggestions or other solutions would potentially be helpful.","It works out better than you'd believe. -Recently I did a large reverse-engineering job on a hideous old collection of C code. Function by function I reallocated the features that were still relevant into classes, wrote unit tests for the classes, and built up what looked like a replacement application. It had some of the original ""logic flow"" through the classes, and some classes were poorly designed [Mostly this was because of a subset of the global variables that was too hard to tease apart.] -It passed unit tests at the class level and at the overall application level. The legacy source was mostly used as a kind of ""specification in C"" to ferret out the really obscure business rules. -Last year, I wrote a project plan for replacing 30-year old COBOL. The customer was leaning toward Java. I prototyped the revised data model in Python using Django as part of the planning effort. I could demo the core transactions before I was done planning. -Note: It was quicker to build a the model and admin interface in Django than to plan the project as a whole. -Because of the ""we need to use Java"" mentality, the resulting project will be larger and more expensive than finishing the Django demo. With no real value to balance that cost. -Also, I did the same basic ""prototype in Django"" for a VB desktop application that needed to become a web application. I built the model in Django, loaded legacy data, and was up and running in a few weeks. I used that working prototype to specify the rest of the conversion effort. -Note: I had a working Django implementation (model and admin pages only) that I used to plan the rest of the effort. -The best part about doing this kind of prototyping in Django is that you can mess around with the model, unit tests and admin pages until you get it right. Once the model's right, you can spend the rest of your time fiddling around with the user interface until everyone's happy.",0.1352210990936997,False,7,12 +Now, the question. Has anyone taken either of the two paths above? If so, was it successful, how could it have been better, etc. We aren't looking to deviate much from doing one of those two things, but some suggestions or other solutions would potentially be helpful.","I would not recommend JScript as that is definitely the road less traveled. +ASP.NET MVC is rapidly maturing, and I think that you could begin a migration to it, simultaneously ramping up on the ASP.NET MVC framework as its finalization comes through. +Another option would be to use something like ASP.NET w/Subsonic or NHibernate.",0.0,False,7,12 2008-09-17 20:48:45.610,"If it is decided that our system needs an overhaul, what is the best way to go about it?","We are mainting a web application that is built on Classic ASP using VBScript as the primary language. We are in agreement that our backend (framework if you will) is out dated and doesn't provide us with the proper tools to move forward in a quick manner. We have pretty much embraced the current webMVC pattern that is all over the place, and cannot do it, in a reasonable manner, with the current technology. The big missing features are proper dispatching and templating with inheritance, amongst others. Currently there are two paths being discussed: @@ -300,9 +300,9 @@ Completely rewrite the application using some other technology, right now the le This does not mean that our logic is gone, as what we have built over the years is fairly stable, as noted just difficult to deal with. It is built on SQL Server 2005 with heavy use of stored procedures and published on IIS 6, just for a little more background. Now, the question. Has anyone taken either of the two paths above? If so, was it successful, how could it have been better, etc. We aren't looking to deviate much from doing one of those two things, but some suggestions or other solutions would potentially be helpful.",I agree with Michael Pryor and Joel that it's almost always a better idea to continue evolving your existing code base rather than re-writing from scratch. There are typically opportunities to just re-write or re-factor certain components for performance or flexibility.,0.0,False,7,12 2008-09-18 04:04:58.170,"How do I verify that a string only contains letters, numbers, underscores and dashes?",I know how to do this if I iterate through all of the characters in the string but I am looking for a more elegant method.,"You could always use a list comprehension and check the results with all, it would be a little less resource intensive than using a regex: all([c in string.letters + string.digits + [""_"", ""-""] for c in mystring])",-0.0370887312438237,False,1,13 -2008-09-18 12:51:07.733,"Python, beyond the basics",I've gotten to grips with the basics of Python and I've got a small holiday which I want to use some of to learn a little more Python. The problem is that I have no idea what to learn or where to start. I'm primarily web development but in this case I don't know how much difference it will make.,"Search ""Alex Martelli"", ""Alex Martelli patterns"" and ""Thomas Wouters"" on Google video. There's plenty of interesting talks on advanced Python, design patterns in Python, and so on.",0.0407936753323291,False,3,14 2008-09-18 12:51:07.733,"Python, beyond the basics",I've gotten to grips with the basics of Python and I've got a small holiday which I want to use some of to learn a little more Python. The problem is that I have no idea what to learn or where to start. I'm primarily web development but in this case I don't know how much difference it will make.,"I'd suggest writing a non-trivial webapp using either Django or Pylons, something that does some number crunching. No better way to learn a new language than commiting yourself to a problem and learning as you go!",0.0407936753323291,False,3,14 +2008-09-18 12:51:07.733,"Python, beyond the basics",I've gotten to grips with the basics of Python and I've got a small holiday which I want to use some of to learn a little more Python. The problem is that I have no idea what to learn or where to start. I'm primarily web development but in this case I don't know how much difference it will make.,"Search ""Alex Martelli"", ""Alex Martelli patterns"" and ""Thomas Wouters"" on Google video. There's plenty of interesting talks on advanced Python, design patterns in Python, and so on.",0.0407936753323291,False,3,14 2008-09-18 12:51:07.733,"Python, beyond the basics",I've gotten to grips with the basics of Python and I've got a small holiday which I want to use some of to learn a little more Python. The problem is that I have no idea what to learn or where to start. I'm primarily web development but in this case I don't know how much difference it will make.,"The Python Cookbook is absolutely essential if you want to master idiomatic Python. Besides, that's the book that made me fall in love with the language.",0.0814518047658113,False,3,14 2008-09-19 12:47:32.310,Algorithm to detect similar documents in python script,"I need to write a module to detect similar documents. I have read many papers of fingerprints of documents techniques and others, but I do not know how to write code or implement such a solution. The algorithm should work for Chinese, Japanese, English and German language or be language independent. How can I accomplish this?","I think Jeremy has hit the nail on the head - if you just want to detect if files are different, a hash algorithm like MD5 or SHA1 is a good way to go. Linus Torvalds' Git source control software uses SHA1 hashing in just this way - to check when files have been modified.",0.0,False,2,15 @@ -313,11 +313,6 @@ The first thing I'd probably do is separate the tokenization (the process of ext 2008-09-19 19:53:19.447,"What is ""thread local storage"" in Python, and why do I need it?","In Python specifically, how do variables get shared between threads? Although I have used threading.Thread before I never really understood or saw examples of how variables got shared. Are they shared between the main thread and the children or only among the children? When would I need to use thread local storage to avoid this sharing? I have seen many warnings about synchronizing access to shared data among threads by using locks but I have yet to see a really good example of the problem. -Thanks in advance!","Just like in every other language, every thread in Python has access to the same variables. There's no distinction between the 'main thread' and child threads. -One difference with Python is that the Global Interpreter Lock means that only one thread can be running Python code at a time. This isn't much help when it comes to synchronising access, however, as all the usual pre-emption issues still apply, and you have to use threading primitives just like in other languages. It does mean you need to reconsider if you were using threads for performance, however.",0.2012947653214861,False,3,16 -2008-09-19 19:53:19.447,"What is ""thread local storage"" in Python, and why do I need it?","In Python specifically, how do variables get shared between threads? -Although I have used threading.Thread before I never really understood or saw examples of how variables got shared. Are they shared between the main thread and the children or only among the children? When would I need to use thread local storage to avoid this sharing? -I have seen many warnings about synchronizing access to shared data among threads by using locks but I have yet to see a really good example of the problem. Thanks in advance!","I may be wrong here. If you know otherwise please expound as this would help explain why one would need to use thread local(). This statement seems off, not wrong: ""If you want to atomically modify anything that another thread has access to, you have to protect it with a lock."" I think this statement is ->effectively<- right but not entirely accurate. I thought the term ""atomic"" meant that the Python interpreter created a byte-code chunk that left no room for an interrupt signal to the CPU. I thought atomic operations are chunks of Python byte code that does not give access to interrupts. Python statements like ""running = True"" is atomic. You do not need to lock CPU from interrupts in this case (I believe). The Python byte code breakdown is safe from thread interruption. @@ -329,23 +324,28 @@ I have seen many warnings about synchronizing access to shared data among thread Thanks in advance!","Worth mentioning threading.local() is not a singleton. You can use more of them per thread. It is not one storage.",0.0679224682270276,False,3,16 +2008-09-19 19:53:19.447,"What is ""thread local storage"" in Python, and why do I need it?","In Python specifically, how do variables get shared between threads? +Although I have used threading.Thread before I never really understood or saw examples of how variables got shared. Are they shared between the main thread and the children or only among the children? When would I need to use thread local storage to avoid this sharing? +I have seen many warnings about synchronizing access to shared data among threads by using locks but I have yet to see a really good example of the problem. +Thanks in advance!","Just like in every other language, every thread in Python has access to the same variables. There's no distinction between the 'main thread' and child threads. +One difference with Python is that the Global Interpreter Lock means that only one thread can be running Python code at a time. This isn't much help when it comes to synchronising access, however, as all the usual pre-emption issues still apply, and you have to use threading primitives just like in other languages. It does mean you need to reconsider if you were using threads for performance, however.",0.2012947653214861,False,3,16 2008-09-24 12:21:02.957,Checking for code changes in all imported python modules,"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?","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. Inline reload()ing doesn't work because references to the reloaded module are not updated.",1.2,True,1,17 2008-09-25 21:18:09.800,How do you manage your custom modules?,"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 :) +To all the pythonistas, how do you handle this? Do you use PyPI or setuptools (easy_install)? or something else?","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.",0.0,False,2,18 +2008-09-25 21:18:09.800,How do you manage your custom modules?,"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 :) To all the pythonistas, how do you handle this? Do you use PyPI or setuptools (easy_install)? or something else?","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. For 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.",0.1352210990936997,False,2,18 -2008-09-25 21:18:09.800,How do you manage your custom modules?,"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 :) -To all the pythonistas, how do you handle this? Do you use PyPI or setuptools (easy_install)? or something else?","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.",0.0,False,2,18 2008-09-26 12:05:29.377,PyQt - QScrollBar,"Dear Stacktoverflow, can you show me an example of how to use a QScrollBar? Thanks.","It will come down to you using the QScrollArea, it is a widget that implements showing something that is larger than the available space. You will not need to use QScrollBar directly. I don't have a PyQt example but there is a C++ example in the QT distribution it is called the ""Image Viewer"". The object hierarchy will still be the same",1.2,True,1,19 2008-09-26 23:59:47.337,How to make a cross-module variable?,"The __debug__ variable is handy in part because it affects every module. If I want to create another variable that works the same way, how would I do it? -The variable (let's be original and call it 'foo') doesn't have to be truly global, in the sense that if I change foo in one module, it is updated in others. I'd be fine if I could set foo before importing other modules and then they would see the same value for it.","You can already do this with module-level variables. Modules are the same no matter what module they're being imported from. So you can make the variable a module-level variable in whatever module it makes sense to put it in, and access it or assign to it from other modules. It would be better to call a function to set the variable's value, or to make it a property of some singleton object. That way if you end up needing to run some code when the variable's changed, you can do so without breaking your module's external interface. -It's not usually a great way to do things — using globals seldom is — but I think this is the cleanest way to do it.",0.1684471436049839,False,2,20 -2008-09-26 23:59:47.337,How to make a cross-module variable?,"The __debug__ variable is handy in part because it affects every module. If I want to create another variable that works the same way, how would I do it? The variable (let's be original and call it 'foo') doesn't have to be truly global, in the sense that if I change foo in one module, it is updated in others. I'd be fine if I could set foo before importing other modules and then they would see the same value for it.","I believe that there are plenty of circumstances in which it does make sense and it simplifies programming to have some globals that are known across several (tightly coupled) modules. In this spirit, I would like to elaborate a bit on the idea of having a module of globals which is imported by those modules which need to reference them. When there is only one such module, I name it ""g"". In it, I assign default values for every variable I intend to treat as global. In each module that uses any of them, I do not use ""from g import var"", as this only results in a local variable which is initialized from g only at the time of the import. I make most references in the form g.var, and the ""g."" serves as a constant reminder that I am dealing with a variable that is potentially accessible to other modules. If the value of such a global variable is to be used frequently in some function in a module, then that function can make a local copy: var = g.var. However, it is important to realize that assignments to var are local, and global g.var cannot be updated without referencing g.var explicitly in an assignment. Note that you can also have multiple such globals modules shared by different subsets of your modules to keep things a little more tightly controlled. The reason I use short names for my globals modules is to avoid cluttering up the code too much with occurrences of them. With only a little experience, they become mnemonic enough with only 1 or 2 characters. It is still possible to make an assignment to, say, g.x when x was not already defined in g, and a different module can then access g.x. However, even though the interpreter permits it, this approach is not so transparent, and I do avoid it. There is still the possibility of accidentally creating a new variable in g as a result of a typo in the variable name for an assignment. Sometimes an examination of dir(g) is useful to discover any surprise names that may have arisen by such accident.",0.7408590612005881,False,2,20 +2008-09-26 23:59:47.337,How to make a cross-module variable?,"The __debug__ variable is handy in part because it affects every module. If I want to create another variable that works the same way, how would I do it? +The variable (let's be original and call it 'foo') doesn't have to be truly global, in the sense that if I change foo in one module, it is updated in others. I'd be fine if I could set foo before importing other modules and then they would see the same value for it.","You can already do this with module-level variables. Modules are the same no matter what module they're being imported from. So you can make the variable a module-level variable in whatever module it makes sense to put it in, and access it or assign to it from other modules. It would be better to call a function to set the variable's value, or to make it a property of some singleton object. That way if you end up needing to run some code when the variable's changed, you can do so without breaking your module's external interface. +It's not usually a great way to do things — using globals seldom is — but I think this is the cleanest way to do it.",0.1684471436049839,False,2,20 2008-09-30 16:50:38.440,Python GUI Application redistribution,"I need to develop a small-medium sized desktop GUI application, preferably with Python as a language of choice because of time constraints. What GUI library choices do I have which allow me to redistribute my application standalone, assuming that the users don't have a working Python installation and obviously don't have the GUI libraries I'm using either? Also, how would I go about packaging everything up in binaries of reasonable size for each target OS? (my main targets are Windows and Mac OS X) @@ -361,18 +361,13 @@ write an inefficient flooding system, where each multicaster simply re-sends eac message it receives once (unless it was sent by that particular multicaster.) I'm allowed to use the second option, and am inclined to do so. -I'm currently multicasting UDP messages (which seems to be the only option,) but that means that some messages might get lost. That means I have to be able to uniquely identify each sent UDP message, so that it can be re-sent according to #2. Should I really generate unique numbers (e.g. using the sender address and a counter) and pack them into each and every UDP message sent? How would I go about doing that? And how do I receive a single UDP message in Python, and not a stream of data (i.e. socket.recv)?","The flooding approach can cause a bad situation to get worse. If messages are dropped due to high network load, having every node resend every message will only make the situation worse. -The best approach to take depends on the nature of the data you are sending. For example: - -Multimedia data: no retries, a dropped packet is a dropped frame, which won't matter when the next frame gets there anyway. -Fixed period data: Recipient node keeps a timer that is reset each time an update is received. If the time expires, it requests the missing update from the master node. Retries can be unicast to the requesting node. - -If neither of these situations applies (every packet has to be received by every node, and the packet timing is unpredictable, so recipients can't detect missed packets on their own), then your options include: - -Explicit ACK from every node for each packet. Sender retries (unicast) any packet that is not ACKed. -TCP-based grid approach, where each node is manually repeats received packets to neighbor nodes, relying on TCP mechanisms to ensure delivery. +I'm currently multicasting UDP messages (which seems to be the only option,) but that means that some messages might get lost. That means I have to be able to uniquely identify each sent UDP message, so that it can be re-sent according to #2. Should I really generate unique numbers (e.g. using the sender address and a counter) and pack them into each and every UDP message sent? How would I go about doing that? And how do I receive a single UDP message in Python, and not a stream of data (i.e. socket.recv)?","The approach you take is going to depend very much on the nature of the data that you're sending, the scale of your network and the quantity of data you're sending. In particular it is going to depend on the number of targets each of your nodes is connected to. +If you're expecting this to scale to a large number of targets for each node and a large quantity of data then you may well find that the overhead of adding an ACK/NAK to every packet is sufficient to adversely limit your throughput, particularly when you add retransmissions into the mix. +As Frank Szczerba has said multimedia data has the benefit of being able to recover from lost packets. If you have any control over the data that you're sending you should try to design the payloads so that you minimise the susceptibility to dropped packets. +If the data that you're sending cannot tolerate dropped packets and you're trying to scale to high utilisation of your network then perhaps udp is not the best protocol to use. Implementing a series of tcp proxies (where each node retransmits, unicast, to all other connected nodes - similar to your flooding idea) would be a more reliable mechanism. +With all of that said, have you considered using true multicast for this application? -You could possibly rely on recipients noticing a missed packet upon reception of one with a later sequence number, but this requires the sender to keep the packet around until at least one additional packet has been sent. Requiring positive ACKs is more reliable (and provable).",1.2,True,2,22 +Just saw the ""homework"" tag... these suggestions might not be appropriate for a homework problem.",0.1352210990936997,False,2,22 2008-10-06 21:03:55.827,"Writing a reliable, totally-ordered multicast system in Python","I have to write a reliable, totally-ordered multicast system from scratch in Python. I can't use any external libraries. I'm allowed to use a central sequencer. There seems to be two immediate approaches: @@ -383,13 +378,18 @@ write an inefficient flooding system, where each multicaster simply re-sends eac message it receives once (unless it was sent by that particular multicaster.) I'm allowed to use the second option, and am inclined to do so. -I'm currently multicasting UDP messages (which seems to be the only option,) but that means that some messages might get lost. That means I have to be able to uniquely identify each sent UDP message, so that it can be re-sent according to #2. Should I really generate unique numbers (e.g. using the sender address and a counter) and pack them into each and every UDP message sent? How would I go about doing that? And how do I receive a single UDP message in Python, and not a stream of data (i.e. socket.recv)?","The approach you take is going to depend very much on the nature of the data that you're sending, the scale of your network and the quantity of data you're sending. In particular it is going to depend on the number of targets each of your nodes is connected to. -If you're expecting this to scale to a large number of targets for each node and a large quantity of data then you may well find that the overhead of adding an ACK/NAK to every packet is sufficient to adversely limit your throughput, particularly when you add retransmissions into the mix. -As Frank Szczerba has said multimedia data has the benefit of being able to recover from lost packets. If you have any control over the data that you're sending you should try to design the payloads so that you minimise the susceptibility to dropped packets. -If the data that you're sending cannot tolerate dropped packets and you're trying to scale to high utilisation of your network then perhaps udp is not the best protocol to use. Implementing a series of tcp proxies (where each node retransmits, unicast, to all other connected nodes - similar to your flooding idea) would be a more reliable mechanism. -With all of that said, have you considered using true multicast for this application? +I'm currently multicasting UDP messages (which seems to be the only option,) but that means that some messages might get lost. That means I have to be able to uniquely identify each sent UDP message, so that it can be re-sent according to #2. Should I really generate unique numbers (e.g. using the sender address and a counter) and pack them into each and every UDP message sent? How would I go about doing that? And how do I receive a single UDP message in Python, and not a stream of data (i.e. socket.recv)?","The flooding approach can cause a bad situation to get worse. If messages are dropped due to high network load, having every node resend every message will only make the situation worse. +The best approach to take depends on the nature of the data you are sending. For example: -Just saw the ""homework"" tag... these suggestions might not be appropriate for a homework problem.",0.1352210990936997,False,2,22 +Multimedia data: no retries, a dropped packet is a dropped frame, which won't matter when the next frame gets there anyway. +Fixed period data: Recipient node keeps a timer that is reset each time an update is received. If the time expires, it requests the missing update from the master node. Retries can be unicast to the requesting node. + +If neither of these situations applies (every packet has to be received by every node, and the packet timing is unpredictable, so recipients can't detect missed packets on their own), then your options include: + +Explicit ACK from every node for each packet. Sender retries (unicast) any packet that is not ACKed. +TCP-based grid approach, where each node is manually repeats received packets to neighbor nodes, relying on TCP mechanisms to ensure delivery. + +You could possibly rely on recipients noticing a missed packet upon reception of one with a later sequence number, but this requires the sender to keep the packet around until at least one additional packet has been sent. Requiring positive ACKs is more reliable (and provable).",1.2,True,2,22 2008-10-07 18:18:48.450,Average difference between dates in Python,"I have a series of datetime objects and would like to calculate the average delta between them. For example, if the input was (2008-10-01 12:15:00, 2008-10-01 12:25:00, 2008-10-01 12:35:00), then the average delta would be exactly 00:10:00, or 10 minutes. Any suggestions on how to calculate this using Python?","Since you seem to be throwing out the 20 minute delta between times 1 and 3 in your example, I'd say you should just sort the list of datetimes, add up the deltas between adjacent times, then divide by n-1. @@ -398,12 +398,12 @@ Do you have any code you can share with us, so we can help you debug it?",0.1618 For example, if the input was (2008-10-01 12:15:00, 2008-10-01 12:25:00, 2008-10-01 12:35:00), then the average delta would be exactly 00:10:00, or 10 minutes. Any suggestions on how to calculate this using Python?","You can subtract each successive date from the one prior (resulting in a timedelta object which represents the difference in days, seconds). You can then average the timedelta objects to find your answer.",1.2,True,2,23 2008-10-08 06:27:12.350,What is the problem with reduce()?,"There seems to be a lot of heated discussion on the net about the changes to the reduce() function in python 3.0 and how it should be removed. I am having a little difficulty understanding why this is the case; I find it quite reasonable to use it in a variety of cases. If the contempt was simply subjective, I cannot imagine that such a large number of people would care about it. -What am I missing? What is the problem with reduce()?","The primary reason of reduce's existence is to avoid writing explicit for loops with accumulators. Even though python has some facilities to support the functional style, it is not encouraged. If you like the 'real' and not 'pythonic' functional style - use a modern Lisp (Clojure?) or Haskell instead.",0.3153999413393242,False,3,24 +What am I missing? What is the problem with reduce()?","reduce() is not being removed -- it's simply being moved into the functools module. Guido's reasoning is that except for trivial cases like summation, code written using reduce() is usually clearer when written as an accumulation loop.",0.9999992527404032,False,3,24 2008-10-08 06:27:12.350,What is the problem with reduce()?,"There seems to be a lot of heated discussion on the net about the changes to the reduce() function in python 3.0 and how it should be removed. I am having a little difficulty understanding why this is the case; I find it quite reasonable to use it in a variety of cases. If the contempt was simply subjective, I cannot imagine that such a large number of people would care about it. What am I missing? What is the problem with reduce()?","People worry it encourages an obfuscated style of programming, doing something that can be achieved with clearer methods. I'm not against reduce myself, I also find it a useful tool sometimes.",0.6259286199743823,False,3,24 2008-10-08 06:27:12.350,What is the problem with reduce()?,"There seems to be a lot of heated discussion on the net about the changes to the reduce() function in python 3.0 and how it should be removed. I am having a little difficulty understanding why this is the case; I find it quite reasonable to use it in a variety of cases. If the contempt was simply subjective, I cannot imagine that such a large number of people would care about it. -What am I missing? What is the problem with reduce()?","reduce() is not being removed -- it's simply being moved into the functools module. Guido's reasoning is that except for trivial cases like summation, code written using reduce() is usually clearer when written as an accumulation loop.",0.9999992527404032,False,3,24 +What am I missing? What is the problem with reduce()?","The primary reason of reduce's existence is to avoid writing explicit for loops with accumulators. Even though python has some facilities to support the functional style, it is not encouraged. If you like the 'real' and not 'pythonic' functional style - use a modern Lisp (Clojure?) or Haskell instead.",0.3153999413393242,False,3,24 2008-10-08 07:49:01.903,When to use the Python debugger,"Since Python is a dynamic, interpreted language you don't have to compile your code before running it. Hence, it's very easy to simply write your code, run it, see what problems occur, and fix them. Using hotkeys or macros can make this incredibly quick. So, because it's so easy to immediately see the output of your program and any errors that may occur, I haven't uses a debugger tool yet. What situations may call for using a real debugger vs. the method I currently use? I'd like to know before I get into a situation and get frustrated because I don't know how to fix the problem.","In 30 years of programming I've used a debugger exactly 4 times. All four times were to read the core file produced from a C program crashing to locate the traceback information that's buried in there. @@ -436,10 +436,10 @@ Its always better to use a debugger than litter the code with prints. Normally there can be more than one point of failures resulting in a bug, all are not obvious in the first look. So you look for obvious places, if nothing is wrong there, you move ahead and add some more prints.. debugger can save you time here, you dont need to add the print and run again.",1.2,True,4,25 2008-10-10 14:52:04.360,Configuring python,"I am new to python and struggling to find how to control the amount of memory a python process can take? I am running python on a Cento OS machine with more than 2 GB of main memory size. Python is taking up only 128mb of this and I want to allocate it more. I tried to search all over the internet on this for last half an hour and found absolutely nothing! Why is it so difficult to find information on python related stuff :( I would be happy if someone could throw some light on how to configure python for various things like allowed memory size, number of threads etc. -A link to a site where most controllable parameters of python are described would be appreciated well.","Are you sure that the machine does not have a 128M process limit? If you are running the python script as a CGI inside a web server, it is quite likely that there is a process limit set - you will need to look at the web server configuration.",0.3869120172231254,False,2,26 +A link to a site where most controllable parameters of python are described would be appreciated well.","Forget all that, python just allocates more memory as needed, there is not a myriad of comandline arguments for the VM as in java, just let it run. For all comandline switches you can just run python -h or read man python.",1.2,True,2,26 2008-10-10 14:52:04.360,Configuring python,"I am new to python and struggling to find how to control the amount of memory a python process can take? I am running python on a Cento OS machine with more than 2 GB of main memory size. Python is taking up only 128mb of this and I want to allocate it more. I tried to search all over the internet on this for last half an hour and found absolutely nothing! Why is it so difficult to find information on python related stuff :( I would be happy if someone could throw some light on how to configure python for various things like allowed memory size, number of threads etc. -A link to a site where most controllable parameters of python are described would be appreciated well.","Forget all that, python just allocates more memory as needed, there is not a myriad of comandline arguments for the VM as in java, just let it run. For all comandline switches you can just run python -h or read man python.",1.2,True,2,26 +A link to a site where most controllable parameters of python are described would be appreciated well.","Are you sure that the machine does not have a 128M process limit? If you are running the python script as a CGI inside a web server, it is quite likely that there is a process limit set - you will need to look at the web server configuration.",0.3869120172231254,False,2,26 2008-10-13 14:26:10.293,Dealing with a string containing multiple character encodings,"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. I'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: ""^LThis is an example ^Gstring with multiple ^Jcharacter encodings"" @@ -485,25 +485,17 @@ Thanks for your patience!","If you want to handle arbitrary expressions like {'{ 2008-10-17 09:02:12.737,Using SQLite in a Python program,"I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially ""inline"", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in production. What I'm trying to do is have a method check to see if the database is already created. If so, then I can use it. If not, an exception is raised and the program will create the database. (Or use if/else statements, whichever is better). I created a test script to see if my logic is correct but it's not working. When I create the try statement, it just creates a new database rather than checking if one already exists. The next time I run the script, I get an error that the table already exists, even if I tried catching the exception. (I haven't used try/except before but figured this is a good time to learn). -Are there any good tutorials for using SQLite operationally or any suggestions on how to code this? I've looked through the pysqlite tutorial and others I found but they don't address this.","Yes, I was nuking out the problem. All I needed to do was check for the file and catch the IOError if it didn't exist. -Thanks for all the other answers. They may come in handy in the future.",0.0,False,5,30 +Are there any good tutorials for using SQLite operationally or any suggestions on how to code this? I've looked through the pysqlite tutorial and others I found but they don't address this.","SQLite automatically creates the database file the first time you try to use it. The SQL statements for creating tables can use IF NOT EXISTS to make the commands only take effect if the table has not been created This way you don't need to check for the database's existence beforehand: SQLite can take care of that for you. +The main thing I would still be worried about is that executing CREATE TABLE IF EXISTS for every web transaction (say) would be inefficient; you can avoid that by having the program keep an (in-memory) variable saying whether it has created the database today, so it runs the CREATE TABLE script once per run. This would still allow for you to delete the database and start over during debugging.",0.3426949069654599,False,5,30 2008-10-17 09:02:12.737,Using SQLite in a Python program,"I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially ""inline"", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in production. What I'm trying to do is have a method check to see if the database is already created. If so, then I can use it. If not, an exception is raised and the program will create the database. (Or use if/else statements, whichever is better). I created a test script to see if my logic is correct but it's not working. When I create the try statement, it just creates a new database rather than checking if one already exists. The next time I run the script, I get an error that the table already exists, even if I tried catching the exception. (I haven't used try/except before but figured this is a good time to learn). -Are there any good tutorials for using SQLite operationally or any suggestions on how to code this? I've looked through the pysqlite tutorial and others I found but they don't address this.","Don't make this more complex than it needs to be. The big, independent databases have complex setup and configuration requirements. SQLite is just a file you access with SQL, it's much simpler. -Do the following. - -Add a table to your database for ""Components"" or ""Versions"" or ""Configuration"" or ""Release"" or something administrative like that. -CREATE TABLE REVISION( - RELEASE_NUMBER CHAR(20) -); -In your application, connect to your database normally. -Execute a simple query against the revision table. Here's what can happen. - - -The query fails to execute: your database doesn't exist, so execute a series of CREATE statements to build it. -The query succeeds but returns no rows or the release number is lower than expected: your database exists, but is out of date. You need to migrate from that release to the current release. Hopefully, you have a sequence of DROP, CREATE and ALTER statements to do this. -The query succeeds, and the release number is the expected value. Do nothing more, your database is configured correctly.",0.9985806592017988,False,5,30 +Are there any good tutorials for using SQLite operationally or any suggestions on how to code this? I've looked through the pysqlite tutorial and others I found but they don't address this.","AFAIK an SQLITE database is just a file. +To check if the database exists, check for file existence. +When you open a SQLITE database it will automatically create one if the file that backs it up is not in place. +If you try and open a file as a sqlite3 database that is NOT a database, you will get this: +""sqlite3.DatabaseError: file is encrypted or is not a database"" +so check to see if the file exists and also make sure to try and catch the exception in case the file is not a sqlite3 database",1.2,True,5,30 2008-10-17 09:02:12.737,Using SQLite in a Python program,"I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially ""inline"", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in production. What I'm trying to do is have a method check to see if the database is already created. If so, then I can use it. If not, an exception is raised and the program will create the database. (Or use if/else statements, whichever is better). I created a test script to see if my logic is correct but it's not working. When I create the try statement, it just creates a new database rather than checking if one already exists. The next time I run the script, I get an error that the table already exists, even if I tried catching the exception. (I haven't used try/except before but figured this is a good time to learn). @@ -520,21 +512,29 @@ After creating a session, you can commit and query from the database.",0.1518770 2008-10-17 09:02:12.737,Using SQLite in a Python program,"I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially ""inline"", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in production. What I'm trying to do is have a method check to see if the database is already created. If so, then I can use it. If not, an exception is raised and the program will create the database. (Or use if/else statements, whichever is better). I created a test script to see if my logic is correct but it's not working. When I create the try statement, it just creates a new database rather than checking if one already exists. The next time I run the script, I get an error that the table already exists, even if I tried catching the exception. (I haven't used try/except before but figured this is a good time to learn). -Are there any good tutorials for using SQLite operationally or any suggestions on how to code this? I've looked through the pysqlite tutorial and others I found but they don't address this.","AFAIK an SQLITE database is just a file. -To check if the database exists, check for file existence. -When you open a SQLITE database it will automatically create one if the file that backs it up is not in place. -If you try and open a file as a sqlite3 database that is NOT a database, you will get this: -""sqlite3.DatabaseError: file is encrypted or is not a database"" -so check to see if the file exists and also make sure to try and catch the exception in case the file is not a sqlite3 database",1.2,True,5,30 +Are there any good tutorials for using SQLite operationally or any suggestions on how to code this? I've looked through the pysqlite tutorial and others I found but they don't address this.","Don't make this more complex than it needs to be. The big, independent databases have complex setup and configuration requirements. SQLite is just a file you access with SQL, it's much simpler. +Do the following. + +Add a table to your database for ""Components"" or ""Versions"" or ""Configuration"" or ""Release"" or something administrative like that. +CREATE TABLE REVISION( + RELEASE_NUMBER CHAR(20) +); +In your application, connect to your database normally. +Execute a simple query against the revision table. Here's what can happen. + + +The query fails to execute: your database doesn't exist, so execute a series of CREATE statements to build it. +The query succeeds but returns no rows or the release number is lower than expected: your database exists, but is out of date. You need to migrate from that release to the current release. Hopefully, you have a sequence of DROP, CREATE and ALTER statements to do this. +The query succeeds, and the release number is the expected value. Do nothing more, your database is configured correctly.",0.9985806592017988,False,5,30 2008-10-17 09:02:12.737,Using SQLite in a Python program,"I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially ""inline"", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in production. What I'm trying to do is have a method check to see if the database is already created. If so, then I can use it. If not, an exception is raised and the program will create the database. (Or use if/else statements, whichever is better). I created a test script to see if my logic is correct but it's not working. When I create the try statement, it just creates a new database rather than checking if one already exists. The next time I run the script, I get an error that the table already exists, even if I tried catching the exception. (I haven't used try/except before but figured this is a good time to learn). -Are there any good tutorials for using SQLite operationally or any suggestions on how to code this? I've looked through the pysqlite tutorial and others I found but they don't address this.","SQLite automatically creates the database file the first time you try to use it. The SQL statements for creating tables can use IF NOT EXISTS to make the commands only take effect if the table has not been created This way you don't need to check for the database's existence beforehand: SQLite can take care of that for you. -The main thing I would still be worried about is that executing CREATE TABLE IF EXISTS for every web transaction (say) would be inefficient; you can avoid that by having the program keep an (in-memory) variable saying whether it has created the database today, so it runs the CREATE TABLE script once per run. This would still allow for you to delete the database and start over during debugging.",0.3426949069654599,False,5,30 +Are there any good tutorials for using SQLite operationally or any suggestions on how to code this? I've looked through the pysqlite tutorial and others I found but they don't address this.","Yes, I was nuking out the problem. All I needed to do was check for the file and catch the IOError if it didn't exist. +Thanks for all the other answers. They may come in handy in the future.",0.0,False,5,30 +2008-10-20 17:19:57.223,How do I use Tkinter with Python on Windows Vista?,"I installed Python 2.6 for one user on Windows Vista. Python works okay, but when I try: import Tkinter, it says the side-by-side configuration has errors. I've tried tinkering with the Visual Studio runtime, with no good results. Any ideas on how to resolve this?",Maybe you should downgrade to 2.5 version?,1.2,True,3,31 2008-10-20 17:19:57.223,How do I use Tkinter with Python on Windows Vista?,"I installed Python 2.6 for one user on Windows Vista. Python works okay, but when I try: import Tkinter, it says the side-by-side configuration has errors. I've tried tinkering with the Visual Studio runtime, with no good results. Any ideas on how to resolve this?","It seems this is a one of the many weird Vista problems and some random reinstalling, installing/upgrading of the visual studio runtime or some such seems sometimes to help, or disabling sxs in the system configuration or writing a manifest file etc. Though I think you should downgrade to windows XP.",0.1352210990936997,False,3,31 2008-10-20 17:19:57.223,How do I use Tkinter with Python on Windows Vista?,"I installed Python 2.6 for one user on Windows Vista. Python works okay, but when I try: import Tkinter, it says the side-by-side configuration has errors. I've tried tinkering with the Visual Studio runtime, with no good results. Any ideas on how to resolve this?","python 2.6.2 + tkinter 8.5, no problems",-0.1352210990936997,False,3,31 -2008-10-20 17:19:57.223,How do I use Tkinter with Python on Windows Vista?,"I installed Python 2.6 for one user on Windows Vista. Python works okay, but when I try: import Tkinter, it says the side-by-side configuration has errors. I've tried tinkering with the Visual Studio runtime, with no good results. Any ideas on how to resolve this?",Maybe you should downgrade to 2.5 version?,1.2,True,3,31 2008-10-22 02:54:17.533,Alternatives to a wizard,"I'm making a program that fits the wizard concept ideally; the user is walked through the steps to create a character for a game. However, I'm realizing that the limitations of the wizard are making it difficult to design ""elegant"" logic flow. For example, because all pages of the wizard are initalized at the same time, I can't have the values entered in one page available to the next one. I have to put a button on each page to get the values from a previous page rather than simply having fields auto-populated. I've thought about alternatives to using the wizard. I think the best idea is to have some buttons on one panel that change the information on another panel, e.g. a splitter window. @@ -579,7 +579,8 @@ When you make changes deep inside the code, how do you find out what operations How do you handle/prevent typing errors (typos)? Are UnitTest's used as a substitute for static type checking? -As 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.","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.",0.1518770276964961,False,4,34 +As 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.","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. +Proponents 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.",0.1016881243684853,False,4,34 2008-10-25 13:30:27.933,How can I use Python for large scale development?,"I would be interested to learn about large scale development in Python and especially in how do you maintain a large code base? When 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? @@ -587,8 +588,7 @@ When you make changes deep inside the code, how do you find out what operations How do you handle/prevent typing errors (typos)? Are UnitTest's used as a substitute for static type checking? -As 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.","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. -Python (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.",1.2,True,4,34 +As 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.","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.",0.1518770276964961,False,4,34 2008-10-25 13:30:27.933,How can I use Python for large scale development?,"I would be interested to learn about large scale development in Python and especially in how do you maintain a large code base? When 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? @@ -596,8 +596,12 @@ When you make changes deep inside the code, how do you find out what operations How do you handle/prevent typing errors (typos)? Are UnitTest's used as a substitute for static type checking? -As 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.","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. -Proponents 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.",0.1016881243684853,False,4,34 +As 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.","I had some experience with modifying ""Frets On Fire"", an open source python ""Guitar Hero"" clone. +as I see it, python is not really suitable for a really large scale project. +I 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. +also, 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. +in 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). +I 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.",0.9999092042625952,False,4,34 2008-10-25 13:30:27.933,How can I use Python for large scale development?,"I would be interested to learn about large scale development in Python and especially in how do you maintain a large code base? When 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? @@ -605,12 +609,8 @@ When you make changes deep inside the code, how do you find out what operations How do you handle/prevent typing errors (typos)? Are UnitTest's used as a substitute for static type checking? -As 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.","I had some experience with modifying ""Frets On Fire"", an open source python ""Guitar Hero"" clone. -as I see it, python is not really suitable for a really large scale project. -I 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. -also, 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. -in 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). -I 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.",0.9999092042625952,False,4,34 +As 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.","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. +Python (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.",1.2,True,4,34 2008-10-27 03:32:24.250,getting pywin32 to work inside open office 2.4 built in python 2.3 interpreter,"I need to update data to a mssql 2005 database so I have decided to use adodbapi, which is supposed to come built into the standard installation of python 2.1.1 and greater. It needs pywin32 to work correctly and the open office python 2.3 installation does not have pywin32 built into it. It also seems like this built int python installation does not have adodbapi, as I get an error when I go import adodbapi. Any suggestions on how to get both pywin32 and adodbapi installed into this open office 2.4 python installation? @@ -646,8 +646,8 @@ I know I can use gksudo (when the user clicks on ""shutdown when done"") to ask I have thought about chmod u+s on the shutdown command so I don't need a password but I really don't want to do that. Any ideas how I can achieve this? Thanks in advance, -Ashy.","gksudo should have a timeout, I believe it's from the time you last executed a gksudo command. -So I think I'd just throw out a ""gksudo echo meh"" or something every minute. Should reset the timer and keep you active until you reboot.",1.2,True,3,40 +Ashy.","Instead of chmod u+sing the shutdown command, allowing passwordless sudo access to that command would be better.. +As for allowing shutdown at the end of the script, I suppose you could run the entire script with sudo, then drop privileges to the initial user at the start of the script?",0.4961739557460144,False,3,40 2008-11-04 22:47:39.493,How can I ask for root password but perform the action at a later time?,"I have a python script that I would like to add a ""Shutdown when done"" feature to. I know I can use gksudo (when the user clicks on ""shutdown when done"") to ask the user for root privileges but how can I use those privileges at a later time (when the script is actually finished). I have thought about chmod u+s on the shutdown command so I don't need a password but I really don't want to do that. @@ -659,8 +659,8 @@ I know I can use gksudo (when the user clicks on ""shutdown when done"") to ask I have thought about chmod u+s on the shutdown command so I don't need a password but I really don't want to do that. Any ideas how I can achieve this? Thanks in advance, -Ashy.","Instead of chmod u+sing the shutdown command, allowing passwordless sudo access to that command would be better.. -As for allowing shutdown at the end of the script, I suppose you could run the entire script with sudo, then drop privileges to the initial user at the start of the script?",0.4961739557460144,False,3,40 +Ashy.","gksudo should have a timeout, I believe it's from the time you last executed a gksudo command. +So I think I'd just throw out a ""gksudo echo meh"" or something every minute. Should reset the timer and keep you active until you reboot.",1.2,True,3,40 2008-11-05 21:50:04.180,Using Python's smtplib with Tor,"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. Ideas how this can be done?","Because of abuse by spammers, many Tor egress nodes decline to emit port 25 (SMTP) traffic, so you may have problems.",1.2,True,1,41 2008-11-06 09:39:20.723,Multiple database support in django,"From some forum I came to know that Multiple database support is added in Django at lower level, but the higher level apis are not added yet. @@ -689,16 +689,6 @@ Key to all these questions is response time. We need to be able to measure how Right 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. I'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. One 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. -So there we go, I throw this to the floor: really interested to see what ideas you guys can come up with!","If you have the budget, LoadRunner would be perfect for this.",0.0,False,2,43 -2008-11-07 11:35:00.583,How should I stress test / load test a client server application?,"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: -• How many clients can a server support? -• How many concurrent searches can a server support? -• How much data can we store in the database? -• Etc. -Key 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. -Right 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. -I'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. -One 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. So there we go, I throw this to the floor: really interested to see what ideas you guys can come up with!","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. These 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. Without knowledge of hardware then you can really only observe trends in performance over time rather than absolutes. @@ -710,38 +700,38 @@ You can do a soak test with many clients operating continously for many hours or Concurrent 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). Database 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. Other 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.",0.3869120172231254,False,2,43 +2008-11-07 11:35:00.583,How should I stress test / load test a client server application?,"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: +• How many clients can a server support? +• How many concurrent searches can a server support? +• How much data can we store in the database? +• Etc. +Key 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. +Right 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. +I'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. +One 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. +So there we go, I throw this to the floor: really interested to see what ideas you guys can come up with!","If you have the budget, LoadRunner would be perfect for this.",0.0,False,2,43 2008-11-16 22:11:25.050,How do I find userid by login (Python under *NIX),"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? I've found out that uids are in /etc/passwd, but maybe there is a more pythonic way than scanning /etc/passwd. Anybody?","Never directly scan /etc/passwd. For instance, on a Linux system I administer, the user accounts are not on /etc/passwd, but on a LDAP server. The 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).",0.9866142981514304,False,1,44 2008-11-17 14:24:32.683,What is a partial class?,"What is and how can it be used in C#. +Can you use the same concept in Python/Perl?",Because python is a dynamic language you don't need a concept like partial class. In python is possible to extend object with functionality in runtime so it possible to break class declaration into different files,0.0509761841073563,False,3,45 +2008-11-17 14:24:32.683,What is a partial class?,"What is and how can it be used in C#. Can you use the same concept in Python/Perl?","A Partial type is a type whose declaration is separated across multiple files. It makes sense to use them if you have a big class, which is hard to handle and read for a typical developer, to separate that class definition in separate files and to put in each file a logically separated section of code (for instance all public methods and proprieties in one file, private in other, db handling code in third and so on..) No you don't have the same syntactical element in Python.",0.0,False,3,45 2008-11-17 14:24:32.683,What is a partial class?,"What is and how can it be used in C#. -Can you use the same concept in Python/Perl?",Because python is a dynamic language you don't need a concept like partial class. In python is possible to extend object with functionality in runtime so it possible to break class declaration into different files,0.0509761841073563,False,3,45 -2008-11-17 14:24:32.683,What is a partial class?,"What is and how can it be used in C#. Can you use the same concept in Python/Perl?",Python also has meta classes but that is more like a template class than a partial class. A good example of meta class usage is the Django ORM. All of your table models inherit from a base model class which also gets functionality included from a meta class. It is a pretty cool concept that enables an active record like pattern (is it full active record?).,0.0,False,3,45 2008-11-17 18:56:12.727,How do I remove a specific number of files using python (version 2.5)?,I would like to remove two files from a folder at the conclusion of my script. Do I need to create a function responsible for removing these two specific files? I would like to know in some detail how to use os.remove (if that is what I should use) properly. These two files will always be discarded at the conclusion of my script (which packages a series of files together in a zip format). Thanks in advance.,"It is perfectly acceptable to have a 'cleanup()' function that you call at the end of your script, which will call 'os.remove()' on your files.",0.0,False,1,46 2008-11-18 13:52:31.717,Django Template Variables and Javascript,"When I render a page using the Django template renderer, I can pass in a dictionary variable containing various values to manipulate them in the page using {{ myVar }}. Is there a way to access the same variable in Javascript (perhaps using the DOM, I don't know how Django makes the variables accessible)? I want to be able to lookup details using an AJAX lookup based on the values contained in the variables passed in.","For a dictionary, you're best of encoding to JSON first. You can use simplejson.dumps() or if you want to convert from a data model in App Engine, you could use encode() from the GQLEncoder library.",0.2012947653214861,False,1,47 2008-11-18 16:22:39.447,How can I get my python (version 2.5) script to run a jar file inside a folder instead of from command line?,"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.","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(). On 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.",0.2012947653214861,False,1,48 -2008-11-18 18:39:05.350,What are good ways to make my Python code run first time?,"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?","Test early and test often. -This doesn't necessarily mean to jump into the test driven design pool head first (though that's not such a bad idea). It just means, test your objects and methods as soon as you have something that works. Don't wait until you have a huge pile of code before doing testing. -Invest some time in learning a testing framework. If it's trivial for you to type in a test case you'll more likely do it. If you don't have any sort of framework testing can be a pain so you'll avoid it. So, establish some good habits early on and you'll have fewer problems down the road.",0.1766972496294356,False,6,49 -2008-11-18 18:39:05.350,What are good ways to make my Python code run first time?,"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?",Using assert statement liberally.,0.126863772113723,False,6,49 -2008-11-18 18:39:05.350,What are good ways to make my Python code run first time?,"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?","All the really cool stuff is easily demonstrated in the interactive interpreter. I think this might be the ""gold standard"" for good design: -Can you exercise your class interactively? -If you can do stuff interactively, then you can write unittests and doctests with confidence that it's testable, simple, reliable. -And, more important, you can explore it interactively. There's nothing better than the instant gratification that comes from typing code and seeing exactly what happens. -The compiled language habits (write a bunch of stuff, debug a bunch of stuff, test a bunch of stuff) can be left behind. Instead, you can write a little bit of stuff, explore it, write a formal test and then attach your little bit of stuff to your growing final project. -You still do overall design. But you don't squander time writing code that may or may not work. In Python you write code that works. If you're not sure, you play with it interactively until you're sure. Then you write code that works.",0.3650092804034399,False,6,49 +2008-11-18 18:39:05.350,What are good ways to make my Python code run first time?,"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?",Eric4 IDE also has a great built-in debugger.,0.0,False,6,49 2008-11-18 18:39:05.350,What are good ways to make my Python code run first time?,"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?","The PyDev plugin for eclipse is my tool of choice. It recognizes simple syntax mistakes and indentation errors and underlines the error with a red line. It has a powerful debugger and even has a plugin called PyLint which warns you about dangerous code. Edit: It also has a user friendly stack trace on runtime errors, partial auto complete and some other nifty features. Edit again: I didn't notice that pydev was mentioned in the top post. I hope I brought something else to the table.",0.1016881243684853,False,6,49 -2008-11-18 18:39:05.350,What are good ways to make my Python code run first time?,"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?",Eric4 IDE also has a great built-in debugger.,0.0,False,6,49 2008-11-18 18:39:05.350,What are good ways to make my Python code run first time?,"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?","I am new to python, and have been trying several different debuggers. Here are the options I've come across so far: Eclipse with Pydev - If you're already using eclipse, this is probably the way to go. The debugger works well, and is pretty featureful. @@ -759,6 +749,16 @@ gc module - Interact directly with the garbage collector. heapy - Heap analyzer. For example: from guppy import hpy; hp = hpy(); print(hp.heap()) will print the most common types, their memory usage, etc. This is a very incomplete list, but hopefully it's a good start.",0.2497086294969975,False,6,49 +2008-11-18 18:39:05.350,What are good ways to make my Python code run first time?,"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?",Using assert statement liberally.,0.126863772113723,False,6,49 +2008-11-18 18:39:05.350,What are good ways to make my Python code run first time?,"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?","All the really cool stuff is easily demonstrated in the interactive interpreter. I think this might be the ""gold standard"" for good design: +Can you exercise your class interactively? +If you can do stuff interactively, then you can write unittests and doctests with confidence that it's testable, simple, reliable. +And, more important, you can explore it interactively. There's nothing better than the instant gratification that comes from typing code and seeing exactly what happens. +The compiled language habits (write a bunch of stuff, debug a bunch of stuff, test a bunch of stuff) can be left behind. Instead, you can write a little bit of stuff, explore it, write a formal test and then attach your little bit of stuff to your growing final project. +You still do overall design. But you don't squander time writing code that may or may not work. In Python you write code that works. If you're not sure, you play with it interactively until you're sure. Then you write code that works.",0.3650092804034399,False,6,49 +2008-11-18 18:39:05.350,What are good ways to make my Python code run first time?,"I'm getting quite a few errors in my code. Consequently, I would like to be able to minimize them at the outset or see as many errors as possible before code execution. Is this possible and if so, how can I do this?","Test early and test often. +This doesn't necessarily mean to jump into the test driven design pool head first (though that's not such a bad idea). It just means, test your objects and methods as soon as you have something that works. Don't wait until you have a huge pile of code before doing testing. +Invest some time in learning a testing framework. If it's trivial for you to type in a test case you'll more likely do it. If you don't have any sort of framework testing can be a pain so you'll avoid it. So, establish some good habits early on and you'll have fewer problems down the road.",0.1766972496294356,False,6,49 2008-11-18 19:51:54.423,Calling Java (or python or perl) from a PHP script,"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. My 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. Feel 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... @@ -798,11 +798,11 @@ What I need is: to get rid of any CHILD emails attached to the ROOT email AND th I cannot have this. I am only interested in ROOT attachements that are legal ie .pdf .doc. xls .rtf .tif .tiff That should do for now, I have to run to catch a bus! thanks!","Have you tried the get_payload( [i[, decode]]) method? Unlike walk it is not documented to recursively open attachments.",0.0,False,1,53 -2008-11-26 19:09:08.440,Comparing XML in a unit test in Python,"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).","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).",0.0,False,2,54 2008-11-26 19:09:08.440,Comparing XML in a unit test in Python,"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).","Why are you examining the XML data at all? The 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. The 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. Of 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.",0.1218406379589197,False,2,54 +2008-11-26 19:09:08.440,Comparing XML in a unit test in Python,"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).","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).",0.0,False,2,54 2008-12-05 12:02:54.363,How do I submit a form given only the HTML source?,"I would like to be able to submit a form in an HTML source (string). In other words I need at least the ability to generate POST parameters from a string containing HTML source of the form. This is needed in unit tests for a Django project. I would like a solution that possibly; Uses only standard Python library and Django. @@ -867,9 +867,8 @@ UPDATE2: Well here's something interesting some of the ftps we tested on appear to automatically allocate the space once the transfer starts. E.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. Permissions 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. -:'(","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. -You 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. -Sorry.",0.0,False,4,58 +:'(","“Damn the torpedoes! Full speed ahead!” +Just 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.",1.2,True,4,58 2008-12-17 18:54:03.843,Prevent ftplib from Downloading a File in Progress?,"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. We 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. What 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. @@ -897,8 +896,9 @@ UPDATE2: Well here's something interesting some of the ftps we tested on appear to automatically allocate the space once the transfer starts. E.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. Permissions 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. -:'(","“Damn the torpedoes! Full speed ahead!” -Just 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.",1.2,True,4,58 +:'(","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. +You 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. +Sorry.",0.0,False,4,58 2008-12-18 09:41:52.897,Code not waiting for class initialization!,"I have a block of code that basically intializes several classes, but they are placed in a sequential order, as later ones reference early ones. For some reason the last one initializes before the first one...it seems to me there is some sort of threading going on. What I need to know is how can I stop it from doing this? Is there some way to make a class init do something similar to sending a return value? @@ -916,6 +916,13 @@ Who has done it? How? EDIT: The TurboGears framework takes the CherryPy web server and bundles other related components such as a template engine, data access tools, JavaScript kit, etc. I am interested in MochiKit, demand CherryPy, but I don't want any other template engine than StringTemplate (architecture is critical--I don't want another broken/bad template engine). Therefore, it would be acceptable to answer this question by addressing how to integrate StringTemplate with TurboGears. It may also be acceptable to answer this question by addressing how to use CherryPy and StringTemplate in the Google App Engine. +Thanks.","Rob, +There's reason behind people's selection of tools. StringTemplate is not terribly popular for Python, there are templating engines that are much better supported and with a much wider audience. If you don't like Kid, there's also Django's templating, Jinja, Cheetah and others. Perhaps you can find in one of them the features you like so much in StringTemplate and live happily ever after.",0.0,False,2,60 +2008-12-18 21:23:50.017,How to integrate the StringTemplate engine into the CherryPy web server,"I love the StringTemplate engine, and I love the CherryPy web server, and I know that they can be integrated. +Who has done it? How? +EDIT: The TurboGears framework takes the CherryPy web server and bundles other related components such as a template engine, data access tools, JavaScript kit, etc. I am interested in MochiKit, demand CherryPy, but I don't want any other template engine than StringTemplate (architecture is critical--I don't want another broken/bad template engine). +Therefore, it would be acceptable to answer this question by addressing how to integrate StringTemplate with TurboGears. +It may also be acceptable to answer this question by addressing how to use CherryPy and StringTemplate in the Google App Engine. Thanks.","Based on the tutorials for both, it looks pretty straightforward: import stringtemplate @@ -932,36 +939,29 @@ cherrypy.quickstart(HelloWorld()) You'll probably want to have the CherryPy functions find the StringTemplate's in some location on disk instead, but the general idea will be like this. Django is conceptually similar: url's are mapped to python functions, and the python functions generally build up a context dictionary, render a template with that context object, and return the result.",0.6730655149877884,False,2,60 -2008-12-18 21:23:50.017,How to integrate the StringTemplate engine into the CherryPy web server,"I love the StringTemplate engine, and I love the CherryPy web server, and I know that they can be integrated. -Who has done it? How? -EDIT: The TurboGears framework takes the CherryPy web server and bundles other related components such as a template engine, data access tools, JavaScript kit, etc. I am interested in MochiKit, demand CherryPy, but I don't want any other template engine than StringTemplate (architecture is critical--I don't want another broken/bad template engine). -Therefore, it would be acceptable to answer this question by addressing how to integrate StringTemplate with TurboGears. -It may also be acceptable to answer this question by addressing how to use CherryPy and StringTemplate in the Google App Engine. -Thanks.","Rob, -There's reason behind people's selection of tools. StringTemplate is not terribly popular for Python, there are templating engines that are much better supported and with a much wider audience. If you don't like Kid, there's also Django's templating, Jinja, Cheetah and others. Perhaps you can find in one of them the features you like so much in StringTemplate and live happily ever after.",0.0,False,2,60 2008-12-18 21:52:22.050,How much slower is a wxWidget written in Python versus C++?,"I'm looking into writing a wxWidget that displays a graphical node network, and therefore does a lot of drawing operations. I know that using Python to do it is going to be slower, but I'd rather get it working and port it later when its functional. Ideally, if the performance hit isn't too great, I'd prefer to keep the codebase in Python for easy updates. What I'm wondering is how much slower should I expect things to go? I realize this is vague and open ended, but I just need a sense of what to expect. Will drawing 500 circles bog down? Will it be noticeable at all? What are your experiences?","For drawing, people have suggested PyGame. I like PyGame, its easy to work with and works well. Other choices would be Pyglet, or using PyOpenGL (you can most likely draw to a wx widget too, though I've never done it). Personally, I'd do it in Python using whatever library I'm most familiar with (in my case, I'd use pygtk and cairo) and worry about performance only when it becomes a problem - then profile and optimize the bottleneck, if its Python code thats slow, I'll know which bits to run in C instead.",0.1352210990936997,False,1,61 2008-12-22 02:25:02.243,"Prototype based object orientation. The good, the bad and the ugly?","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. The 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. +In summary, what is the good, the bad and the ugly parts of such approach?","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. +Looked 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. +The implementation is simple, but makes it very difficult to do effective typechecking.",0.0,False,2,62 +2008-12-22 02:25:02.243,"Prototype based object orientation. The good, the bad and the ugly?","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. +The 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. In summary, what is the good, the bad and the ugly parts of such approach?","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. Taking 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. So prototypal means much more flexible development of modules. Of course, it's quite another thing to say it's EASY to develop without static typing. IMO, it is not.",0.0814518047658113,False,2,62 -2008-12-22 02:25:02.243,"Prototype based object orientation. The good, the bad and the ugly?","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. -The 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. -In summary, what is the good, the bad and the ugly parts of such approach?","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. -Looked 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. -The implementation is simple, but makes it very difficult to do effective typechecking.",0.0,False,2,62 -2008-12-22 22:37:08.520,Using user input to find information in a Mysql database,"I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product. -I am a bit stuck on how to get started. Does anyone have any tips for me?","A barcode is simply a graphical representation of a series of characters (alphanumeric) -So if you have a method for users to enter this code (a barcode scanner), then its just an issue of querying the mysql database for the character string.",0.1016881243684853,False,3,63 2008-12-22 22:37:08.520,Using user input to find information in a Mysql database,"I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product. I am a bit stuck on how to get started. Does anyone have any tips for me?","That is a very ambiguous question. What you want can be done in many ways depending on what you actually want to do. How are your users going to enter the bar code? Are they going to use a bar code scanner? Are they entering the bar code numbers manually? Is this going to run on a desktop/laptop computer or is it going to run on a handheld device? Is the bar code scanner storing the bar codes for later retrieval or is it sending them directly to the computer. Will it send them through a USB cable or wireless?",0.0,False,3,63 2008-12-22 22:37:08.520,Using user input to find information in a Mysql database,"I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product. +I am a bit stuck on how to get started. Does anyone have any tips for me?","A barcode is simply a graphical representation of a series of characters (alphanumeric) +So if you have a method for users to enter this code (a barcode scanner), then its just an issue of querying the mysql database for the character string.",0.1016881243684853,False,3,63 +2008-12-22 22:37:08.520,Using user input to find information in a Mysql database,"I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product. I am a bit stuck on how to get started. Does anyone have any tips for me?","To start with, treat the barcode input as plain old text. It has been quite a while since I worked with barcode scanners, but I doubt they have changed that much, the older ones used to just piggyback on the keyboard input, so from a programming perspective, the net result was a stream of characters in the keyboard buffer, either typed or scanned made no difference. If the device you are targeting differs from that, you will need to write something to deal with that before you get to the database query. @@ -1023,19 +1023,6 @@ I'm just wondering how I should go about structuring this... Do I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class? Do I just create functions to calculate and just control all the numbers in there with something like an multi-D array? And actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object? -Thanks.","Well, I would use one class for the sudoku itself, with a 9 x 9 array and all the functionality to add numbers and detect errors in the pattern. -Another class will be used to solve the puzzle.",0.1016881243684853,False,5,70 -2009-01-10 23:57:46.473,Programming Design Help - How to Structure a Sudoku Solver program?,"I'm trying to create a sudoku solver program in Java (maybe Python). -I'm just wondering how I should go about structuring this... -Do I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class? -Do I just create functions to calculate and just control all the numbers in there with something like an multi-D array? -And actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object? -Thanks.","The simplest way to do it is to represent the board by a 2D 9x9 array. You'll want to have references to each row, column and 3x3 box as a separate object, so storing each cell in a String makes more sense (in Java) than using a primitive. With a String you can keep references to the same object in multiple containers.",0.0509761841073563,False,5,70 -2009-01-10 23:57:46.473,Programming Design Help - How to Structure a Sudoku Solver program?,"I'm trying to create a sudoku solver program in Java (maybe Python). -I'm just wondering how I should go about structuring this... -Do I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class? -Do I just create functions to calculate and just control all the numbers in there with something like an multi-D array? -And actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object? Thanks.","First, it looks like there are two kinds of cells. Known calls; those with a fixed value, no choices. @@ -1064,22 +1051,35 @@ If it has definite value (Known cells and Unknown cells implement this differen The above must be iterated until no changes are found. At this point, you either have it solved (all cells report a definite value), or, you have some cells with multiple values. Now you have to engage in a sophisticated back-tracking solver to find a combination of the remaining values that ""works"".",0.0,False,5,70 +2009-01-10 23:57:46.473,Programming Design Help - How to Structure a Sudoku Solver program?,"I'm trying to create a sudoku solver program in Java (maybe Python). +I'm just wondering how I should go about structuring this... +Do I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class? +Do I just create functions to calculate and just control all the numbers in there with something like an multi-D array? +And actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object? +Thanks.","Well, I would use one class for the sudoku itself, with a 9 x 9 array and all the functionality to add numbers and detect errors in the pattern. +Another class will be used to solve the puzzle.",0.1016881243684853,False,5,70 +2009-01-10 23:57:46.473,Programming Design Help - How to Structure a Sudoku Solver program?,"I'm trying to create a sudoku solver program in Java (maybe Python). +I'm just wondering how I should go about structuring this... +Do I create a class and make each box a object of that class (9x9=81 objects)? If yes, how do I control all the objects - in other words, how do I make them all call a certain method in the class? +Do I just create functions to calculate and just control all the numbers in there with something like an multi-D array? +And actually, even if I could just create multiple functions, how would I control all the objects if I were to make each box an object? +Thanks.","The simplest way to do it is to represent the board by a 2D 9x9 array. You'll want to have references to each row, column and 3x3 box as a separate object, so storing each cell in a String makes more sense (in Java) than using a primitive. With a String you can keep references to the same object in multiple containers.",0.0509761841073563,False,5,70 2009-01-12 04:05:35.690,Installing certain packages using virtualenv,"So, I want to start using virtualenv this year. I like the no-site-packages option, that is nice. However I was wondering how to install certain packages into each virtualenv. For example, lets say I want to install django into each virtualenv... is this possible, and if so, how? Does buildout address this? -Well it's not so much django, more like the django applications... I dont mind installing a version of django into each virtualenv... i was just wondering if there was some intermediate option to 'no-site-packages'","The other option (one I've used) is to easy_install Django after you've created the virtual environment. This is easily scripted. The penalty you pay is waiting for Django installation in each of your virtual environments. -I'm with Toby, though: Unless there's a compelling reason why you have to have a separate copy of Django in each virtual environment, you should just consider installing it in your main Python area, and allowing each virtual environment to use it from there.",0.0,False,2,71 +Well it's not so much django, more like the django applications... I dont mind installing a version of django into each virtualenv... i was just wondering if there was some intermediate option to 'no-site-packages'","If you want django to be installed on EACH virtualenv, you might as well install it in the site-packages directory? Just a thought.",0.1618299653758019,False,2,71 2009-01-12 04:05:35.690,Installing certain packages using virtualenv,"So, I want to start using virtualenv this year. I like the no-site-packages option, that is nice. However I was wondering how to install certain packages into each virtualenv. For example, lets say I want to install django into each virtualenv... is this possible, and if so, how? Does buildout address this? -Well it's not so much django, more like the django applications... I dont mind installing a version of django into each virtualenv... i was just wondering if there was some intermediate option to 'no-site-packages'","If you want django to be installed on EACH virtualenv, you might as well install it in the site-packages directory? Just a thought.",0.1618299653758019,False,2,71 +Well it's not so much django, more like the django applications... I dont mind installing a version of django into each virtualenv... i was just wondering if there was some intermediate option to 'no-site-packages'","The other option (one I've used) is to easy_install Django after you've created the virtual environment. This is easily scripted. The penalty you pay is waiting for Django installation in each of your virtual environments. +I'm with Toby, though: Unless there's a compelling reason why you have to have a separate copy of Django in each virtual environment, you should just consider installing it in your main Python area, and allowing each virtual environment to use it from there.",0.0,False,2,71 2009-01-12 18:38:15.180,Python: import the containing package,"In a module residing inside a package, i have the need to use a function defined within the __init__.py of that package. how can i import the package within the module that resides within the package, so i can use that function? Importing __init__ inside the module will not import the package, but instead a module named __init__, leading to two copies of things with different names... -Is there a pythonic way to do this?","This doesn't exactly answer your question, but I'm going to suggest that you move the function outside of the __init__.py file, and into another module inside that package. You can then easily import that function into your other module. If you want, you can have an import statement in the __init__.py file that will import that function (when the package is imported) as well.",0.9997979416121844,False,3,72 +Is there a pythonic way to do this?","In Django, the file manage.py has from django.core.management import execute_manager, but execute_manager is not a module. It is a function within the __init__.py module of the management directory.",0.0814518047658113,False,3,72 2009-01-12 18:38:15.180,Python: import the containing package,"In a module residing inside a package, i have the need to use a function defined within the __init__.py of that package. how can i import the package within the module that resides within the package, so i can use that function? Importing __init__ inside the module will not import the package, but instead a module named __init__, leading to two copies of things with different names... Is there a pythonic way to do this?","If the package is named testmod and your init file is therefore testmod/__init__.py and your module within the package is submod.py then from within submod.py file, you should just be able to say import testmod and use whatever you want that's defined in testmod.",0.3869120172231254,False,3,72 2009-01-12 18:38:15.180,Python: import the containing package,"In a module residing inside a package, i have the need to use a function defined within the __init__.py of that package. how can i import the package within the module that resides within the package, so i can use that function? Importing __init__ inside the module will not import the package, but instead a module named __init__, leading to two copies of things with different names... -Is there a pythonic way to do this?","In Django, the file manage.py has from django.core.management import execute_manager, but execute_manager is not a module. It is a function within the __init__.py module of the management directory.",0.0814518047658113,False,3,72 +Is there a pythonic way to do this?","This doesn't exactly answer your question, but I'm going to suggest that you move the function outside of the __init__.py file, and into another module inside that package. You can then easily import that function into your other module. If you want, you can have an import statement in the __init__.py file that will import that function (when the package is imported) as well.",0.9997979416121844,False,3,72 2009-01-12 21:11:44.310,How to implement a python REPL that nicely handles asynchronous output?,"I have a Python-based app that can accept a few commands in a simple read-eval-print-loop. I'm using raw_input('> ') to get the input. On Unix-based systems, I also import readline to make things behave a little better. All this is working fine. The problem is that there are asynchronous events coming in, and I'd like to print output as soon as they happen. Unfortunately, this makes things look ugly. The ""> "" string doesn't show up again after the output, and if the user is halfway through typing something, it chops their text in half. It should probably redraw the user's text-in-progress after printing something. This seems like it must be a solved problem. What's the proper way to do this? @@ -1210,15 +1210,15 @@ Judging from your other question about evaluating your server design it would se I'm trying it these days and it continues to crash also code navigation doesn't work well and I've problems with debugging. Surely these problems are related to my low eperience about python and I need support also in trivial things as organizing source folders, imports ecc,, thank you very much. Valerio","Python support is in beta, and as someone who works with NB for a past 2 years, I can say that even a release versions are buggy and sometimes crashes. Early Ruby support was also very shaky.",0.3869120172231254,False,1,82 2009-01-21 07:14:19.397,Python - Hits per minute implementation?,"This seems like such a trivial problem, but I can't seem to pin how I want to do it. Basically, I want to be able to produce a figure from a socket server that at any time can give the number of packets received in the last minute. How would I do that? -I was thinking of maybe summing a dictionary that uses the current second as a key, and when receiving a packet it increments that value by one, as well as setting the second+1 key above it to 0, but this just seems sloppy. Any ideas?","A common pattern for solving this in other languages is to let the thing being measured simply increment an integer. Then you leave it to the listening client to determine intervals and frequencies. -So you basically do not let the socket server know about stuff like ""minutes"", because that's a feature the observer calculates. Then you can also support multiple listeners with different interval resolution. -I suppose you want some kind of ring-buffer structure to do the rolling logging.",0.3869120172231254,False,3,83 +I was thinking of maybe summing a dictionary that uses the current second as a key, and when receiving a packet it increments that value by one, as well as setting the second+1 key above it to 0, but this just seems sloppy. Any ideas?","When you say the last minute, do you mean the exact last seconds or the last full minute from x:00 to x:59? The latter will be easier to implement and would probably give accurate results. You have one prev variable holding the value of the hits for the previous minute. Then you have a current value that increments every time there is a new hit. You return the value of prev to the users. At the change of the minute you swap prev with current and reset current. +If you want higher analysis you could split the minute in 2 to 6 slices. You need a variable or list entry for every slice. Let's say you have 6 slices of 10 seconds. You also have an index variable pointing to the current slice (0..5). For every hit you increment a temp variable. When the slice is over, you replace the value of the indexed variable with the value of temp, reset temp and move the index forward. You return the sum of the slice variables to the users.",1.2,True,3,83 2009-01-21 07:14:19.397,Python - Hits per minute implementation?,"This seems like such a trivial problem, but I can't seem to pin how I want to do it. Basically, I want to be able to produce a figure from a socket server that at any time can give the number of packets received in the last minute. How would I do that? I was thinking of maybe summing a dictionary that uses the current second as a key, and when receiving a packet it increments that value by one, as well as setting the second+1 key above it to 0, but this just seems sloppy. Any ideas?","For what it's worth, your implementation above won't work if you don't receive a packet every second, as the next second entry won't necessarily be reset to 0. Either way, afaik the ""correct"" way to do this, ala logs analysis, is to keep a limited record of all the queries you receive. So just chuck the query, time received etc. into a database, and then simple database queries will give you the use over a minute, or any minute in the past. Not sure whether this is too heavyweight for you, though.",0.1352210990936997,False,3,83 2009-01-21 07:14:19.397,Python - Hits per minute implementation?,"This seems like such a trivial problem, but I can't seem to pin how I want to do it. Basically, I want to be able to produce a figure from a socket server that at any time can give the number of packets received in the last minute. How would I do that? -I was thinking of maybe summing a dictionary that uses the current second as a key, and when receiving a packet it increments that value by one, as well as setting the second+1 key above it to 0, but this just seems sloppy. Any ideas?","When you say the last minute, do you mean the exact last seconds or the last full minute from x:00 to x:59? The latter will be easier to implement and would probably give accurate results. You have one prev variable holding the value of the hits for the previous minute. Then you have a current value that increments every time there is a new hit. You return the value of prev to the users. At the change of the minute you swap prev with current and reset current. -If you want higher analysis you could split the minute in 2 to 6 slices. You need a variable or list entry for every slice. Let's say you have 6 slices of 10 seconds. You also have an index variable pointing to the current slice (0..5). For every hit you increment a temp variable. When the slice is over, you replace the value of the indexed variable with the value of temp, reset temp and move the index forward. You return the sum of the slice variables to the users.",1.2,True,3,83 +I was thinking of maybe summing a dictionary that uses the current second as a key, and when receiving a packet it increments that value by one, as well as setting the second+1 key above it to 0, but this just seems sloppy. Any ideas?","A common pattern for solving this in other languages is to let the thing being measured simply increment an integer. Then you leave it to the listening client to determine intervals and frequencies. +So you basically do not let the socket server know about stuff like ""minutes"", because that's a feature the observer calculates. Then you can also support multiple listeners with different interval resolution. +I suppose you want some kind of ring-buffer structure to do the rolling logging.",0.3869120172231254,False,3,83 2009-01-21 19:40:34.663,How can I return system information in Python?,"Using Python, how can information such as CPU usage, memory usage (free, used, etc), process count, etc be returned in a generic manner so that the same code can be run on Linux, Windows, BSD, etc? Alternatively, how could this information be returned on all the above systems with the code specific to that OS being run only if that OS is indeed the operating environment?","It looks like you want to get a lot more information than the standard Python library offers. If I were you, I would download the source code for 'ps' or 'top', or the Gnome/KDE version of the same, or any number of system monitoring/graphing programs which are more likely to have all the necessary Unix cross platform bits, see what they do, and then make the necessary native calls with ctypes. It's trivial to detect the platform. For example with ctypes you might try to load libc.so, if that throws an exception try to load 'msvcrt.dll' and so on. Not to mention simply checking the operating system's name with os.name. Then just delegate calls to your new cross-platform API to the appropriate platform-specific (sorry) implementation. @@ -1232,12 +1232,7 @@ One tricky use case is key bindings. I want the user to be able to specify custo Now, the editor component captures keypresses. It has to have access to the keymappings, which are per-session, so it needs access to the session. Is coupling the editor to the session a good idea? Other components will also need to access the keybindings, so the session now becomes shared and can be a singleton... Is there any good reading about designing GUI applications that goes beyond MVC? This is Python and wxPython, FWIW. -[EDIT]: Added concrete usecase.","In MVC, the Model stuff is the shared state of the information. -The Control stuff is the shared state of the GUI control settings and responses to mouse-clicks and what-not. -Your scripting angle can -1) Update the Model objects. This is good. The Control can be ""Observers"" of the model objects and the View be updated to reflect the observed changes. -2) Update the Control objects. This is not so good, but... The Control objects can then make appropriate changes to the Model and/or View. -I'm not sure what the problem is with MVC. Could you provide a more detailed design example with specific issues or concerns?",0.1352210990936997,False,2,85 +[EDIT]: Added concrete usecase.","If you've looked at MVC you're probably moving in the right direction. MVC, MVP, Passive View, Supervising Controller. Those are all different ways, each with their own pros and cons, of accomplishing what you're after. I find that Passive View is the ""ideal"", but it causes you to introduce far too many widgets into your GUI interfaces (i.e. IInterface). In general I find that Supervising Controller is a good compromise.",0.2655860252697744,False,2,85 2009-01-22 23:25:40.950,Organising a GUI application,"This is going to be a generic question. I am struggling in designing a GUI application, esp. with dealing with interactions between different parts. I don't know how I should deal with shared state. On one hand, shared state is bad, and things should be as explicit as possible. On the other hand, not having shared state introduces unwanted coupling between components. @@ -1247,7 +1242,12 @@ One tricky use case is key bindings. I want the user to be able to specify custo Now, the editor component captures keypresses. It has to have access to the keymappings, which are per-session, so it needs access to the session. Is coupling the editor to the session a good idea? Other components will also need to access the keybindings, so the session now becomes shared and can be a singleton... Is there any good reading about designing GUI applications that goes beyond MVC? This is Python and wxPython, FWIW. -[EDIT]: Added concrete usecase.","If you've looked at MVC you're probably moving in the right direction. MVC, MVP, Passive View, Supervising Controller. Those are all different ways, each with their own pros and cons, of accomplishing what you're after. I find that Passive View is the ""ideal"", but it causes you to introduce far too many widgets into your GUI interfaces (i.e. IInterface). In general I find that Supervising Controller is a good compromise.",0.2655860252697744,False,2,85 +[EDIT]: Added concrete usecase.","In MVC, the Model stuff is the shared state of the information. +The Control stuff is the shared state of the GUI control settings and responses to mouse-clicks and what-not. +Your scripting angle can +1) Update the Model objects. This is good. The Control can be ""Observers"" of the model objects and the View be updated to reflect the observed changes. +2) Update the Control objects. This is not so good, but... The Control objects can then make appropriate changes to the Model and/or View. +I'm not sure what the problem is with MVC. Could you provide a more detailed design example with specific issues or concerns?",0.1352210990936997,False,2,85 2009-01-23 16:16:33.017,"When printing an image, what determines how large it will appear on a page?","Using Python's Imaging Library I want to create a PNG file. I would like it if when printing this image, without any scaling, it would always print at a known and consistent 'size' on the printed page. Is the resolution encoded in the image? @@ -1279,6 +1279,14 @@ Our inventory management system runs off a server in the office, while the three See my problem here? Basically, I am trying to think of ways I can create a central inventory control system that allows both the internal software and external websites to communicate so that inventory is always up to date and we are not selling something we don't have. Our internal inventory tracking works great and flows well, but I have no idea on how I would implement a solid tracking system that can communicate between the two. The software is all written in Python, but it does not matter as I am mostly looking for ideas and methods on how would this be implemented. +Thanks in advance for any answers, and I hope that made sense .. I can elaborate.","I don't see the problem... You have an application running on one server that manages your database locally. There's no reason a remote server can't also talk to that database. +Of course, if you don't have a database and are instead using a homegrown app to act as some sort of faux-database, I recommend that you refactor to use something sort of actual DB sooner rather than later.",0.0,False,3,88 +2009-01-28 13:39:54.740,Inventory Control Across Multiple Servers .. Ideas?,"We currently have an inventory management system that was built in-house. It works great, and we are constantly innovating it. +This past Fall, we began selling products directly on one of our websites via a Shopping Cart checkout. +Our inventory management system runs off a server in the office, while the three websites we currently have (only one actually sells things) runs off an outside source, obviously. +See my problem here? Basically, I am trying to think of ways I can create a central inventory control system that allows both the internal software and external websites to communicate so that inventory is always up to date and we are not selling something we don't have. +Our internal inventory tracking works great and flows well, but I have no idea on how I would implement a solid tracking system that can communicate between the two. +The software is all written in Python, but it does not matter as I am mostly looking for ideas and methods on how would this be implemented. Thanks in advance for any answers, and I hope that made sense .. I can elaborate.","One possibility would be to expose a web service interface on your inventory management system that allows the transactions used by the web shopfront to be accessed remotely. With a reasonably secure VPN link or ssh tunnel type arrangement, the web shopfront could get stock levels, place orders or execute searches against the inventory system. Notes: @@ -1292,14 +1300,6 @@ Our inventory management system runs off a server in the office, while the three See my problem here? Basically, I am trying to think of ways I can create a central inventory control system that allows both the internal software and external websites to communicate so that inventory is always up to date and we are not selling something we don't have. Our internal inventory tracking works great and flows well, but I have no idea on how I would implement a solid tracking system that can communicate between the two. The software is all written in Python, but it does not matter as I am mostly looking for ideas and methods on how would this be implemented. -Thanks in advance for any answers, and I hope that made sense .. I can elaborate.","I don't see the problem... You have an application running on one server that manages your database locally. There's no reason a remote server can't also talk to that database. -Of course, if you don't have a database and are instead using a homegrown app to act as some sort of faux-database, I recommend that you refactor to use something sort of actual DB sooner rather than later.",0.0,False,3,88 -2009-01-28 13:39:54.740,Inventory Control Across Multiple Servers .. Ideas?,"We currently have an inventory management system that was built in-house. It works great, and we are constantly innovating it. -This past Fall, we began selling products directly on one of our websites via a Shopping Cart checkout. -Our inventory management system runs off a server in the office, while the three websites we currently have (only one actually sells things) runs off an outside source, obviously. -See my problem here? Basically, I am trying to think of ways I can create a central inventory control system that allows both the internal software and external websites to communicate so that inventory is always up to date and we are not selling something we don't have. -Our internal inventory tracking works great and flows well, but I have no idea on how I would implement a solid tracking system that can communicate between the two. -The software is all written in Python, but it does not matter as I am mostly looking for ideas and methods on how would this be implemented. Thanks in advance for any answers, and I hope that made sense .. I can elaborate.","I'm not sure if there is any one really good solution for your problem. I think the way you are doing it now works fine, but if you don't agree then I don't know what to tell you.",0.0,False,3,88 2009-01-29 18:05:22.420,Reversing a regular expression in Python,"I want to reverse a regular expression. I.e. given a regular expression, I want to produce any string that will match that regex. I know how to do this from a theoretical computer science background using a finite state machine, but I just want to know if someone has already written a library to do this. :) @@ -1308,15 +1308,20 @@ To reiterate, I only want one string that will match the regex. Things like ""." I'm willing for this library to only work on a certain subset of regex.","Unless your regex is extremely simple (i.e. no stars or pluses), there will be infinitely many strings which match it. If your regex only involves concatenation and alternation, then you can expand each alternation into all of its possibilities, e.g. (foo|bar)(baz|quux) can be expanded into the list ['foobaz', 'fooquux', 'barbaz', 'barquux'].",0.2497086294969975,False,1,89 2009-01-30 18:21:13.493,What's a good way to keep track of class instance variables in Python?,"I'm a C++ programmer just starting to learn Python. I'd like to know how you keep track of instance variables in large Python classes. I'm used to having a .h file that gives me a neat list (complete with comments) of all the class' members. But since Python allows you to add new instance variables on the fly, how do you keep track of them all? I'm picturing a scenario where I mistakenly add a new instance variable when I already had one - but it was 1000 lines away from where I was working. Are there standard practices for avoiding this? +Edit: It appears I created some confusion with the term ""member variable."" I really mean instance variable, and I've edited my question accordingly.","First of all: class attributes, or instance attributes? Or both? =) +Usually you just add instance attributes in __init__, and class attributes in the class definition, often before method definitions... which should probably cover 90% of use cases. +If code adds attributes on the fly, it probably (hopefully :-) has good reasons for doing so... leveraging dynamic features, introspection, etc. Other than that, adding attributes this way is probably less common than you think.",1.2,True,5,90 +2009-01-30 18:21:13.493,What's a good way to keep track of class instance variables in Python?,"I'm a C++ programmer just starting to learn Python. I'd like to know how you keep track of instance variables in large Python classes. I'm used to having a .h file that gives me a neat list (complete with comments) of all the class' members. But since Python allows you to add new instance variables on the fly, how do you keep track of them all? +I'm picturing a scenario where I mistakenly add a new instance variable when I already had one - but it was 1000 lines away from where I was working. Are there standard practices for avoiding this? Edit: It appears I created some confusion with the term ""member variable."" I really mean instance variable, and I've edited my question accordingly.","The easiest is to use an IDE. PyDev is a plugin for eclipse. I'm not a full on expert in all ways pythonic, but in general I define my class members right under the class definition in python, so if I add members, they're all relative. My personal opinion is that class members should be declared in one section, for this specific reason. Local scoped variables, otoh, should be defined closest to when they are used (except in C--which I believe still requires variables to be declared at the beginning of a method).",0.0,False,5,90 2009-01-30 18:21:13.493,What's a good way to keep track of class instance variables in Python?,"I'm a C++ programmer just starting to learn Python. I'd like to know how you keep track of instance variables in large Python classes. I'm used to having a .h file that gives me a neat list (complete with comments) of all the class' members. But since Python allows you to add new instance variables on the fly, how do you keep track of them all? I'm picturing a scenario where I mistakenly add a new instance variable when I already had one - but it was 1000 lines away from where I was working. Are there standard practices for avoiding this? -Edit: It appears I created some confusion with the term ""member variable."" I really mean instance variable, and I've edited my question accordingly.","First of all: class attributes, or instance attributes? Or both? =) -Usually you just add instance attributes in __init__, and class attributes in the class definition, often before method definitions... which should probably cover 90% of use cases. -If code adds attributes on the fly, it probably (hopefully :-) has good reasons for doing so... leveraging dynamic features, introspection, etc. Other than that, adding attributes this way is probably less common than you think.",1.2,True,5,90 +Edit: It appears I created some confusion with the term ""member variable."" I really mean instance variable, and I've edited my question accordingly.","This is a common concern I hear from many programmers who come from a C, C++, or other statically typed language where variables are pre-declared. In fact it was one of the biggest concerns we heard when we were persuading programmers at our organization to abandon C for high-level programs and use Python instead. +In theory, yes you can add instance variables to an object at any time. Yes it can happen from typos, etc. In practice, it rarely results in a bug. When it does, the bugs are generally not hard to find. +As long as your classes are not bloated (1000 lines is pretty huge!) and you have ample unit tests, you should rarely run in to a real problem. In case you do, it's easy to drop to a Python console at almost any time and inspect things as much as you wish.",0.0814518047658113,False,5,90 2009-01-30 18:21:13.493,What's a good way to keep track of class instance variables in Python?,"I'm a C++ programmer just starting to learn Python. I'd like to know how you keep track of instance variables in large Python classes. I'm used to having a .h file that gives me a neat list (complete with comments) of all the class' members. But since Python allows you to add new instance variables on the fly, how do you keep track of them all? I'm picturing a scenario where I mistakenly add a new instance variable when I already had one - but it was 1000 lines away from where I was working. Are there standard practices for avoiding this? Edit: It appears I created some confusion with the term ""member variable."" I really mean instance variable, and I've edited my question accordingly.","Instance variables should be initialized in the class's __init__() method. (In general) @@ -1326,11 +1331,6 @@ I'm picturing a scenario where I mistakenly add a new instance variable when I a Edit: It appears I created some confusion with the term ""member variable."" I really mean instance variable, and I've edited my question accordingly.","I would say, the standard practice to avoid this is to not write classes where you can be 1000 lines away from anything! Seriously, that's way too much for just about any useful class, especially in a language that is as expressive as Python. Using more of what the Standard Library offers and abstracting away code into separate modules should help keeping your LOC count down. The largest classes in the standard library have well below 100 lines!",0.3869120172231254,False,5,90 -2009-01-30 18:21:13.493,What's a good way to keep track of class instance variables in Python?,"I'm a C++ programmer just starting to learn Python. I'd like to know how you keep track of instance variables in large Python classes. I'm used to having a .h file that gives me a neat list (complete with comments) of all the class' members. But since Python allows you to add new instance variables on the fly, how do you keep track of them all? -I'm picturing a scenario where I mistakenly add a new instance variable when I already had one - but it was 1000 lines away from where I was working. Are there standard practices for avoiding this? -Edit: It appears I created some confusion with the term ""member variable."" I really mean instance variable, and I've edited my question accordingly.","This is a common concern I hear from many programmers who come from a C, C++, or other statically typed language where variables are pre-declared. In fact it was one of the biggest concerns we heard when we were persuading programmers at our organization to abandon C for high-level programs and use Python instead. -In theory, yes you can add instance variables to an object at any time. Yes it can happen from typos, etc. In practice, it rarely results in a bug. When it does, the bugs are generally not hard to find. -As long as your classes are not bloated (1000 lines is pretty huge!) and you have ample unit tests, you should rarely run in to a real problem. In case you do, it's easy to drop to a Python console at almost any time and inspect things as much as you wish.",0.0814518047658113,False,5,90 2009-01-31 01:22:08.137,How to make python gracefully fail?,"I was just wondering how do you make python fail in a user defined way in all possible errors. For example, I'm writing a program that processes a (large) list of items, and some of the items may not be in the format I defined. If python detects an error, it currently just spits out an ugly error message and stop the whole process. However, I want it to just outputs the error to somewhere together with some context and then move on to the next item. If anyone can help me with this it would be greatly appreciated! @@ -1355,6 +1355,13 @@ In your proc, I would introduce some kind of logic like say, there's only a 30% 2009-02-05 21:19:20.087,How to clear the interpreter console?,"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc. Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times. I'm wondering if, and how, to clear the Python interpreter console. I've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do. +Note: I'm running on Windows, so Ctrl+L doesn't work.","I am using Spyder (Python 2.7) and to clean the interpreter console I use either +%clear +that forces the command line to go to the top and I will not see the previous old commands. +or I click ""option"" on the Console environment and select ""Restart kernel"" that removes everything.",0.0136046027467035,False,7,94 +2009-02-05 21:19:20.087,How to clear the interpreter console?,"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc. +Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times. I'm wondering if, and how, to clear the Python interpreter console. +I've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do. Note: I'm running on Windows, so Ctrl+L doesn't work.","Quickest and easiest way without a doubt is Ctrl+L. This is the same for OS X on the terminal.",0.3275988531455109,False,7,94 2009-02-05 21:19:20.087,How to clear the interpreter console?,"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc. @@ -1364,10 +1371,7 @@ Note: I'm running on Windows, so Ctrl+L doesn't work.","If it is on mac, then a 2009-02-05 21:19:20.087,How to clear the interpreter console?,"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc. Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times. I'm wondering if, and how, to clear the Python interpreter console. I've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do. -Note: I'm running on Windows, so Ctrl+L doesn't work.","I am using Spyder (Python 2.7) and to clean the interpreter console I use either -%clear -that forces the command line to go to the top and I will not see the previous old commands. -or I click ""option"" on the Console environment and select ""Restart kernel"" that removes everything.",0.0136046027467035,False,7,94 +Note: I'm running on Windows, so Ctrl+L doesn't work.",I found the simplest way is just to close the window and run a module/script to reopen the shell.,0.0136046027467035,False,7,94 2009-02-05 21:19:20.087,How to clear the interpreter console?,"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc. Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times. I'm wondering if, and how, to clear the Python interpreter console. I've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do. @@ -1375,10 +1379,6 @@ Note: I'm running on Windows, so Ctrl+L doesn't work.","OK, so this is a much le 2009-02-05 21:19:20.087,How to clear the interpreter console?,"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc. Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times. I'm wondering if, and how, to clear the Python interpreter console. I've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do. -Note: I'm running on Windows, so Ctrl+L doesn't work.",I found the simplest way is just to close the window and run a module/script to reopen the shell.,0.0136046027467035,False,7,94 -2009-02-05 21:19:20.087,How to clear the interpreter console?,"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc. -Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times. I'm wondering if, and how, to clear the Python interpreter console. -I've heard about doing a system call and either calling cls on Windows or clear on Linux, but I was hoping there was something I could command the interpreter itself to do. Note: I'm running on Windows, so Ctrl+L doesn't work.","Use idle. It has many handy features. Ctrl+F6, for example, resets the console. Closing and opening the console are good ways to clear it.",0.0543681047732388,False,7,94 2009-02-05 21:19:20.087,How to clear the interpreter console?,"Like most Python developers, I typically keep a console window open with the Python interpreter running to test commands, dir() stuff, help() stuff, etc. Like any console, after a while the visible backlog of past commands and prints gets to be cluttered, and sometimes confusing when re-running the same command several times. I'm wondering if, and how, to clear the Python interpreter console. @@ -1401,9 +1401,7 @@ If you're familiar with how Expect allows passthrough to interactive subprocesse So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite database. Then in the main thread start a CherryPy application that will query that SQLite database and serve the data. My problem is: how do I handle connections to the SQLite database from my threads and from the CherryPy application? -If I'd do a connection per thread to the database will I also be able to create/use an in memory database?","Short answer: Don't use Sqlite3 in a threaded application. -Sqlite3 databases scale well for size, but rather terribly for concurrency. You will be plagued with ""Database is locked"" errors. -If you do, you will need a connection per thread, and you have to ensure that these connections clean up after themselves. This is traditionally handled using thread-local sessions, and is performed rather well (for example) using SQLAlchemy's ScopedSession. I would use this if I were you, even if you aren't using the SQLAlchemy ORM features.",1.2,True,4,97 +If I'd do a connection per thread to the database will I also be able to create/use an in memory database?","Depending on the application the DB could be a real overhead. If we are talking about volatile data, maybe you could skip the communication via DB completely and share the data between the data gathering process and the data serving process(es) via IPC. This is not an option if the data has to be persisted, of course.",0.0,False,4,97 2009-02-07 23:18:03.840,"Python, SQLite and threading","I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP. So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite database. Then in the main thread start a CherryPy application that will query that SQLite database and serve the data. @@ -1418,7 +1416,9 @@ Just use processes -- threads won't help you.",0.0679224682270276,False,4,97 So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite database. Then in the main thread start a CherryPy application that will query that SQLite database and serve the data. My problem is: how do I handle connections to the SQLite database from my threads and from the CherryPy application? -If I'd do a connection per thread to the database will I also be able to create/use an in memory database?","Depending on the application the DB could be a real overhead. If we are talking about volatile data, maybe you could skip the communication via DB completely and share the data between the data gathering process and the data serving process(es) via IPC. This is not an option if the data has to be persisted, of course.",0.0,False,4,97 +If I'd do a connection per thread to the database will I also be able to create/use an in memory database?","Short answer: Don't use Sqlite3 in a threaded application. +Sqlite3 databases scale well for size, but rather terribly for concurrency. You will be plagued with ""Database is locked"" errors. +If you do, you will need a connection per thread, and you have to ensure that these connections clean up after themselves. This is traditionally handled using thread-local sessions, and is performed rather well (for example) using SQLAlchemy's ScopedSession. I would use this if I were you, even if you aren't using the SQLAlchemy ORM features.",1.2,True,4,97 2009-02-07 23:18:03.840,"Python, SQLite and threading","I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP. So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite database. Then in the main thread start a CherryPy application that will query that SQLite database and serve the data. @@ -1436,16 +1436,16 @@ for row in conn_or_sess_or_engine.execute(selectable_obj_or_SQLstring): 2009-02-11 16:11:44.397,Standard python interpreter has a vi command mode?,"I was working a bit in the python interpreter (python 2.4 on RHEL 5.3), and suddenly found myself in what seems to be a 'vi command mode'. That is, I can edit previous commands with typical vi key bindings, going left with h, deleting with x... I love it - the only thing is, I don't know how I got here (perhaps it's through one of the modules I've imported: pylab/matplotlib?). Can anyone shed some light on how to enable this mode in the interpreter?","For Mac OS X 10.10.3, python2.7, vi mode can be configured by placing bind -v in ~/.editrc. The last few paragraphs of the man page hint at this.",0.5457054096481145,False,1,100 -2009-02-12 20:41:14.033,Granularity of Paradigm Mixing,"When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?","Different paradigms mix in different ways. For example, Using OOP doesn't eliminate the use of subroutines and procedural code from an outside library. It merely moves the procedures around into a different place. -It is impossible to purely program with one paradigm. You may think you have a single one in mind when you program, but that's your illusion. Your resultant code will land along the borders and within the bounds of many paradigms.",0.2012947653214861,False,4,101 -2009-02-12 20:41:14.033,Granularity of Paradigm Mixing,"When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?","I am not sure that I ever think about it like this. -Once you start ""thinking in Ruby"" the multi-paradigms just merge into ... well, Ruby. -Ruby is object-oriented, but I find that other things such as the functional aspect tend to mean that some of the ""traditional"" design patters present in OO languages are just simply not relevant. The iterator is a classic example ... iteration is something that is handled elegantly in Ruby and the heavy-weight OO iteration patterns no longer really apply. This seems to be true throughout the language.",0.2012947653214861,False,4,101 -2009-02-12 20:41:14.033,Granularity of Paradigm Mixing,"When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?","Mixing paradigms has an advantage of letting you express solutions in most natural and esy way. Which is very good thing when it help keeping your program logic smaller. For example, filtering a list by some criteria is several times simpler to express with functional solution compared to traditional loop. -On the other hand, to get benefit from mixing two or more paradigms programmer should be reasonably fluent with all of them. So this is powerful tool that should be used with care.",0.1016881243684853,False,4,101 2009-02-12 20:41:14.033,Granularity of Paradigm Mixing,"When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?","Different problems require different solutions, but it helps if you solve things the same way in the same layer. And varying to wildly will just confuse you and everyone else in the project. For C++, I've found that statically typed OOP (use zope.interface in Python) work well for higher-level parts (connecting, updating, signaling, etc) and functional stuff solves many lower-level problems (parsing, nuts 'n bolts data processing, etc) more nicely. And usually, a dynamically typed scripting system is good for selecting and configuring the specific app, game level, whatnot. This may be the language itself (i.e. Python) or something else (an xml-script engine + necessary system for dynamic links in C++).",0.0,False,4,101 +2009-02-12 20:41:14.033,Granularity of Paradigm Mixing,"When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?","Mixing paradigms has an advantage of letting you express solutions in most natural and esy way. Which is very good thing when it help keeping your program logic smaller. For example, filtering a list by some criteria is several times simpler to express with functional solution compared to traditional loop. +On the other hand, to get benefit from mixing two or more paradigms programmer should be reasonably fluent with all of them. So this is powerful tool that should be used with care.",0.1016881243684853,False,4,101 +2009-02-12 20:41:14.033,Granularity of Paradigm Mixing,"When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?","I am not sure that I ever think about it like this. +Once you start ""thinking in Ruby"" the multi-paradigms just merge into ... well, Ruby. +Ruby is object-oriented, but I find that other things such as the functional aspect tend to mean that some of the ""traditional"" design patters present in OO languages are just simply not relevant. The iterator is a classic example ... iteration is something that is handled elegantly in Ruby and the heavy-weight OO iteration patterns no longer really apply. This seems to be true throughout the language.",0.2012947653214861,False,4,101 +2009-02-12 20:41:14.033,Granularity of Paradigm Mixing,"When using a multi-paradigm language such as Python, C++, D, or Ruby, how much do you mix paradigms within a single application? Within a single module? Do you believe that mixing the functional, procedural and OO paradigms at a fine granularity leads to clearer, more concise code because you're using the right tool for every subproblem, or an inconsistent mess because you're doing similar things 3 different ways?","Different paradigms mix in different ways. For example, Using OOP doesn't eliminate the use of subroutines and procedural code from an outside library. It merely moves the procedures around into a different place. +It is impossible to purely program with one paradigm. You may think you have a single one in mind when you program, but that's your illusion. Your resultant code will land along the borders and within the bounds of many paradigms.",0.2012947653214861,False,4,101 2009-02-17 13:16:25.157,Python list serialization - fastest method,"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. Which is the fastest method, and why? @@ -1474,32 +1474,32 @@ If multiple people work on the project, nobody else has to deal with installing When it's time to update a component's version, update it in your VCS and then propagate the update to your deployments via it.",0.3869120172231254,False,1,103 2009-02-18 15:25:25.633,How to convert an integer to the shortest url-safe string in Python?,"I want the shortest possible way of representing an integer in a URL. For example, 11234 can be shortened to '2be2' using hexadecimal. Since base64 uses is a 64 character encoding, it should be possible to represent an integer in base64 using even less characters than hexadecimal. The problem is I can't figure out the cleanest way to convert an integer to base64 (and back again) using Python. -The base64 module has methods for dealing with bytestrings - so maybe one solution would be to convert an integer to its binary representation as a Python string... but I'm not sure how to do that either.","Base64 takes 4 bytes/characters to encode 3 bytes and can only encode multiples of 3 bytes (and adds padding otherwise). -So representing 4 bytes (your average int) in Base64 would take 8 bytes. Encoding the same 4 bytes in hex would also take 8 bytes. So you wouldn't gain anything for a single int.",0.1084157444430997,False,2,104 -2009-02-18 15:25:25.633,How to convert an integer to the shortest url-safe string in Python?,"I want the shortest possible way of representing an integer in a URL. For example, 11234 can be shortened to '2be2' using hexadecimal. Since base64 uses is a 64 character encoding, it should be possible to represent an integer in base64 using even less characters than hexadecimal. The problem is I can't figure out the cleanest way to convert an integer to base64 (and back again) using Python. The base64 module has methods for dealing with bytestrings - so maybe one solution would be to convert an integer to its binary representation as a Python string... but I'm not sure how to do that either.","If you are looking for a way to shorten the integer representation using base64, I think you need to look elsewhere. When you encode something with base64 it doesn't get shorter, in fact it gets longer. E.g. 11234 encoded with base64 would yield MTEyMzQ= When using base64 you have overlooked the fact that you are not converting just the digits (0-9) to a 64 character encoding. You are converting 3 bytes into 4 bytes so you are guaranteed your base64 encoded string would be 33.33% longer.",0.0543681047732388,False,2,104 -2009-02-19 19:50:27.033,Python: Am I missing something?,"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. -Am I really missing something? -(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.)","To add to the answers of Andrew Hare and Baishampayan Ghose... -To 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.",0.0763815498574146,False,5,105 +2009-02-18 15:25:25.633,How to convert an integer to the shortest url-safe string in Python?,"I want the shortest possible way of representing an integer in a URL. For example, 11234 can be shortened to '2be2' using hexadecimal. Since base64 uses is a 64 character encoding, it should be possible to represent an integer in base64 using even less characters than hexadecimal. The problem is I can't figure out the cleanest way to convert an integer to base64 (and back again) using Python. +The base64 module has methods for dealing with bytestrings - so maybe one solution would be to convert an integer to its binary representation as a Python string... but I'm not sure how to do that either.","Base64 takes 4 bytes/characters to encode 3 bytes and can only encode multiples of 3 bytes (and adds padding otherwise). +So representing 4 bytes (your average int) in Base64 would take 8 bytes. Encoding the same 4 bytes in hex would also take 8 bytes. So you wouldn't gain anything for a single int.",0.1084157444430997,False,2,104 2009-02-19 19:50:27.033,Python: Am I missing something?,"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. Am I really missing something? (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.)",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.,0.0,False,5,105 2009-02-19 19:50:27.033,Python: Am I missing something?,"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. Am I really missing something? -(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.)","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.",0.0,False,5,105 -2009-02-19 19:50:27.033,Python: Am I missing something?,"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. -Am I really missing something? -(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.)",Write some Python code and post it on SO for review and feedback whether it is pythonic.,0.0509761841073563,False,5,105 -2009-02-19 19:50:27.033,Python: Am I missing something?,"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. -Am I really missing something? (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.)","Think like this: If you are writing too much for little work, something is wrong, this is not pythonic. Most 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!)",0.1016881243684853,False,5,105 +2009-02-19 19:50:27.033,Python: Am I missing something?,"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. +Am I really missing something? +(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.)",Write some Python code and post it on SO for review and feedback whether it is pythonic.,0.0509761841073563,False,5,105 +2009-02-19 19:50:27.033,Python: Am I missing something?,"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. +Am I really missing something? +(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.)","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.",0.0,False,5,105 +2009-02-19 19:50:27.033,Python: Am I missing something?,"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. +Am I really missing something? +(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.)","To add to the answers of Andrew Hare and Baishampayan Ghose... +To 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.",0.0763815498574146,False,5,105 2009-02-20 16:04:25.480,Statistics with numpy,"I am working at some plots and statistics for work and I am not sure how I can do some statistics using numpy: I have a list of prices and another one of basePrices. And I want to know how many prices are with X percent above basePrice, how many are with Y percent above basePrice. Is there a simple way to do that using numpy?","In addition to df's answer, if you want to know the specific prices that are above the base prices, you can do: prices[prices > (1.10 * base_prices)]",0.1016881243684853,False,1,106 @@ -1520,8 +1520,8 @@ as 2 but with reverse proxy from nginx, apache2 etc, with good static file handl Conversion to other protocol such as FCGI with a bridge (eg Flup) and running in a conventional web server. More? -I 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.","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. -Static data has been handled by completely separate (and somewhat ""organically"" grown) stacks, including the use of S3, Akamai, Apache and IIS, in various ways.",0.0453204071731508,False,4,108 +I 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.","Apache+mod_wsgi, +Simple, clean. (only four lines of webserver config), easy for other sysadimns to get their head around.",0.0453204071731508,False,4,108 2009-02-22 00:58:37.450,How do YOU deploy your WSGI application? (and why it is the best way),"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. So how can it be done? @@ -1542,8 +1542,8 @@ as 2 but with reverse proxy from nginx, apache2 etc, with good static file handl Conversion to other protocol such as FCGI with a bridge (eg Flup) and running in a conventional web server. More? -I 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.","Apache+mod_wsgi, -Simple, clean. (only four lines of webserver config), easy for other sysadimns to get their head around.",0.0453204071731508,False,4,108 +I 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.","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. +Static data has been handled by completely separate (and somewhat ""organically"" grown) stacks, including the use of S3, Akamai, Apache and IIS, in various ways.",0.0453204071731508,False,4,108 2009-02-22 00:58:37.450,How do YOU deploy your WSGI application? (and why it is the best way),"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. So how can it be done? @@ -1571,20 +1571,6 @@ Is it worth diving straight with a framework or to roll something simple of my o How exactly are Python apps served if I have to reload httpd to see the changes? Something like a permanent process spawning child processes, with all the major file includes happening on server start and then just lazy loading needed resources? Python supports multithreading, do I need to look into using that for a benefit when developing web apps? What would be that benefit and in what situations? -Big thanks!","When you use mod_python on a threaded Apache server (the default on Windows), CherryPy runs in the same process as Apache. In that case, you almost certainly don't want CP to restart the process. -Solution: use mod_rewrite or mod_proxy so that CherryPy runs in its own process. Then you can autoreload to your heart's content. :)",0.0814518047658113,False,2,109 -2009-02-24 09:15:24.853,Python web programming,"Good morning. -As the title indicates, I've got some questions about using python for web development. - -What is the best setup for a development environment, more specifically, what webserver to use, how to bind python with it. Preferably, I'd like it to be implementable in both, *nix and win environment. - -My major concern when I last tried apache + mod_python + CherryPy was having to reload webserver to see the changes. Is it considered normal? For some reason cherrypy's autoreload didn't work at all. - -What is the best setup to deploy a working Python app to production and why? I'm now using lighttpd for my PHP web apps, but how would it do for python compared to nginx for example? -Is it worth diving straight with a framework or to roll something simple of my own? I see that Django has got quite a lot of fans, but I'm thinking it would be overkill for my needs, so I've started looking into CherryPy. -How exactly are Python apps served if I have to reload httpd to see the changes? Something like a permanent process spawning child processes, with all the major file includes happening on server start and then just lazy loading needed resources? -Python supports multithreading, do I need to look into using that for a benefit when developing web apps? What would be that benefit and in what situations? - Big thanks!","What is the best setup for a development environment? Doesn't much matter. We use Django, which runs in Windows and Unix nicely. For production, we use Apache in Red Hat. Is having to reload webserver to see the changes considered normal? @@ -1602,6 +1588,24 @@ Embedded - mod_wsgi or mod_python have an embedded mode in which the Python inte Do I need to look into using multi-threaded? Yes and no. Yes you do need to be aware of this. No, you don't need to do very much. Apache and mod_wsgi and Django should handle this for you.",0.573727155831378,False,2,109 +2009-02-24 09:15:24.853,Python web programming,"Good morning. +As the title indicates, I've got some questions about using python for web development. + +What is the best setup for a development environment, more specifically, what webserver to use, how to bind python with it. Preferably, I'd like it to be implementable in both, *nix and win environment. + +My major concern when I last tried apache + mod_python + CherryPy was having to reload webserver to see the changes. Is it considered normal? For some reason cherrypy's autoreload didn't work at all. + +What is the best setup to deploy a working Python app to production and why? I'm now using lighttpd for my PHP web apps, but how would it do for python compared to nginx for example? +Is it worth diving straight with a framework or to roll something simple of my own? I see that Django has got quite a lot of fans, but I'm thinking it would be overkill for my needs, so I've started looking into CherryPy. +How exactly are Python apps served if I have to reload httpd to see the changes? Something like a permanent process spawning child processes, with all the major file includes happening on server start and then just lazy loading needed resources? +Python supports multithreading, do I need to look into using that for a benefit when developing web apps? What would be that benefit and in what situations? + +Big thanks!","When you use mod_python on a threaded Apache server (the default on Windows), CherryPy runs in the same process as Apache. In that case, you almost certainly don't want CP to restart the process. +Solution: use mod_rewrite or mod_proxy so that CherryPy runs in its own process. Then you can autoreload to your heart's content. :)",0.0814518047658113,False,2,109 +2009-02-25 15:39:46.823,What are good ways to upload bulk .csv data into a webapp using Django/Python?,"I have a very basic CSV file upload module working to bulk upload my user's data into my site. I process the CSV file in the backend with a python script that runs on crontab and then email the user the results of the bulk upload. This process works ok operationally, but my issue is with the format of the csv file. +Are there good tools or even basic rules on how to accept different formats of the csv file? The user may have a different order of data columns, slightly different names for the column headers (I want the email column to be entitled ""Email"", but it may say ""Primary Email"", ""Email Address""), or missing additional data columns. Any good examples of CSV upload functionality that is very permissive and user friendly? +Also, how do I tell the user to export as CSV data? I'm importing address book information, so this data often comes from Outlook, Thunderbird, other software packages that have address books. Are there other popular data formats that I should accept?","Look at csv module from stdlib. It contains presets for popualr CSV dialects like one produced by Excel. +Reader class support field mapping and if file contains column header it coes not depend on column order. For more complex logic, like looking up several alternative names for a field, you'll need to write your own implementation.",0.0679224682270276,False,2,110 2009-02-25 15:39:46.823,What are good ways to upload bulk .csv data into a webapp using Django/Python?,"I have a very basic CSV file upload module working to bulk upload my user's data into my site. I process the CSV file in the backend with a python script that runs on crontab and then email the user the results of the bulk upload. This process works ok operationally, but my issue is with the format of the csv file. Are there good tools or even basic rules on how to accept different formats of the csv file? The user may have a different order of data columns, slightly different names for the column headers (I want the email column to be entitled ""Email"", but it may say ""Primary Email"", ""Email Address""), or missing additional data columns. Any good examples of CSV upload functionality that is very permissive and user friendly? Also, how do I tell the user to export as CSV data? I'm importing address book information, so this data often comes from Outlook, Thunderbird, other software packages that have address books. Are there other popular data formats that I should accept?","If you'll copy excel table into clipboard and then paste results into notepad, you'll notice that it's tab separated. I once used it to make bulk import from most of table editors by copy-pasting data from the editor into textarea on html page. @@ -1610,20 +1614,16 @@ Javascript will process pasted data and display them to the user immediately wit Then import button is clicked, data is validated again and import results are displayed. Unfortunately, I've never heard any feedback about whenever this was easy to use or not. Anyway, I still see it as an option when implementing bulk import.",0.0679224682270276,False,2,110 -2009-02-25 15:39:46.823,What are good ways to upload bulk .csv data into a webapp using Django/Python?,"I have a very basic CSV file upload module working to bulk upload my user's data into my site. I process the CSV file in the backend with a python script that runs on crontab and then email the user the results of the bulk upload. This process works ok operationally, but my issue is with the format of the csv file. -Are there good tools or even basic rules on how to accept different formats of the csv file? The user may have a different order of data columns, slightly different names for the column headers (I want the email column to be entitled ""Email"", but it may say ""Primary Email"", ""Email Address""), or missing additional data columns. Any good examples of CSV upload functionality that is very permissive and user friendly? -Also, how do I tell the user to export as CSV data? I'm importing address book information, so this data often comes from Outlook, Thunderbird, other software packages that have address books. Are there other popular data formats that I should accept?","Look at csv module from stdlib. It contains presets for popualr CSV dialects like one produced by Excel. -Reader class support field mapping and if file contains column header it coes not depend on column order. For more complex logic, like looking up several alternative names for a field, you'll need to write your own implementation.",0.0679224682270276,False,2,110 2009-02-26 06:44:48.240,Python - How to check if a file is used by another application?,"I want to open a file which is periodically written to by another application. This application cannot be modified. I'd therefore like to only open the file when I know it is not been written to by an other application. Is there a pythonic way to do this? Otherwise, how do I achieve this in Unix and Windows? edit: I'll try and clarify. Is there a way to check if the current file has been opened by another application? I'd like to start with this question. Whether those other application read/write is irrelevant for now. I realize it is probably OS dependent, so this may not really be python related right now.","One thing I've done is have python very temporarily rename the file. If we're able to rename it, then no other process is using it. I only tested this on Windows.",0.0,False,1,111 2009-02-28 19:55:21.193,Calling function defined in exe,"I need to know a way to call a function defined in the exe from a python script. +I know how to call entire exe from py file.",Not sure if it is for windows. But you can treat an exe like a dll (if functions are exported). And they can be used by other programs.,0.1352210990936997,False,2,112 +2009-02-28 19:55:21.193,Calling function defined in exe,"I need to know a way to call a function defined in the exe from a python script. I know how to call entire exe from py file.","Unless the said executable takes command line arguments which will specify which function to use, I don't think this is possible. With that being said, if you created the EXE, command line arguments are a good way to implement the functionality you're looking for.",0.0,False,2,112 -2009-02-28 19:55:21.193,Calling function defined in exe,"I need to know a way to call a function defined in the exe from a python script. -I know how to call entire exe from py file.",Not sure if it is for windows. But you can treat an exe like a dll (if functions are exported). And they can be used by other programs.,0.1352210990936997,False,2,112 2009-02-28 20:54:02.567,External classes in Python,"I'm just beginning Python, and I'd like to use an external RSS class. Where do I put that class and how do I import it? I'd like to eventually be able to share python programs.","If you want to store your RSS file in a different place use sys.append("""") and pout the module in that directory and use import or from import *",0.0,False,1,113 2009-03-01 03:40:26.020,How can I manually register distributions with pkg_resources?,"I'm trying to get a package installed on Google App Engine. The package relies rather extensively on pkg_resources, but there's no way to run setup.py on App Engine. @@ -1641,13 +1641,6 @@ in a nutshell: How do I get all the outgoing headers from an HTTP request creat (line 293) self.addheaders = [('User-agent', client_version)] (only 'User-agent' added)",0.0,False,1,115 2009-03-05 03:18:42.560,Discovering public IP programmatically,"I'm behind a router, I need a simple command to discover my public ip (instead of googling what's my ip and clicking one the results) Are there any standard protocols for this? I've heard about STUN but I don't know how can I use it? -P.S. I'm planning on writing a short python script to do it","Your simplest way may be to ask some server on the outside of your network. -One thing to keep in mind is that different destinations may see a different address for you. The router may be multihomed. And really that's just where problems begin.",0.0763815498574146,False,3,116 -2009-03-05 03:18:42.560,Discovering public IP programmatically,"I'm behind a router, I need a simple command to discover my public ip (instead of googling what's my ip and clicking one the results) -Are there any standard protocols for this? I've heard about STUN but I don't know how can I use it? -P.S. I'm planning on writing a short python script to do it",If the network has an UpNp server running on the gateway you are able to talk to the gateway and ask it for your outside IP address.,0.0763815498574146,False,3,116 -2009-03-05 03:18:42.560,Discovering public IP programmatically,"I'm behind a router, I need a simple command to discover my public ip (instead of googling what's my ip and clicking one the results) -Are there any standard protocols for this? I've heard about STUN but I don't know how can I use it? P.S. I'm planning on writing a short python script to do it","Here are a few public services that support IPv4 and IPv6: curl http://icanhazip.com @@ -1666,6 +1659,13 @@ curl http://ip-api.com curl http://api.infoip.io/ip It's easy to make an HTTP call programmatically. So all should be relatively easy to use, and you can try multiple different URLs in case one fails.",0.0255046717588776,False,3,116 +2009-03-05 03:18:42.560,Discovering public IP programmatically,"I'm behind a router, I need a simple command to discover my public ip (instead of googling what's my ip and clicking one the results) +Are there any standard protocols for this? I've heard about STUN but I don't know how can I use it? +P.S. I'm planning on writing a short python script to do it","Your simplest way may be to ask some server on the outside of your network. +One thing to keep in mind is that different destinations may see a different address for you. The router may be multihomed. And really that's just where problems begin.",0.0763815498574146,False,3,116 +2009-03-05 03:18:42.560,Discovering public IP programmatically,"I'm behind a router, I need a simple command to discover my public ip (instead of googling what's my ip and clicking one the results) +Are there any standard protocols for this? I've heard about STUN but I don't know how can I use it? +P.S. I'm planning on writing a short python script to do it",If the network has an UpNp server running on the gateway you are able to talk to the gateway and ask it for your outside IP address.,0.0763815498574146,False,3,116 2009-03-06 16:11:46.483,Tools to ease executing raw SQL with Django ORM,"I often need to execute custom sql queries in django, and manually converting query results into objects every time is kinda painful. I wonder how fellow Slackers deal with this. Maybe someone had written some kind of a library to help dealing with custom SQL in Django?","Since the issue is ""manually converting query results into objects,"" the simplest solution is often to see if your custom SQL can fit into an ORM .extra() call rather than being a pure-SQL query. Often it can, and then you let the ORM do all the work of building up objects as usual.",1.2,True,1,117 2009-03-08 04:44:41.143,"For my app, how many threads would be optimal?","I have a simple Python web crawler. It uses SQLite to store its output and also to keep a queue. I want to make the crawler multi-threaded so that it can crawl several pages at a time. I figured i would make a thread and just run several instances of the class at once, so they all run concurrently. But the question is, how many should i run at once? should i stick to two? can i go higher? what would be a reasonable limit for a number of threads? Keep in mind that each thread goes out to a web page, downloads the html, runs a few regex searches through it, stores the info it finds in a SQLite db, and then pops the next url off the queue.","It's usually simpler to make multiple concurrent processes. Simply use subprocess to create as many Popens as you feel it necessary to run concurrently. There's no ""optimal"" number. Generally, when you run just one crawler, your PC spends a lot of time waiting. How much? Hard to say. @@ -1675,14 +1675,14 @@ You can create a graph that shows how the process scales. Based on this you can Think of it this way. 1 crawler does it's job in 1 minute. 100 pages done serially could take a 100 minutes. 100 crawlers concurrently might take on hour. Let's say that 25 crawlers finishes the job in 50 minutes. You don't know what's optimal until you run various combinations and compare the results.",0.1731644579931097,False,3,118 +2009-03-08 04:44:41.143,"For my app, how many threads would be optimal?","I have a simple Python web crawler. It uses SQLite to store its output and also to keep a queue. I want to make the crawler multi-threaded so that it can crawl several pages at a time. I figured i would make a thread and just run several instances of the class at once, so they all run concurrently. But the question is, how many should i run at once? should i stick to two? can i go higher? what would be a reasonable limit for a number of threads? Keep in mind that each thread goes out to a web page, downloads the html, runs a few regex searches through it, stores the info it finds in a SQLite db, and then pops the next url off the queue.","One thing you should keep in mind is that some servers may interpret too many concurrent requests from the same IP address as a DoS attack and abort connections or return error pages for requests that would otherwise succeed. +So it might be a good idea to limit the number of concurrent requests to the same server to a relatively low number (5 should be on the safe side).",0.0582430451621389,False,3,118 2009-03-08 04:44:41.143,"For my app, how many threads would be optimal?","I have a simple Python web crawler. It uses SQLite to store its output and also to keep a queue. I want to make the crawler multi-threaded so that it can crawl several pages at a time. I figured i would make a thread and just run several instances of the class at once, so they all run concurrently. But the question is, how many should i run at once? should i stick to two? can i go higher? what would be a reasonable limit for a number of threads? Keep in mind that each thread goes out to a web page, downloads the html, runs a few regex searches through it, stores the info it finds in a SQLite db, and then pops the next url off the queue.","You will probably find your application is bandwidth limited not CPU or I/O limited. As such, add as many as you like until performance begins to degrade. You may come up against other limits depending on your network setup. Like if you're behind an ADSL router, there will be a limit on the number of concurrent NAT sessions, which may impact making too many HTTP requests at once. Make too many and your provider may treat you as being infected by a virus or the like. There's also the issue of how many requests the server you're crawling can handle and how much of a load you want to put on it. I wrote a crawler once that used just one thread. It took about a day to process all the information I wanted at about one page every two seconds. I could've done it faster but I figured this was less of a burden for the server. So really theres no hard and fast answer. Assuming a 1-5 megabit connection I'd say you could easily have up to 20-30 threads without any problems.",1.2,True,3,118 -2009-03-08 04:44:41.143,"For my app, how many threads would be optimal?","I have a simple Python web crawler. It uses SQLite to store its output and also to keep a queue. I want to make the crawler multi-threaded so that it can crawl several pages at a time. I figured i would make a thread and just run several instances of the class at once, so they all run concurrently. But the question is, how many should i run at once? should i stick to two? can i go higher? what would be a reasonable limit for a number of threads? Keep in mind that each thread goes out to a web page, downloads the html, runs a few regex searches through it, stores the info it finds in a SQLite db, and then pops the next url off the queue.","One thing you should keep in mind is that some servers may interpret too many concurrent requests from the same IP address as a DoS attack and abort connections or return error pages for requests that would otherwise succeed. -So it might be a good idea to limit the number of concurrent requests to the same server to a relatively low number (5 should be on the safe side).",0.0582430451621389,False,3,118 2009-03-09 09:57:36.500,"Is there a way to configure the Application Pool's ""Idle timeout"" in web.config?","I know one can set the session timeout. But, if the application itself has received no requests for a given period of time, IIS shuts down the application. This behavior is configurable in the IIS management console, and I know how to do this. Still, I wonder if it is possible to configure this in web.config.","Not in IIS 6. In IIS 6, Application Pools are controlled by Worker Processes, which map to a Request Queue handled by HTTP.sys. HTTP.sys handles the communication with the WWW Server to determine when to start and stop Worker Processes. Since IIS 6 was created before .Net, there's no communication hooks between .Net and the low-level http handlers. @@ -1696,16 +1696,16 @@ Edit: I guess I can use a dictionary or a list and sort() it every time I modify it, but is this the best way?","Do you have the possibility of using Jython? I just mention it because using TreeMap, TreeSet, etc. is trivial. Also if you're coming from a Java background and you want to head in a Pythonic direction Jython is wonderful for making the transition easier. Though I recognise that use of TreeSet in this case would not be part of such a ""transition"". For Jython superusers I have a question myself: the blist package can't be imported because it uses a C file which must be imported. But would there be any advantage of using blist instead of TreeSet? Can we generally assume the JVM uses algorithms which are essentially as good as those of CPython stuff?",0.0,False,1,121 2009-03-11 02:32:55.053,Viewing all defined variables,"I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such). +Is there a way, and how can I do that?","globals(), locals(), vars(), and dir() may all help you in what you want.",0.573727155831378,False,3,122 +2009-03-11 02:32:55.053,Viewing all defined variables,"I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such). +Is there a way, and how can I do that?","In my Python 2.7 interpreter, the same whos command that exists in MATLAB exists in Python. It shows the same details as the MATLAB analog (variable name, type, and value/data). +Note that in the Python interpreter, whos lists all variables in the ""interactive namespace"".",0.2012947653214861,False,3,122 +2009-03-11 02:32:55.053,Viewing all defined variables,"I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such). Is there a way, and how can I do that?","A few things you could use: dir() will give you the list of in scope variables: globals() will give you a dictionary of global variables locals() will give you a dictionary of local variables",1.0,False,3,122 -2009-03-11 02:32:55.053,Viewing all defined variables,"I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such). -Is there a way, and how can I do that?","globals(), locals(), vars(), and dir() may all help you in what you want.",0.573727155831378,False,3,122 -2009-03-11 02:32:55.053,Viewing all defined variables,"I'm currently working on a computation in python shell. What I want to have is Matlab style listout where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such). -Is there a way, and how can I do that?","In my Python 2.7 interpreter, the same whos command that exists in MATLAB exists in Python. It shows the same details as the MATLAB analog (variable name, type, and value/data). -Note that in the Python interpreter, whos lists all variables in the ""interactive namespace"".",0.2012947653214861,False,3,122 2009-03-13 00:09:14.370,Email integration,"I was wondering if someone could help me out. In some web application, the app will send out emails, say when a new message has been posted. Then instead of signing into the application to post a reply you can just simply reply to the email and it will automatically update the web app with your response. My question is, how is this done and what is it called? Thanks","Generally: @@ -1738,21 +1738,6 @@ An ""editor"" process is any editor for that database: it changes the database c Now I want the player to reflect the editing changes quickly. I know that SQLite supplies hooks to trace database changes within the same process, but there seems to be little info on how to do this with multiple processes. I could poll the database constantly, compare records and trigger events, but that seems to be quite inefficient, especially when the database grows to a large size. -I am thinking about using a log table and triggers, but I wonder if there is a simpler method.","How many editor processes (why processes?), and how often do you expect updates? This doesn't sound like a good design, especially not considering sqlite really isn't too happy about multiple concurrent accesses to the database. -If multiple processes makes sense and you want persistence, it would probably be smarter to have the editors notify your player via sockets, pipes, shared memory or the like and then have the player (aka server process) do the persisting.",0.0509761841073563,False,5,127 -2009-03-24 11:34:34.207,How do I notify a process of an SQLite database change done in a different process?,"Let's say I have two or more processes dealing with an SQLite database - a ""player"" process and many ""editor"" processes. -The ""player"" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database. -An ""editor"" process is any editor for that database: it changes the database constantly. -Now I want the player to reflect the editing changes quickly. -I know that SQLite supplies hooks to trace database changes within the same process, but there seems to be little info on how to do this with multiple processes. -I could poll the database constantly, compare records and trigger events, but that seems to be quite inefficient, especially when the database grows to a large size. -I am thinking about using a log table and triggers, but I wonder if there is a simpler method.","If it's on the same machine, the simplest way would be to have named pipe, ""player"" with blocking read() and ""editors"" putting a token in pipe whenever they modify DB.",0.1016881243684853,False,5,127 -2009-03-24 11:34:34.207,How do I notify a process of an SQLite database change done in a different process?,"Let's say I have two or more processes dealing with an SQLite database - a ""player"" process and many ""editor"" processes. -The ""player"" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database. -An ""editor"" process is any editor for that database: it changes the database constantly. -Now I want the player to reflect the editing changes quickly. -I know that SQLite supplies hooks to trace database changes within the same process, but there seems to be little info on how to do this with multiple processes. -I could poll the database constantly, compare records and trigger events, but that seems to be quite inefficient, especially when the database grows to a large size. I am thinking about using a log table and triggers, but I wonder if there is a simpler method.","I think in that case, I would make a process to manage the database read/writes. Each editor that want to make some modifications to the database makes a call to this proccess, be it through IPC or network, or whatever method. This process can then notify the player of a change in the database. The player, when he wants to retrieve some data should make a request of the data it wants to the process managing the database. (Or the db process tells it what it needs, when it notifies of a change, so no request from the player needed) @@ -1763,13 +1748,6 @@ An ""editor"" process is any editor for that database: it changes the database c Now I want the player to reflect the editing changes quickly. I know that SQLite supplies hooks to trace database changes within the same process, but there seems to be little info on how to do this with multiple processes. I could poll the database constantly, compare records and trigger events, but that seems to be quite inefficient, especially when the database grows to a large size. -I am thinking about using a log table and triggers, but I wonder if there is a simpler method.",Just open a socket between the two processes and have the editor tell all the players about the update.,0.1016881243684853,False,5,127 -2009-03-24 11:34:34.207,How do I notify a process of an SQLite database change done in a different process?,"Let's say I have two or more processes dealing with an SQLite database - a ""player"" process and many ""editor"" processes. -The ""player"" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database. -An ""editor"" process is any editor for that database: it changes the database constantly. -Now I want the player to reflect the editing changes quickly. -I know that SQLite supplies hooks to trace database changes within the same process, but there seems to be little info on how to do this with multiple processes. -I could poll the database constantly, compare records and trigger events, but that seems to be quite inefficient, especially when the database grows to a large size. I am thinking about using a log table and triggers, but I wonder if there is a simpler method.","A relational database is not your best first choice for this. Why? You want all of your editors to pass changes to your player. @@ -1785,6 +1763,28 @@ If your message traffic is small enough so that network latency is not a problem Please clarify ""If the editor crashes while notifying, the player is permanently messed up"" in your question. This sounds like a poor design for the player service. It can't be ""permanently messed up"" unless it's not getting state from the various editors. If it's getting state from the editors (but attempting to mirror that state, for example) then you should consider a design where the player simply gets state from the editor and cannot get ""permanently messed up"".",1.2,True,5,127 +2009-03-24 11:34:34.207,How do I notify a process of an SQLite database change done in a different process?,"Let's say I have two or more processes dealing with an SQLite database - a ""player"" process and many ""editor"" processes. +The ""player"" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database. +An ""editor"" process is any editor for that database: it changes the database constantly. +Now I want the player to reflect the editing changes quickly. +I know that SQLite supplies hooks to trace database changes within the same process, but there seems to be little info on how to do this with multiple processes. +I could poll the database constantly, compare records and trigger events, but that seems to be quite inefficient, especially when the database grows to a large size. +I am thinking about using a log table and triggers, but I wonder if there is a simpler method.",Just open a socket between the two processes and have the editor tell all the players about the update.,0.1016881243684853,False,5,127 +2009-03-24 11:34:34.207,How do I notify a process of an SQLite database change done in a different process?,"Let's say I have two or more processes dealing with an SQLite database - a ""player"" process and many ""editor"" processes. +The ""player"" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database. +An ""editor"" process is any editor for that database: it changes the database constantly. +Now I want the player to reflect the editing changes quickly. +I know that SQLite supplies hooks to trace database changes within the same process, but there seems to be little info on how to do this with multiple processes. +I could poll the database constantly, compare records and trigger events, but that seems to be quite inefficient, especially when the database grows to a large size. +I am thinking about using a log table and triggers, but I wonder if there is a simpler method.","How many editor processes (why processes?), and how often do you expect updates? This doesn't sound like a good design, especially not considering sqlite really isn't too happy about multiple concurrent accesses to the database. +If multiple processes makes sense and you want persistence, it would probably be smarter to have the editors notify your player via sockets, pipes, shared memory or the like and then have the player (aka server process) do the persisting.",0.0509761841073563,False,5,127 +2009-03-24 11:34:34.207,How do I notify a process of an SQLite database change done in a different process?,"Let's say I have two or more processes dealing with an SQLite database - a ""player"" process and many ""editor"" processes. +The ""player"" process reads the database and updates a view - in my case it would be a waveform being mixed to the soundcard depending on events stored in the database. +An ""editor"" process is any editor for that database: it changes the database constantly. +Now I want the player to reflect the editing changes quickly. +I know that SQLite supplies hooks to trace database changes within the same process, but there seems to be little info on how to do this with multiple processes. +I could poll the database constantly, compare records and trigger events, but that seems to be quite inefficient, especially when the database grows to a large size. +I am thinking about using a log table and triggers, but I wonder if there is a simpler method.","If it's on the same machine, the simplest way would be to have named pipe, ""player"" with blocking read() and ""editors"" putting a token in pipe whenever they modify DB.",0.1016881243684853,False,5,127 2009-03-25 04:23:52.267,How do I tell which Python interpreter I'm using?,"I am using Python 2.5.2. How can I tell whether it is CPython or IronPython or Jython? Another question: how can I use a DLL developed in VB.NET in my project?","If you are typing ""python"" to launch it, it is probably CPython. IronPython's executable name is ""ipy"".",0.3153999413393242,False,1,128 2009-03-26 01:19:41.687,How to re import an updated package while in Python Interpreter?,"I often test my module in the Python Interpreter, and when I see an error, I quickly update the .py file. But how do I make it reflect on the Interpreter ? So, far I have been exiting and reentering the Interpreter because re importing the file again is not working for me.","So, far I have been exiting and reentering the Interpreter because re importing the file again is not working for me. @@ -1834,6 +1834,13 @@ You can store the code in a variable, but this is complicated and depends on how There are 648 rows in the database: 27 weeks of series for 24 teams. The problem is that the schedule has gotten predictable and allows teams to know in advance about weak parts of their schedule. What I want to do is take the existing schedule and randomize it. That way teams are still playing each other the proper number of times but not in the same order as before. There is one rule that has been tripping me up: each team can only play one home and one road series PER week. I had been fooling around with SELECT statements based on ORDER BY RANDOM() but I haven't figured out how to make sure a team only has one home and one road series per week. Now, I could do this in PHP (which is the language I am most comfortable with) but I am trying to make the shift to Python so I'm not sure how to get this done in Python. I know that Python doesn't seem to handle two dimensional arrays very well. +Any help would be greatly appreciated.","Have you considered keeping your same ""schedule"", and just shuffling the teams? Generating a schedule where everyone plays each other the proper number of times is possible, but if you already have such a schedule then it's much easier to just shuffle the teams. +You could keep your current table, but replace each team in it with an id (0-23, or A-X, or whatever), then randomly generate into another table where you assign each team to each id (0 = TeamJoe, 1 = TeamBob, etc). Then when it's time to shuffle again next year, just regenerate that mapping table. +Not sure if this answers the question the way you want, but is probably what I would go with (and is actually how I do it on my fantasy football website).",0.2655860252697744,False,2,135 +2009-04-05 23:34:32.857,Help Me Figure Out A Random Scheduling Algorithm using Python and PostgreSQL,"I am trying to do the schedule for the upcoming season for my simulation baseball team. I have an existing Postgresql database that contains the old schedule. +There are 648 rows in the database: 27 weeks of series for 24 teams. The problem is that the schedule has gotten predictable and allows teams to know in advance about weak parts of their schedule. What I want to do is take the existing schedule and randomize it. That way teams are still playing each other the proper number of times but not in the same order as before. +There is one rule that has been tripping me up: each team can only play one home and one road series PER week. I had been fooling around with SELECT statements based on ORDER BY RANDOM() but I haven't figured out how to make sure a team only has one home and one road series per week. +Now, I could do this in PHP (which is the language I am most comfortable with) but I am trying to make the shift to Python so I'm not sure how to get this done in Python. I know that Python doesn't seem to handle two dimensional arrays very well. Any help would be greatly appreciated.","I'm not sure I fully understand the problem, but here is how I would do it: 1. create a complete list of matches that need to happen 2. iterate over the weeks, selecting which match needs to happen in this week. @@ -1843,13 +1850,6 @@ a. use random.choice to select a random match to happen. b. determine which team has a home round for this match, using random.choice([1,2]) (if it could have been a home round for either team) c. temporarily remove all matches that get blocked by this selection. a match is blocked if one of its teams has already two matches in the week, or if both teams already have a home match in this week, or if both teams already have a road match in this week. d. when there are no available matches anymore for a week, proceed to the next week, readding all the matches that got blocked for the previous week.",0.1352210990936997,False,2,135 -2009-04-05 23:34:32.857,Help Me Figure Out A Random Scheduling Algorithm using Python and PostgreSQL,"I am trying to do the schedule for the upcoming season for my simulation baseball team. I have an existing Postgresql database that contains the old schedule. -There are 648 rows in the database: 27 weeks of series for 24 teams. The problem is that the schedule has gotten predictable and allows teams to know in advance about weak parts of their schedule. What I want to do is take the existing schedule and randomize it. That way teams are still playing each other the proper number of times but not in the same order as before. -There is one rule that has been tripping me up: each team can only play one home and one road series PER week. I had been fooling around with SELECT statements based on ORDER BY RANDOM() but I haven't figured out how to make sure a team only has one home and one road series per week. -Now, I could do this in PHP (which is the language I am most comfortable with) but I am trying to make the shift to Python so I'm not sure how to get this done in Python. I know that Python doesn't seem to handle two dimensional arrays very well. -Any help would be greatly appreciated.","Have you considered keeping your same ""schedule"", and just shuffling the teams? Generating a schedule where everyone plays each other the proper number of times is possible, but if you already have such a schedule then it's much easier to just shuffle the teams. -You could keep your current table, but replace each team in it with an id (0-23, or A-X, or whatever), then randomly generate into another table where you assign each team to each id (0 = TeamJoe, 1 = TeamBob, etc). Then when it's time to shuffle again next year, just regenerate that mapping table. -Not sure if this answers the question the way you want, but is probably what I would go with (and is actually how I do it on my fantasy football website).",0.2655860252697744,False,2,135 2009-04-07 00:39:25.627,Import XML into SQL database,"I'm working with a 20 gig XML file that I would like to import into a SQL database (preferably MySQL, since that is what I am familiar with). This seems like it would be a common task, but after Googling around a bit I haven't been able to figure out how to do it. What is the best way to do this? I know this ability is built into MySQL 6.0, but that is not an option right now because it is an alpha development release. Also, if I have to do any scripting I would prefer to use Python because that's what I am most familiar with. @@ -1857,11 +1857,11 @@ Thanks.","It may be a common task, but maybe 20GB isn't as common with MySQL as I've done this using SQL Server Integration Services and a bit of custom code. Whether you need either of those depends on what you need to do with 20GB of XML in a database. Is it going to be a single column of a single row of a table? One row per child element? SQL Server has an XML datatype if you simply want to store the XML as XML. This type allows you to do queries using XQuery, allows you to create XML indexes over the XML, and allows the XML column to be ""strongly-typed"" by referring it to a set of XML schemas, which you store in the database.",0.0,False,1,136 2009-04-07 08:36:07.227,"Python distutils, how to get a compiler that is going to be used?","For example, I may use python setup.py build --compiler=msvc or python setup.py build --compiler=mingw32 or just python setup.py build, in which case the default compiler (say, bcpp) will be used. How can I get the compiler name inside my setup.py (e. g. msvc, mingw32 and bcpp, respectively)? -UPD.: I don't need the default compiler, I need the one that is actually going to be used, which is not necessarily the default one. So far I haven't found a better way than to parse sys.argv to see if there's a --compiler... string there.","import distutils.ccompiler -compiler_name = distutils.ccompiler.get_default_compiler()",-0.0679224682270276,False,2,137 -2009-04-07 08:36:07.227,"Python distutils, how to get a compiler that is going to be used?","For example, I may use python setup.py build --compiler=msvc or python setup.py build --compiler=mingw32 or just python setup.py build, in which case the default compiler (say, bcpp) will be used. How can I get the compiler name inside my setup.py (e. g. msvc, mingw32 and bcpp, respectively)? UPD.: I don't need the default compiler, I need the one that is actually going to be used, which is not necessarily the default one. So far I haven't found a better way than to parse sys.argv to see if there's a --compiler... string there.","You can subclass the distutils.command.build_ext.build_ext command. Once build_ext.finalize_options() method has been called, the compiler type is stored in self.compiler.compiler_type as a string (the same as the one passed to the build_ext's --compiler option, e.g. 'mingw32', 'gcc', etc...).",0.4961739557460144,False,2,137 +2009-04-07 08:36:07.227,"Python distutils, how to get a compiler that is going to be used?","For example, I may use python setup.py build --compiler=msvc or python setup.py build --compiler=mingw32 or just python setup.py build, in which case the default compiler (say, bcpp) will be used. How can I get the compiler name inside my setup.py (e. g. msvc, mingw32 and bcpp, respectively)? +UPD.: I don't need the default compiler, I need the one that is actually going to be used, which is not necessarily the default one. So far I haven't found a better way than to parse sys.argv to see if there's a --compiler... string there.","import distutils.ccompiler +compiler_name = distutils.ccompiler.get_default_compiler()",-0.0679224682270276,False,2,137 2009-04-13 16:20:47.457,Django models - how to filter out duplicate values by PK after the fact?,"I build a list of Django model objects by making several queries. Then I want to remove any duplicates, (all of these objects are of the same type with an auto_increment int PK), but I can't use set() because they aren't hashable. Is there a quick and easy way to do this? I'm considering using a dict instead of a list with the id as the key.","If the order doesn't matter, use a dict.",0.0,False,1,138 2009-04-15 01:05:26.610,How to visualize IP addresses as they change in python?,"I've written a little script that collects my external IP address every time I open a new terminal window and appends it, at well as the current time, to a text file. I'm looking for ideas on a way to visualize when/how often my IP address changes. I bounce between home and campus and could separate them using the script, but it would be nice to visualize them separately. @@ -1885,10 +1885,10 @@ If you wanted to actually distribute something to other people for running this 2009-04-18 22:02:45.750,How do I modify sys.path from .htaccess to allow mod_python to see Django?,"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. How do I modify sys.path from .htaccess to allow mod_python to see Django? P.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.",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.,0.1352210990936997,False,1,141 +2009-04-19 18:00:40.033,Convert timedelta to years?,I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years.,"How exact do you need it to be? td.days / 365.25 will get you pretty close, if you're worried about leap years.",0.0968769437433111,False,4,142 +2009-04-19 18:00:40.033,Convert timedelta to years?,I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years.,"Get the number of days, then divide by 365.2425 (the mean Gregorian year) for years. Divide by 30.436875 (the mean Gregorian month) for months.",0.1352210990936997,False,4,142 2009-04-19 18:00:40.033,Convert timedelta to years?,I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years.,"In the end what you have is a maths issue. If every 4 years we have an extra day lets then dived the timedelta in days, not by 365 but 365*4 + 1, that would give you the amount of 4 years. Then divide it again by 4. timedelta / ((365*4) +1) / 4 = timedelta * 4 / (365*4 +1)",0.0194338988372611,False,4,142 -2009-04-19 18:00:40.033,Convert timedelta to years?,I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years.,"Get the number of days, then divide by 365.2425 (the mean Gregorian year) for years. Divide by 30.436875 (the mean Gregorian month) for months.",0.1352210990936997,False,4,142 -2009-04-19 18:00:40.033,Convert timedelta to years?,I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years.,"How exact do you need it to be? td.days / 365.25 will get you pretty close, if you're worried about leap years.",0.0968769437433111,False,4,142 2009-04-19 18:00:40.033,Convert timedelta to years?,I need to check if some number of years have been since some date. Currently I've got timedelta from datetime module and I don't know how to convert it to years.,"If you're trying to check if someone is 18 years of age, using timedelta will not work correctly on some edge cases because of leap years. For example, someone born on January 1, 2000, will turn 18 exactly 6575 days later on January 1, 2018 (5 leap years included), but someone born on January 1, 2001, will turn 18 exactly 6574 days later on January 1, 2019 (4 leap years included). Thus, you if someone is exactly 6574 days old, you can't determine if they are 17 or 18 without knowing a little more information about their birthdate. The correct way to do this is to calculate the age directly from the dates, by subtracting the two years, and then subtracting one if the current month/day precedes the birth month/day.",0.9912596409131113,False,4,142 2009-04-19 19:51:07.787,Amazon S3 permissions,"Trying to understand S3...How do you limit access to a file you upload to S3? For example, from a web application, each user has files they can upload, but how do you limit access so only that user has access to that file? It seems like the query string authentication requires an expiration date and that won't work for me, is there another way to do this?",You will have to build the whole access logic to S3 in your applications,0.1016881243684853,False,3,143 @@ -1931,11 +1931,11 @@ Just read the headers of the request, and take action based on the value of the 2009-04-23 19:08:27.440,How to connect to a WCF Service with IronPython,"Has anyone done this? I've tried generating a c# proxy class and connecting through it, but I cannot figure out how to get IronPython to use the generated app.config file that defines the endpoint. It tries to connect, but I just get an error about no default endpoint. I would ideally like to make the connection using only IronPython code and not use the proxy class, if possible. The binding for the service I am trying to connect to is a NetTcpBinding if that makes any difference.","Is your WCF service interface available in a shared assembly? If so, you could look at using the ChannelFactory to create your client proxy dynamically (instead of using the generated C# proxy). With that method you can supply all the details of the endpoint when you create the ChannelFactory and you won't require any configuration in your .config file.",0.0,False,1,147 2009-04-24 14:45:27.703,How to design an email system?,"I am working for a company that provides customer support to its clients. I am trying to design a system that would send emails automatically to clients when some event occurs. The system would consist of a backend part and a web interface part. The backend will handle the communication with a web interface (which will be only for internal use to change the email templates) and most important it will check some database tables and based on those results will send emails ... lots of them. Now, I am wondering how can this be designed so it can be made scalable and provide the necessary performance as it will probably have to handle a few thousands emails per hours (this should be the peek). I am mostly interested about how would this kind of architecture should be thought in order to be easily scaled in the future if needed. -Python will be used on the backend with Postgres and probably whatever comes first between a Python web framework and GWT on the frontend (which seems the simplest task).",You might want to try Twisted Mail for implementing your own backend in pure Python.,0.0,False,2,148 -2009-04-24 14:45:27.703,How to design an email system?,"I am working for a company that provides customer support to its clients. I am trying to design a system that would send emails automatically to clients when some event occurs. The system would consist of a backend part and a web interface part. The backend will handle the communication with a web interface (which will be only for internal use to change the email templates) and most important it will check some database tables and based on those results will send emails ... lots of them. -Now, I am wondering how can this be designed so it can be made scalable and provide the necessary performance as it will probably have to handle a few thousands emails per hours (this should be the peek). I am mostly interested about how would this kind of architecture should be thought in order to be easily scaled in the future if needed. Python will be used on the backend with Postgres and probably whatever comes first between a Python web framework and GWT on the frontend (which seems the simplest task).","A few thousand emails per hour isn't really that much, as long as your outgoing mail server is willing to accept them in a timely manner. I would send them using a local mta, like postfix, or exim (which would then send them through your outgoing relay if required). That service is then responsible for the mail queues, retries, bounces, etc. If your looking for more ""mailing list"" features, try adding mailman into the mix. It's written in python, and you've probably seen it, as it runs tons of internet mailing lists.",0.296905446847765,False,2,148 +2009-04-24 14:45:27.703,How to design an email system?,"I am working for a company that provides customer support to its clients. I am trying to design a system that would send emails automatically to clients when some event occurs. The system would consist of a backend part and a web interface part. The backend will handle the communication with a web interface (which will be only for internal use to change the email templates) and most important it will check some database tables and based on those results will send emails ... lots of them. +Now, I am wondering how can this be designed so it can be made scalable and provide the necessary performance as it will probably have to handle a few thousands emails per hours (this should be the peek). I am mostly interested about how would this kind of architecture should be thought in order to be easily scaled in the future if needed. +Python will be used on the backend with Postgres and probably whatever comes first between a Python web framework and GWT on the frontend (which seems the simplest task).",You might want to try Twisted Mail for implementing your own backend in pure Python.,0.0,False,2,148 2009-04-24 14:46:45.890,Basic MVT issue in Django,"I have a Django website as follows: site has several views @@ -2014,11 +2014,11 @@ I wonder which approach is the most advantageous from the architectural point of It would be great if you could point out snippets in Python.","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. Note 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. In 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.",0.2401167094949473,False,2,154 +2009-04-30 05:03:05.993,What is the best way to access stored procedures in Django's ORM,"I am designing a fairly complex database, and know that some of my queries will be far outside the scope of Django's ORM. Has anyone integrated SP's with Django's ORM successfully? If so, what RDBMS and how did you do it?",I guess the improved raw sql queryset support in Django 1.2 can make this easier as you wouldn't have to roll your own make_instance type code.,0.0,False,2,155 2009-04-30 05:03:05.993,What is the best way to access stored procedures in Django's ORM,"I am designing a fairly complex database, and know that some of my queries will be far outside the scope of Django's ORM. Has anyone integrated SP's with Django's ORM successfully? If so, what RDBMS and how did you do it?","Don't. Seriously. Move the stored procedure logic into your model where it belongs. Putting some code in Django and some code in the database is a maintenance nightmare. I've spent too many of my 30+ years in IT trying to clean up this kind of mess.",0.336246259354525,False,2,155 -2009-04-30 05:03:05.993,What is the best way to access stored procedures in Django's ORM,"I am designing a fairly complex database, and know that some of my queries will be far outside the scope of Django's ORM. Has anyone integrated SP's with Django's ORM successfully? If so, what RDBMS and how did you do it?",I guess the improved raw sql queryset support in Django 1.2 can make this easier as you wouldn't have to roll your own make_instance type code.,0.0,False,2,155 2009-05-01 03:24:53.257,Biggest python projects,"What is the biggest software development team that uses Python? I am wondering how well the dynamic type system scales to large development teams. It's pretty clear that at Google they have C++ and Java codebases with thousands of developers; their use of Python is much smaller. Are there some huge companies that develop primarily in Python?","Python is very powerful language, Many big and the very high ranked websites are built on python.. @@ -2039,17 +2039,17 @@ Even Many companies are shifting their websites from PHP to Python, Because of i Moreover, 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.",0.296905446847765,False,3,156 2009-05-01 03:24:53.257,Biggest python projects,"What is the biggest software development team that uses Python? I am wondering how well the dynamic type system scales to large development teams. It's pretty clear that at Google they have C++ and Java codebases with thousands of developers; their use of Python is much smaller. -Are there some huge companies that develop primarily in Python?","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. -Among 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. -Among 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).",0.9950547536867304,False,3,156 -2009-05-01 03:24:53.257,Biggest python projects,"What is the biggest software development team that uses Python? I am wondering how well the dynamic type system scales to large development teams. -It's pretty clear that at Google they have C++ and Java codebases with thousands of developers; their use of Python is much smaller. Are there some huge companies that develop primarily in Python?","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. A ""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. When 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. Even 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. (I don't know what a dynamic type system is -- Python types are static -- when you create an object, its type can never change.) Since 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.",0.6730655149877884,False,3,156 +2009-05-01 03:24:53.257,Biggest python projects,"What is the biggest software development team that uses Python? I am wondering how well the dynamic type system scales to large development teams. +It's pretty clear that at Google they have C++ and Java codebases with thousands of developers; their use of Python is much smaller. +Are there some huge companies that develop primarily in Python?","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. +Among 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. +Among 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).",0.9950547536867304,False,3,156 2009-05-04 08:59:20.273,How can I check if an ip is in a network in Python?,"Given an ip address (say 192.168.0.1), how do I check if it's in a network (say 192.168.0.0/24) in Python? Are there general tools in Python for ip address manipulation? Stuff like host lookups, ip adddress to int, network address with netmask to int and so on? Hopefully in the standard Python library for 2.5.","#This works properly without the weird byte by byte handling def addressInNetwork(ip,net): @@ -2125,6 +2125,11 @@ edit 2: and finally, how do I define two parents for an entity if the entity is 2009-05-08 18:23:39.907,Tokenizing left over data with lex/yacc,"Forgive me, I'm completely new to parsing and lex/yacc, and I'm probably in way over my head, but nonetheless: I'm writing a pretty basic calculator with PLY, but it's input might not always be an equation, and I need to determine if it is or not when parsing. The extremes of the input would be something that evaluates perfectly to an equation, which it parses fine and calculates, or something that is nothing like an equation, which fails parsing and is also fine. The gray area is an input that has equation-like parts, of which the parser will grab and work out. This isn't what I want - I need to be able to tell if parts of the string didn't get picked up and tokenized so I can throw back an error, but I have no idea how to do this. +Does anyone know how I can define, basically, a 'catch anything that's left' token? Or is there a better way I can handle this?","I typically use a separate 'command reader' to obtain a complete command - probably a line in your case - into a host variable string, and then arrange for the lexical analyzer to analyze the string, including telling me when it didn't reach the end. This is hard to set up, but make some classes of error reporting easier. One of the places I've used this technique routinely has multi-line commands with 3 comment conventions, two sets of quoted strings, and some other nasties to set my teeth on edge (context sensitive tokenization - yuck!). +Otherwise, Don's advice with the Yacc 'error' token is good.",0.0,False,2,165 +2009-05-08 18:23:39.907,Tokenizing left over data with lex/yacc,"Forgive me, I'm completely new to parsing and lex/yacc, and I'm probably in way over my head, but nonetheless: +I'm writing a pretty basic calculator with PLY, but it's input might not always be an equation, and I need to determine if it is or not when parsing. The extremes of the input would be something that evaluates perfectly to an equation, which it parses fine and calculates, or something that is nothing like an equation, which fails parsing and is also fine. +The gray area is an input that has equation-like parts, of which the parser will grab and work out. This isn't what I want - I need to be able to tell if parts of the string didn't get picked up and tokenized so I can throw back an error, but I have no idea how to do this. Does anyone know how I can define, basically, a 'catch anything that's left' token? Or is there a better way I can handle this?","There is a built-in error token in yacc. You would normally do something like: line: goodline | badline ; @@ -2133,11 +2138,6 @@ goodline : equation '\n' ; Any line that doesn't match equation will be handled by badline. You might want to use yyerrok in the error handling action to ensure error processing is reset for the next line.",1.2,True,2,165 -2009-05-08 18:23:39.907,Tokenizing left over data with lex/yacc,"Forgive me, I'm completely new to parsing and lex/yacc, and I'm probably in way over my head, but nonetheless: -I'm writing a pretty basic calculator with PLY, but it's input might not always be an equation, and I need to determine if it is or not when parsing. The extremes of the input would be something that evaluates perfectly to an equation, which it parses fine and calculates, or something that is nothing like an equation, which fails parsing and is also fine. -The gray area is an input that has equation-like parts, of which the parser will grab and work out. This isn't what I want - I need to be able to tell if parts of the string didn't get picked up and tokenized so I can throw back an error, but I have no idea how to do this. -Does anyone know how I can define, basically, a 'catch anything that's left' token? Or is there a better way I can handle this?","I typically use a separate 'command reader' to obtain a complete command - probably a line in your case - into a host variable string, and then arrange for the lexical analyzer to analyze the string, including telling me when it didn't reach the end. This is hard to set up, but make some classes of error reporting easier. One of the places I've used this technique routinely has multi-line commands with 3 comment conventions, two sets of quoted strings, and some other nasties to set my teeth on edge (context sensitive tokenization - yuck!). -Otherwise, Don's advice with the Yacc 'error' token is good.",0.0,False,2,165 2009-05-08 22:41:21.693,Piping Batch File output to a Python script,I'm trying to write a python script (in windows) that runs a batch file and will take the command line output of that batch file as input. The batch file runs processes that I don't have access to and gives output based on whether those processes are successful. I'd like to take those messages from the batch file and use them in the python script. Anyone have any ideas on how to do this ?,Try subprocess.Popen(). It allows you to redirect stdout and stderr to files.,0.1352210990936997,False,1,166 2009-05-11 12:24:35.110,How to write a vb.net code to compile C/C++ programs?,"I'm trying to make a vb.net application that has got 2 textboxes, 7 radio buttons and 2 buttons(one named compile and the other 'run'). How can I load the content of a C/C++(or any programming language) file into the 1st textbox and on clicking the compile button, i should be able to show the errors or the C/C++ program in the 2nd textbox. On clicking Run, I should be able to show the output in the 2nd textbox. In short, I want to use the 2nd textbox as a terminal/console. The radio buttons are 4 selecting the language C or C++ or python or C# or java or perl or vb. Are the compilers of all these languages present in .net? If so how can I call them?",Compiling can be done by calling cl.exe which comes with Visual Studio. Of course you could also use GCC instead.,0.2012947653214861,False,1,167 @@ -2203,12 +2203,12 @@ In other words, does the size of the table have an effect on how long the RENAME 2009-05-25 12:16:07.597,show lyrics on ubuntu,"I'm writing a little script for Ubuntu. My intention is to call rhythmbox lyrics plug-in with a global short-cut (configuring gnome) . I can call it from rhythmbox python console, but I don't know how to import rhythmbox built-in modules (eg. rhythmdb). -Any ideas?","in this case i guess you'll have to write the whole plugin yourself and , then listen to dbus for change of songs in rhythmbox , to detect which song is being played .",0.0,False,2,177 +Any ideas?","You can't import rhythmbox ""built-in"" modules from a standard python console. +As far as I know they aren't real modules, they are just objects from the rhythmbox process exposed to plugins. So you can access them only if you are running your script from the rhythmbox process.",0.3869120172231254,False,2,177 2009-05-25 12:16:07.597,show lyrics on ubuntu,"I'm writing a little script for Ubuntu. My intention is to call rhythmbox lyrics plug-in with a global short-cut (configuring gnome) . I can call it from rhythmbox python console, but I don't know how to import rhythmbox built-in modules (eg. rhythmdb). -Any ideas?","You can't import rhythmbox ""built-in"" modules from a standard python console. -As far as I know they aren't real modules, they are just objects from the rhythmbox process exposed to plugins. So you can access them only if you are running your script from the rhythmbox process.",0.3869120172231254,False,2,177 +Any ideas?","in this case i guess you'll have to write the whole plugin yourself and , then listen to dbus for change of songs in rhythmbox , to detect which song is being played .",0.0,False,2,177 2009-05-25 18:05:23.203,Making a Python script executable chmod755?,"My hosting provider says my python script must be made to be executable(chmod755). What does this mean & how do I do it? Cheers!","In addition to the other fine answers here, you should be aware that most FTP clients have a chmod command to allow you to set permissions on files at the server. You may not need this if permissions come across properly, but there's a good chance they do not.",0.0,False,1,178 2009-05-28 14:55:26.907,How to compare data of two tables transformed in SSIS package,"A table has been ETLed to another table. My task is to verify the data between two tables programmatically. @@ -2241,16 +2241,16 @@ Some palindromic substring. Some letter, x, repeated without regard to case. Some trailing punctuation. And, by definition, a zero-length string is a palindrome. Also a single-letter string (after removing punctuation) is a palindrome.",0.0740755660660223,False,2,182 -2009-06-06 20:33:32.037,how can I add a QMenu and QMenuItems to a window from Qt Designer,Is there any reason why a QMenu cannot be added from the Qt Designer? I find it weird that you can add other widget types but not this.,"Adding menu editing for every widget in the designer would probably make a very awkward and inconvenient UI. There's really no place you can visualize it on. -If you're editing a QMainWindow you can edit the menu bar and its popups because there's a proper place for them to be displayed in.",0.0,False,3,183 -2009-06-06 20:33:32.037,how can I add a QMenu and QMenuItems to a window from Qt Designer,Is there any reason why a QMenu cannot be added from the Qt Designer? I find it weird that you can add other widget types but not this.,"When you edit a QMainWindow you can right click the window and then choose ""create menu bar"". -Or are you talking about a ""context menu"" aka ""right click menu""?",1.2,True,3,183 2009-06-06 20:33:32.037,how can I add a QMenu and QMenuItems to a window from Qt Designer,Is there any reason why a QMenu cannot be added from the Qt Designer? I find it weird that you can add other widget types but not this.,"I have a single main window with a QGraphicsView and lots of QGraphicsItem objects. Each type of the Items have a different context menu. I find that not being able to create the contextMenu's, or at least the actions that are in them a serious limitation of QtDesigner. It means that I can create about 10% or so of the actions using the designer, and I have to create 90% programaticaly. Compare that with the Microsoft resource editor which allows all of these things to be created, and maintained effortlessly. I hope this will be addressed at some point.",0.3869120172231254,False,3,183 -2009-06-08 11:30:28.043,how to remove text between using python?,how to remove text between using python?,"I don't know Python good enough to tell you a solution. But if you want to use that to sanitize the user input you have to be very, very careful. Removing stuff between and just doesn't catch everything. Maybe you can have a look at existing solutions (I assume Django includes something like this).",-0.0453204071731508,False,2,184 +2009-06-06 20:33:32.037,how can I add a QMenu and QMenuItems to a window from Qt Designer,Is there any reason why a QMenu cannot be added from the Qt Designer? I find it weird that you can add other widget types but not this.,"When you edit a QMainWindow you can right click the window and then choose ""create menu bar"". +Or are you talking about a ""context menu"" aka ""right click menu""?",1.2,True,3,183 +2009-06-06 20:33:32.037,how can I add a QMenu and QMenuItems to a window from Qt Designer,Is there any reason why a QMenu cannot be added from the Qt Designer? I find it weird that you can add other widget types but not this.,"Adding menu editing for every widget in the designer would probably make a very awkward and inconvenient UI. There's really no place you can visualize it on. +If you're editing a QMainWindow you can edit the menu bar and its popups because there's a proper place for them to be displayed in.",0.0,False,3,183 2009-06-08 11:30:28.043,how to remove text between using python?,how to remove text between using python?,"If you're removing everything between why not just remove the entire node? Are you expecting a resig-style src and body?",0.0,False,2,184 +2009-06-08 11:30:28.043,how to remove text between using python?,how to remove text between using python?,"I don't know Python good enough to tell you a solution. But if you want to use that to sanitize the user input you have to be very, very careful. Removing stuff between and just doesn't catch everything. Maybe you can have a look at existing solutions (I assume Django includes something like this).",-0.0453204071731508,False,2,184 2009-06-09 00:29:59.137,python truncate after a hundreds?,"How can truncate an input like 315.15321531321 I want to truncate all the values after the hundredths position so it becomes 315.15 how do i do that?","You have several options - you can round the number using round(), however this can introduce some inaccuracies (315.15 might round to 315.150000003 for example). If you're just looking to truncate the value of the float when you're displaying it, you can specify the width of the output using printf(""%.2f"", mynumber). This is probably a better solution, since without knowing more about your specific application it's a good idea in general to keep the entire length of the number for calculation.",0.0509761841073563,False,1,185 @@ -2274,13 +2274,23 @@ stat = you see, the problem is that that ""!"" call uses os.system to run it, which defaults to manky old /bin/sh . Like I said, it worked for me, although I'm not sure what got borked behind the scenes.",1.2,True,1,187 -2009-06-10 10:42:38.667,python not starting properly,I have installed python and django in my system that uses win vista. Now when I go to command prompt and type python or django-admin.py both are not working. Every time I need to set the path to the python folder manually. But i have seen these commands running even without setting path. So how do i make it to run properly?,"you can't run a command that isn't in your path. it should be set globally when you installed python. -type 'set' at a dos prompt and look at the PATH variable. c:\python25 (or whever you installed python) has to be in that variable ie PATH=c:\windows;c:\python25;... etc -if it isn't in PATH then you or the installer missed the part where you needed to set it. It can be done from the 'Environment Variables' button in the 'System' control panel.",0.1016881243684853,False,3,188 +2009-06-10 10:42:38.667,python not starting properly,I have installed python and django in my system that uses win vista. Now when I go to command prompt and type python or django-admin.py both are not working. Every time I need to set the path to the python folder manually. But i have seen these commands running even without setting path. So how do i make it to run properly?,"In your path, I think you need to have both the location of the Python install and the Python\Scripts folder. For example, on XP, I have C:\Python25;C:\Python25\Scripts. Can you verify that you have both?",0.0,False,3,188 2009-06-10 10:42:38.667,python not starting properly,I have installed python and django in my system that uses win vista. Now when I go to command prompt and type python or django-admin.py both are not working. Every time I need to set the path to the python folder manually. But i have seen these commands running even without setting path. So how do i make it to run properly?,"Either use the system control panel to set the PATH environment variable that applies permanently or Reinstall Python as a system administrator so that the installer can set the registry and environment variables for you. If you install the ""just for me"" option, then you have to set the PATH variable in the control panel.",1.2,True,3,188 -2009-06-10 10:42:38.667,python not starting properly,I have installed python and django in my system that uses win vista. Now when I go to command prompt and type python or django-admin.py both are not working. Every time I need to set the path to the python folder manually. But i have seen these commands running even without setting path. So how do i make it to run properly?,"In your path, I think you need to have both the location of the Python install and the Python\Scripts folder. For example, on XP, I have C:\Python25;C:\Python25\Scripts. Can you verify that you have both?",0.0,False,3,188 +2009-06-10 10:42:38.667,python not starting properly,I have installed python and django in my system that uses win vista. Now when I go to command prompt and type python or django-admin.py both are not working. Every time I need to set the path to the python folder manually. But i have seen these commands running even without setting path. So how do i make it to run properly?,"you can't run a command that isn't in your path. it should be set globally when you installed python. +type 'set' at a dos prompt and look at the PATH variable. c:\python25 (or whever you installed python) has to be in that variable ie PATH=c:\windows;c:\python25;... etc +if it isn't in PATH then you or the installer missed the part where you needed to set it. It can be done from the 'Environment Variables' button in the 'System' control panel.",0.1016881243684853,False,3,188 +2009-06-10 23:35:16.360,"Vim, Python, and Django autocompletion (pysmell?)","Does anyone know how to set up auto completion to work nicely with python, django, and vim? +I've been trying to use pysmell, but I can't seem to get it set up correctly (or maybe I don't know how it works). Right now, I run pysmell in the django directory (I'm using the trunk) and move the resulting tags to my project directory, then I also run pysmell in the project directory. Vim doesn't pick up the django tags, though, and they don't get auto completed. +Does anyone know how to set up auto completion in vim so that it will complete the long django functions (like get_object_or_404) as well as classes/functions in my own code? I have poked around on google but haven't found any good resources. +Thanks.","I've had good luck with exuberant-ctags for this. +I use this macro in my vimrc: + +execute 'map :!/usr/bin/exuberant-ctags -f '.&tags.' --recurse '.$_P4ROOT.' ' + +You'll want to modify that slightly, so that it includes your python /site-packages/django/ directory as well as your own code. +Then, hit F2 inside vim to update the tags, and use the regular vim tag bindings to navigate.",0.2401167094949473,False,2,189 2009-06-10 23:35:16.360,"Vim, Python, and Django autocompletion (pysmell?)","Does anyone know how to set up auto completion to work nicely with python, django, and vim? I've been trying to use pysmell, but I can't seem to get it set up correctly (or maybe I don't know how it works). Right now, I run pysmell in the django directory (I'm using the trunk) and move the resulting tags to my project directory, then I also run pysmell in the project directory. Vim doesn't pick up the django tags, though, and they don't get auto completed. Does anyone know how to set up auto completion in vim so that it will complete the long django functions (like get_object_or_404) as well as classes/functions in my own code? I have poked around on google but haven't found any good resources. @@ -2304,16 +2314,6 @@ sys.path.append is path to your django workspace directory djangoProject is name of your django project, which is going just after '/home/sergey/workspace/django' Finally, save it and restart vim. Now, after '.', you press default ctrl-x ctrl-o to get your autocomplete.",0.1618299653758019,False,2,189 -2009-06-10 23:35:16.360,"Vim, Python, and Django autocompletion (pysmell?)","Does anyone know how to set up auto completion to work nicely with python, django, and vim? -I've been trying to use pysmell, but I can't seem to get it set up correctly (or maybe I don't know how it works). Right now, I run pysmell in the django directory (I'm using the trunk) and move the resulting tags to my project directory, then I also run pysmell in the project directory. Vim doesn't pick up the django tags, though, and they don't get auto completed. -Does anyone know how to set up auto completion in vim so that it will complete the long django functions (like get_object_or_404) as well as classes/functions in my own code? I have poked around on google but haven't found any good resources. -Thanks.","I've had good luck with exuberant-ctags for this. -I use this macro in my vimrc: - -execute 'map :!/usr/bin/exuberant-ctags -f '.&tags.' --recurse '.$_P4ROOT.' ' - -You'll want to modify that slightly, so that it includes your python /site-packages/django/ directory as well as your own code. -Then, hit F2 inside vim to update the tags, and use the regular vim tag bindings to navigate.",0.2401167094949473,False,2,189 2009-06-12 05:28:54.720,How to specify native library search path for python,"I have installed lxml which was built using a standalone version of libxml2. Reason for this was that the lxml needed a later version of libxml2 than what was currently installed. When I use the lxml module how do I tell it (python) where to find the correct version of the libxml2 shared library?","Assuming you're talking about a .so file, it's not up to Python to find it -- it's up to the operating system's dynamic library loaded. For Linux, for example, LD_LIBRARY_PATH is the environment variable you need to set.",1.2,True,1,190 2009-06-15 09:15:37.030,Using python regex to extract namespaces from C++ sources,"I am trying to extract the namespaces defined in C++ files. @@ -2329,16 +2329,17 @@ namespace n1 { I want to be able to retrieve: n1, n1::n2, n1::n3. Does someone have any suggestion of how I could do that using python-regex? -Thanks.","That is what I did earlier today: +Thanks.","The need is simple enough that you may not need a complex parser. You need to: -Extract the comment out of the C++ files -Use regex to extract the namespace definition -Use a simple string search to get the open & close braces positions +extract the namespace names +count the open/close braces to keep track of where your namespace is defined. -The various sanity check added show that I am successfully processing 99.925% of my files (5 failures ouf of 6678 files). The issues are due to mismatches in numbers of { and } cause by few '{' or '}' in strings, and unclean usage of the preprocessor instruction. -However, I am only dealing with header files, and I own the code. That limits the number of scenari that could cause some issues and I can manually modify the ones I don't cover. -Of course I know there are plenty of cases where it would fail but it is probably enough for what I want to achieve. -Thanks for your answers.",0.0,False,5,191 +This simple approach works if the other conditions are met: + +you don't get spurious namespace like strings inside comments or inside strings +you don't get unmatched open/closeing braces inside comments or strings + +I don't think this is too much asking from your source.",0.1352210990936997,False,5,191 2009-06-15 09:15:37.030,Using python regex to extract namespaces from C++ sources,"I am trying to extract the namespaces defined in C++ files. Basically, if my C++ file contains: @@ -2352,17 +2353,8 @@ namespace n1 { I want to be able to retrieve: n1, n1::n2, n1::n3. Does someone have any suggestion of how I could do that using python-regex? -Thanks.","The need is simple enough that you may not need a complex parser. You need to: - -extract the namespace names -count the open/close braces to keep track of where your namespace is defined. - -This simple approach works if the other conditions are met: - -you don't get spurious namespace like strings inside comments or inside strings -you don't get unmatched open/closeing braces inside comments or strings - -I don't think this is too much asking from your source.",0.1352210990936997,False,5,191 +Thanks.","Searching for the namespace names is pretty easy with a regular expression. However, to determine the nesting level you will have to keep track of the curly bracket nesting level in the source file. This is a parsing problem, one that cannot be solved (sanely) with regular expressions. Also, you may have to deal with any C preprocessor directives in the file which can definitely affect parsing. +C++ is a notoriously tricky language to parse completely, but you may be able to get by with a tokeniser and a curly bracket counter.",0.3869120172231254,False,5,191 2009-06-15 09:15:37.030,Using python regex to extract namespaces from C++ sources,"I am trying to extract the namespaces defined in C++ files. Basically, if my C++ file contains: @@ -2376,8 +2368,7 @@ namespace n1 { I want to be able to retrieve: n1, n1::n2, n1::n3. Does someone have any suggestion of how I could do that using python-regex? -Thanks.","Most of the time when someone asks how to do something with regex, they're doing something very wrong. I don't think this case is different. -If you want to parse c++, you need to use a c++ parser. There are many things that can be done that will defeat a regex but still be valid c++.",0.0,False,5,191 +Thanks.",You could write a basic lexer for it. It's not that hard.,0.0679224682270276,False,5,191 2009-06-15 09:15:37.030,Using python regex to extract namespaces from C++ sources,"I am trying to extract the namespaces defined in C++ files. Basically, if my C++ file contains: @@ -2391,8 +2382,8 @@ namespace n1 { I want to be able to retrieve: n1, n1::n2, n1::n3. Does someone have any suggestion of how I could do that using python-regex? -Thanks.","Searching for the namespace names is pretty easy with a regular expression. However, to determine the nesting level you will have to keep track of the curly bracket nesting level in the source file. This is a parsing problem, one that cannot be solved (sanely) with regular expressions. Also, you may have to deal with any C preprocessor directives in the file which can definitely affect parsing. -C++ is a notoriously tricky language to parse completely, but you may be able to get by with a tokeniser and a curly bracket counter.",0.3869120172231254,False,5,191 +Thanks.","Most of the time when someone asks how to do something with regex, they're doing something very wrong. I don't think this case is different. +If you want to parse c++, you need to use a c++ parser. There are many things that can be done that will defeat a regex but still be valid c++.",0.0,False,5,191 2009-06-15 09:15:37.030,Using python regex to extract namespaces from C++ sources,"I am trying to extract the namespaces defined in C++ files. Basically, if my C++ file contains: @@ -2406,7 +2397,16 @@ namespace n1 { I want to be able to retrieve: n1, n1::n2, n1::n3. Does someone have any suggestion of how I could do that using python-regex? -Thanks.",You could write a basic lexer for it. It's not that hard.,0.0679224682270276,False,5,191 +Thanks.","That is what I did earlier today: + +Extract the comment out of the C++ files +Use regex to extract the namespace definition +Use a simple string search to get the open & close braces positions + +The various sanity check added show that I am successfully processing 99.925% of my files (5 failures ouf of 6678 files). The issues are due to mismatches in numbers of { and } cause by few '{' or '}' in strings, and unclean usage of the preprocessor instruction. +However, I am only dealing with header files, and I own the code. That limits the number of scenari that could cause some issues and I can manually modify the ones I don't cover. +Of course I know there are plenty of cases where it would fail but it is probably enough for what I want to achieve. +Thanks for your answers.",0.0,False,5,191 2009-06-15 19:25:28.390,System theme icons and PyQt4,"I'm writing a basic program in python using the PyQt4 module. I'd like to be able to use my system theme's icons for things like the preference dialog's icon, but i have no idea how to do this. So my question is, how do you get the location of an icon, but make sure it changes with the system's icon theme? If it matters, i'm developing this under ubuntu 9.04, so i am using the gnome desktop.","I spent a decent amount of researching this myself not long ago, and my conclusion was that, unfortunately, Qt doesn't provide this functionality in a cross-platform fashion. Ideally the QIcon class would have defaults for file open, save, '+', '-', preferences, etc, but considering it doesn't you'll have to grab the appropriate icon for your desktop environment.",0.0,False,1,192 2009-06-16 14:09:44.313,How To Reversibly Store Password With Python On Linux?,"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. I 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. @@ -2439,8 +2439,7 @@ My question is, how should one approach these different languages? Should I simp So 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. The 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? What 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? -FWIW, the web app will be written in Python.","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. -This way you might stave off your level of hackage for a while.",-0.0679224682270276,False,3,197 +FWIW, the web app will be written in Python.",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.,0.0,False,3,197 2009-06-19 19:35:07.567,Sandboxing in Linux,"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. So 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. The 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? @@ -2450,7 +2449,8 @@ FWIW, the web app will be written in Python.","I think your solutions must conce So 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. The 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? What 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? -FWIW, the web app will be written in Python.",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.,0.0,False,3,197 +FWIW, the web app will be written in Python.","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. +This way you might stave off your level of hackage for a while.",-0.0679224682270276,False,3,197 2009-06-21 23:31:10.947,What's the best way to implement web service for ajax autocomplete,"I'm implementing a ""Google Suggest"" like autocomplete feature for tag searching using jQuery's autocomplete. I need to provide a web service to jQuery giving it a list of suggestions based on what the user has typed. I see 2 ways of implementing the web service: 1) just store all the tags in a database and search the DB using user input as prefix. This is simple, but I'm concerned about latency. @@ -2469,14 +2469,6 @@ I was doing import clr clr.AddReference('Ritmo for iSeries') from Ritmo........ -IOError: Could not add reference to assembly Ritmo for iSeries","You need to use the actual name of the assembly (it won't have spaces). -In your C# project, what does it list under the 'references' folder once you've added it as a reference? Try putting that. Also, make sure you've copied the dll for the library to where your IronPython script can find it (if it's not in the GAC).",0.0,False,2,199 -2009-06-23 14:24:51.560,how to addreference to Ritmo for iSeries in ironpython,"I was just wondering if anybody knows how to add reference to ""Ritmo for iSeries"" in IronPython. -I did it successfully in C# and get it to work (since it is just click click click) And I was trying to do the same in IronPython but it says, ""could not add reference to assembly Ritmo for iSeries"". -I was doing -import clr -clr.AddReference('Ritmo for iSeries') -from Ritmo........ IOError: Could not add reference to assembly Ritmo for iSeries","Jonathan helped me to figure out that I had not copied the dll file to the location where IronPython can find it. After copying the dll file to the location, usually it s ""c:\Program Files\IronPython 2.0\"" unless stated otherwise, I did: @@ -2485,6 +2477,14 @@ clr.AddReference('System.Data') clr.AddReferenceToFile('Sql400.dll') from System.Data import Sql400 from System.Data.Sql400 import *",0.0,False,2,199 +2009-06-23 14:24:51.560,how to addreference to Ritmo for iSeries in ironpython,"I was just wondering if anybody knows how to add reference to ""Ritmo for iSeries"" in IronPython. +I did it successfully in C# and get it to work (since it is just click click click) And I was trying to do the same in IronPython but it says, ""could not add reference to assembly Ritmo for iSeries"". +I was doing +import clr +clr.AddReference('Ritmo for iSeries') +from Ritmo........ +IOError: Could not add reference to assembly Ritmo for iSeries","You need to use the actual name of the assembly (it won't have spaces). +In your C# project, what does it list under the 'references' folder once you've added it as a reference? Try putting that. Also, make sure you've copied the dll for the library to where your IronPython script can find it (if it's not in the GAC).",0.0,False,2,199 2009-06-24 12:54:21.517,HTML conversion,"How to convert HTML CSS file to wxPython files? That is, how to create slidsheet in wxPython like HTML CSS files?","stylesheet, not slidesheet. f = open('NAMEOFSTYLESHEET.css','w') f.write('#ID{}\n.class{}')",0.0,False,1,200 @@ -2506,9 +2506,10 @@ The app on my master is a TurboGears app, so I would prefer ""pythonic"" aka le Can anyone describe shortly how you would do this the ""best-practise"" way? This doesn't necessarily have to involve Databases. Dumping the table on Server1 and transferring the raw data in a structured way so server2 can process it without parsing too much is just as good. One requirement though: As soon as the data arrives on server2, I want it to be processed, so there has to be a notification of some sort when the transfer is done. Of course I could just write my whole own server sitting on a socket on the second machine and accepting the file with own code and processing it and so forth, but this is just a very very small piece of a very big system, so I dont want to spend half a day implementing this. Thanks, -Tom","Server 1: Convert rows to JSON, call the RESTful api of second with JSON data -Server 2: listens on a URI e.g. POST /data , get json data convert back to dictionary or ORM objects, insert into db -sqlalchemy/sqlobject and simplejson is what you need.",1.2,True,2,202 +Tom","Assuming your situation allows this security-wise, you forgot one transport mechanism: simply opening a mysql connection from one server to another. +Me, I would start by thinking about one script that ran regularly on the write server and opens a read only db connection to the read server (A bit of added security) and a full connection to it's own data base server. +How you then proceed depends on the data (is it just inserts to deal with? do you have to mirror deletes? how many inserts vs updates? etc) but basically you could write a script that pulled data from the read server and processed it immediately into the write server. +Also, would mysql server replication work or would it be to over-blown as a solution?",0.0,False,2,202 2009-06-25 11:59:01.843,Best Practise for transferring a MySQL table to another server?,"I have a system sitting on a ""Master Server"", that is periodically transferring quite a few chunks of information from a MySQL DB to another server in the web. Both servers have a MySQL Server and an Apache running. I would like an easy-to-use solution for this. Currently I'm looking into: @@ -2522,10 +2523,9 @@ The app on my master is a TurboGears app, so I would prefer ""pythonic"" aka le Can anyone describe shortly how you would do this the ""best-practise"" way? This doesn't necessarily have to involve Databases. Dumping the table on Server1 and transferring the raw data in a structured way so server2 can process it without parsing too much is just as good. One requirement though: As soon as the data arrives on server2, I want it to be processed, so there has to be a notification of some sort when the transfer is done. Of course I could just write my whole own server sitting on a socket on the second machine and accepting the file with own code and processing it and so forth, but this is just a very very small piece of a very big system, so I dont want to spend half a day implementing this. Thanks, -Tom","Assuming your situation allows this security-wise, you forgot one transport mechanism: simply opening a mysql connection from one server to another. -Me, I would start by thinking about one script that ran regularly on the write server and opens a read only db connection to the read server (A bit of added security) and a full connection to it's own data base server. -How you then proceed depends on the data (is it just inserts to deal with? do you have to mirror deletes? how many inserts vs updates? etc) but basically you could write a script that pulled data from the read server and processed it immediately into the write server. -Also, would mysql server replication work or would it be to over-blown as a solution?",0.0,False,2,202 +Tom","Server 1: Convert rows to JSON, call the RESTful api of second with JSON data +Server 2: listens on a URI e.g. POST /data , get json data convert back to dictionary or ORM objects, insert into db +sqlalchemy/sqlobject and simplejson is what you need.",1.2,True,2,202 2009-06-26 10:44:01.177,Hiding characters typed into password field,"I am developing an student attendance application in wxpython and I need to know how to ensure that password field doesn't echo characters to the screen. Forexample :if I give the name as moni means then it should be displayed as in format of ****","You need to give your text control the TE_PASSWORD style. (As Jørn's comment points out, this isn't ""encryption"" - I'm assuming you're only talking about the visual presentation of the password.)",0.3869120172231254,False,1,203 @@ -2543,12 +2543,12 @@ Modules like that are nice reusable pieces of code that you don't have to write, I 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.",0.1016881243684853,False,1,204 2009-06-27 22:41:01.413,Changing python interpreter windows,"I have two python installations, 2.5 and 2.6 I want to change the default python interpreter from 2.5 to 2.6. -Anyone know how?","just FYI, since both c:\python25 and c:\python26 are on PATH, I copy C:\Python25\python.exe to C:\Python25\py25.exe, and copy C:\Python26\python.exe to C:\Python26\py26.exe -Then just type py25(or py26) get the specific version.",0.2012947653214861,False,2,205 -2009-06-27 22:41:01.413,Changing python interpreter windows,"I have two python installations, 2.5 and 2.6 -I want to change the default python interpreter from 2.5 to 2.6. Anyone know how?","PYTHONPATH is NOT what you are looking for. That is for varying where Python's ""import"" looks for packages and modules. You need to change the PATH variable in your environment so that it contains e.g. ""....;c:\python26;...."" instead of ""....;c:\python25;...."". Click on start > control panel > system > advanced > environment variables. Select ""path"". Edit it. Click on OK enough times to get out of there.",1.2,True,2,205 +2009-06-27 22:41:01.413,Changing python interpreter windows,"I have two python installations, 2.5 and 2.6 +I want to change the default python interpreter from 2.5 to 2.6. +Anyone know how?","just FYI, since both c:\python25 and c:\python26 are on PATH, I copy C:\Python25\python.exe to C:\Python25\py25.exe, and copy C:\Python26\python.exe to C:\Python26\py26.exe +Then just type py25(or py26) get the specific version.",0.2012947653214861,False,2,205 2009-06-30 13:14:59.567,how to use french letters in a django template?,"I have some french letters (é, è, à...) in a django template but when it is loaded by django, an UnicodeDecodeError exception is raised. If I don't load the template but directly use a python string. It works ok. Is there something to do to use unicode with django template?","You are probably storing the template in a non-unicode encoding, such as latin-1. I believe Django assumes that templates are in UTF-8 by default (though there is a setting to override this). @@ -2567,6 +2567,9 @@ If you make the SCons source a part of the Eclipse project, and run the whole co 2. Under the arguments tab, set the working directory to the root of your project. Now set the breakpoint either on SConstruct or SConcript and run in debug mode. That's all!! With this approach you can not only debug your product code but also the build scripts that builds your product :-) Happy Debugging!!!!",0.3869120172231254,False,5,208 +2009-07-02 16:16:07.920,How to debug SCons scripts using eclipse and pydev?,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?,"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. +import pdb; pdb.set_trace() +When 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.",0.0,False,5,208 2009-07-02 16:16:07.920,How to debug SCons scripts using eclipse and pydev?,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?,"On MAC to debug scons through pydev follow Lennart's answer but with one simply addition. Using Finder (or terminal) browse to where scons is installed. You can find this with the ""which"" command. e.g. which scons @@ -2574,9 +2577,6 @@ e.g. which scons Make a copy of the scons file and call it scons.py. Now when you create the Debug Configuration in Eclipse use scons.py as the ""Main Module"". PS: 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.",0.0679224682270276,False,5,208 -2009-07-02 16:16:07.920,How to debug SCons scripts using eclipse and pydev?,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?,"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. -import pdb; pdb.set_trace() -When 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.",0.0,False,5,208 2009-07-02 16:16:07.920,How to debug SCons scripts using eclipse and pydev?,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?,"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.",0.0,False,5,208 2009-07-03 03:24:31.120,Windows Application Programming & wxPython,"Developing a project of mine I realize I have a need for some level of persistence across sessions, for example when a user executes the application, changes some preferences and then closes the app. The next time the user executes the app, be it after a reboot or 15 minutes, I would like to be able to retain the preferences that had been changed. My question relates to this persistence. Whether programming an application using the win32 API or the MFC Framework .. or using the newer tools for higher level languages such as wxPython or wxRuby, how does one maintain the type of persistence I refer to? Is it done as a temporary file written to the disk? Is it saved into some registry setting? Is there some other layer it is stored in that I am unaware of?","I would advice to do it in two steps. @@ -2599,10 +2599,10 @@ Your help would be greatly appreciated.","Automatic partitioning is a very datab Very large datasets are usually time-based, with older data becoming read-only or read-mostly and queries usually only look at data from a time interval. If that describes your data, you should probably partition your data using the date field. There's also application level partitioning, or sharding, where you use your application to split data across different database instances. This isn't all that popular in the Oracle world due to the exorbitant pricing models. If you do want to use sharding, then look at SQLAlchemy documentation and examples for that, for how SQLAlchemy can support you in that, but be aware that application level sharding will affect how you need to build your application code.",0.3869120172231254,False,1,210 2009-07-07 22:55:08.403,Matrix from Python to MATLAB,"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? -Thanks!",You could write the matrix in Python to a CSV file and read it in MATLAB using csvread.,0.229096917477335,False,2,211 -2009-07-07 22:55:08.403,Matrix from Python to MATLAB,"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? Thanks!","I would probably use numpy.savetxt('yourfile.mat',yourarray) in Python and then yourarray = load('yourfile.mat') in MATLAB.",0.283556384140347,False,2,211 +2009-07-07 22:55:08.403,Matrix from Python to MATLAB,"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? +Thanks!",You could write the matrix in Python to a CSV file and read it in MATLAB using csvread.,0.229096917477335,False,2,211 2009-07-11 05:45:38.637,List of installed fonts OS X / C,"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?","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.",0.0814518047658113,False,1,212 2009-07-11 06:02:43.720,How to keep an App Engine/Java app running with deaf requests from a Java/Python web cron?,"App Engine allows you 30 seconds to load your application My application takes around 30 seconds - sometimes more, sometimes less. I don't know how to fix this. @@ -2621,25 +2621,21 @@ Also, if the process is your child, you can get a SIGCHLD when it dies, and you 2009-07-14 15:19:21.097,Python: Persistent shell variables in subprocess,"I'm trying to execute a series of commands using Pythons subprocess module, however I need to set shell variables with export before running them. Of course the shell doesn't seem to be persistent so when I run a command later those shell variables are lost. Is there any way to go about this? I could create a /bin/sh process, but how would I get the exit codes of the commands run under that?","subprocess.Popen takes an optional named argument env that's a dictionary to use as the subprocess's environment (what you're describing as ""shell variables""). Prepare a dict as you need it (you may start with a copy of os.environ and alter that as you need) and pass it to all the subprocess.Popen calls you perform.",1.2,True,1,215 2009-07-14 17:28:02.430,Best way to have full Python install under cygwin/XP?,"Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe. My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such. 1. Can I simply copy the contents of an XP installation into the cygwin tree? 2. Is the XP flavor of Python different from the cygwin flavor? (Same CPU, he pointed out, naively.) 3. Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done? -Disclaimer 1: I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place. Disclaimer 2: sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.","I use Python from within cygwin, but I don't use the version that cygwin gives you the option of installing as I don't have the control over version number used that I need (we use an older version at work). I have my python version installed via the windows installer (the xp version as you put it) and add the /cygdrive/c/Python2x directory to my PATH environment variable.",1.2,True,4,216 -2009-07-14 17:28:02.430,Best way to have full Python install under cygwin/XP?,"Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe. My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such. 1. Can I simply copy the contents of an XP installation into the cygwin tree? 2. Is the XP flavor of Python different from the cygwin flavor? (Same CPU, he pointed out, naively.) 3. Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done? -Disclaimer 1: I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place. Disclaimer 2: sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.","This probably has little value, but... I found myself in this exact situation -- we use ActivePython2.5 in production (pure windows environment) and I was trying to do my development within cygwin and cygwin's Python... -After ripping out half of my hair, I have now switched over to Console2, gvim, iPython and ActivePython2.5. -I'm less than thrilled dealing with Windows tools (and their concomitant warts), but at least I'm not getting in my own way when it comes to development. For a while I found I was spending more time trying to get my tools to play nice than actually getting any work done. -Good luck on this one.",0.0,False,4,216 -2009-07-14 17:28:02.430,Best way to have full Python install under cygwin/XP?,"Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe. My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such. 1. Can I simply copy the contents of an XP installation into the cygwin tree? 2. Is the XP flavor of Python different from the cygwin flavor? (Same CPU, he pointed out, naively.) 3. Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done? Disclaimer 1: I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place. Disclaimer 2: sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.","Just a little off the question, but... Have you considered running Sun's VirtualBox with Fedora or Ubuntu inside of it? I'm assuming you have to / need to use windows because you still are, but don't like it. Then you would have python running inside a native linux desktop without any of the troubles you mentioned. And if you want something that is really easy and portable, then just use Python on Windows, not mixed in with cygwin. $0.02",0.0,False,4,216 2009-07-14 17:28:02.430,Best way to have full Python install under cygwin/XP?,"Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe. My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such. 1. Can I simply copy the contents of an XP installation into the cygwin tree? 2. Is the XP flavor of Python different from the cygwin flavor? (Same CPU, he pointed out, naively.) 3. Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done? +Disclaimer 1: I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place. Disclaimer 2: sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.","I use Python from within cygwin, but I don't use the version that cygwin gives you the option of installing as I don't have the control over version number used that I need (we use an older version at work). I have my python version installed via the windows installer (the xp version as you put it) and add the /cygdrive/c/Python2x directory to my PATH environment variable.",1.2,True,4,216 +2009-07-14 17:28:02.430,Best way to have full Python install under cygwin/XP?,"Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe. My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such. 1. Can I simply copy the contents of an XP installation into the cygwin tree? 2. Is the XP flavor of Python different from the cygwin flavor? (Same CPU, he pointed out, naively.) 3. Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done? Disclaimer 1: I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place. Disclaimer 2: sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.","I accidentally stumbled on this - If I launch Cygwin from the Cygwin.bat file (which is present directly under the main folder), I get access to the Python version installed under Cygwin (i.e 2.6.8) If I instead launch the Cygwin from bash.exe under bin directory (C:\Cygwin\bin\bash.exe for me), running ""Python -V"" shows that I have access to 2.7.3 version of Python (that was installed for Windows). So, I guess you can do the same.",0.0,False,4,216 -2009-07-14 20:29:34.933,Python object has no referrers but still accessible via a weakref?,"Should it be possible for gc.get_referrers(obj) to return an empty list for an object, but the object still be accessible through a weak reference? -If so how would I start trying to identify the cause for this object not being garbage collected? -Edit: I'm not sure exactly how a code sample would help in this case - there's obviously a strong reference somewhere, but I'll be damned if I can find it. I was of the impression that all strong references to an object would be identified by get_referrers(). -Edit: Solved. I found the variable with a strong reference - It was inside the game event loop but wasn't a class variable so get_referrers wasn't picking it up.","It might also be the case that a reference was leaked by a buggy C extension, IMHO you will not see the referer, yet still the refcount does not go down to 0. You might want to check the return value of sys.getrefcount.",0.0814518047658113,False,2,217 +2009-07-14 17:28:02.430,Best way to have full Python install under cygwin/XP?,"Pythons installed under WinXP have dirs like DLLs, DOC, include, etc. but python (2.5) installed with cygwin is a bare python.exe. My motivation for asking is that 'things' under XP don't seem to be finding 'other things' under cygwin and vice versa, I want to start developing with Qt, I like shells, and I do not like MS; I thought if I got all the components under one roof, I could finally start to have scripts find executables which could find files and such. 1. Can I simply copy the contents of an XP installation into the cygwin tree? 2. Is the XP flavor of Python different from the cygwin flavor? (Same CPU, he pointed out, naively.) 3. Someone must work with a full-fledged (if snakes had feathers...) Python from within cygwin; how is it done? +Disclaimer 1: I have never compiled anything under XP or cygwin; had hoped not to have to go there, hence, python in the first place. Disclaimer 2: sorry if this is a ServerFault question, but they seemed to be system people over there and this is (in my case) a lowly desktop.","This probably has little value, but... I found myself in this exact situation -- we use ActivePython2.5 in production (pure windows environment) and I was trying to do my development within cygwin and cygwin's Python... +After ripping out half of my hair, I have now switched over to Console2, gvim, iPython and ActivePython2.5. +I'm less than thrilled dealing with Windows tools (and their concomitant warts), but at least I'm not getting in my own way when it comes to development. For a while I found I was spending more time trying to get my tools to play nice than actually getting any work done. +Good luck on this one.",0.0,False,4,216 2009-07-14 20:29:34.933,Python object has no referrers but still accessible via a weakref?,"Should it be possible for gc.get_referrers(obj) to return an empty list for an object, but the object still be accessible through a weak reference? If so how would I start trying to identify the cause for this object not being garbage collected? Edit: I'm not sure exactly how a code sample would help in this case - there's obviously a strong reference somewhere, but I'll be damned if I can find it. I was of the impression that all strong references to an object would be identified by get_referrers(). @@ -2648,17 +2644,10 @@ It IS legal for the object to have no referrers and yet not be garbage collected From the Python 2.7 manual: ""An implementation is allowed to postpone garbage collection or omit it altogether — it is a matter of implementation quality how garbage collection is implemented, as long as no objects are collected that are still reachable."" The NO-OP garbage collector is legal. The discussions about generational and reference-counting garbage collectors are referring to a particular CPython implementation (as tagged in the question)",0.0814518047658113,False,2,217 -2009-07-15 03:15:27.133,creating non-reloading dynamic webapps using Django,"As far as I know, for a new request coming from a webapp, you need to reload the page to process and respond to that request. -For example, if you want to show a comment on a post, you need to reload the page, process the comment, and then show it. What I want, however, is I want to be able to add comments (something like facebook, where the comment gets added and shown without having to reload the whole page, for example) without having to reload the web-page. Is it possible to do with only Django and Python with no Javascript/AJAX knowledge? -I have heard it's possible with AJAX (I don't know how), but I was wondering if it was possible to do with Django. -Thanks,","You want to do that with out any client side code (javascript and ajax are just examples) and with out reloading your page (or at least part of it)? -If that is your question, then the answer unfortunately is you can't. You need to either have client side code or reload your page. -Think about it, once the client get's the page it will not change unless - -The client requests the same page from the server and the server returns and updated one -the page has some client side code (eg: javascript) that updates the page. - -I can not imagine a third possibility. I have not coded in Django for more than 30 mins and this is clearly obvious to me. If I am wrong plz down vote :D",1.2,True,2,218 +2009-07-14 20:29:34.933,Python object has no referrers but still accessible via a weakref?,"Should it be possible for gc.get_referrers(obj) to return an empty list for an object, but the object still be accessible through a weak reference? +If so how would I start trying to identify the cause for this object not being garbage collected? +Edit: I'm not sure exactly how a code sample would help in this case - there's obviously a strong reference somewhere, but I'll be damned if I can find it. I was of the impression that all strong references to an object would be identified by get_referrers(). +Edit: Solved. I found the variable with a strong reference - It was inside the game event loop but wasn't a class variable so get_referrers wasn't picking it up.","It might also be the case that a reference was leaked by a buggy C extension, IMHO you will not see the referer, yet still the refcount does not go down to 0. You might want to check the return value of sys.getrefcount.",0.0814518047658113,False,2,217 2009-07-15 03:15:27.133,creating non-reloading dynamic webapps using Django,"As far as I know, for a new request coming from a webapp, you need to reload the page to process and respond to that request. For example, if you want to show a comment on a post, you need to reload the page, process the comment, and then show it. What I want, however, is I want to be able to add comments (something like facebook, where the comment gets added and shown without having to reload the whole page, for example) without having to reload the web-page. Is it possible to do with only Django and Python with no Javascript/AJAX knowledge? I have heard it's possible with AJAX (I don't know how), but I was wondering if it was possible to do with Django. @@ -2671,6 +2660,17 @@ I have heard it's possible with AJAX...but I was There's no reason you can't use both - specifically, AJAX within a Django web application. Django provides your organization and framework needs (and a page that will respond to AJAX requests) and then use some JavaScript on the client side to make AJAX calls to your Django-backed page that will respond correctly. I suggest you go find a basic jQuery tutorial which should explain enough basic JavaScript to get this working.",0.1016881243684853,False,2,218 +2009-07-15 03:15:27.133,creating non-reloading dynamic webapps using Django,"As far as I know, for a new request coming from a webapp, you need to reload the page to process and respond to that request. +For example, if you want to show a comment on a post, you need to reload the page, process the comment, and then show it. What I want, however, is I want to be able to add comments (something like facebook, where the comment gets added and shown without having to reload the whole page, for example) without having to reload the web-page. Is it possible to do with only Django and Python with no Javascript/AJAX knowledge? +I have heard it's possible with AJAX (I don't know how), but I was wondering if it was possible to do with Django. +Thanks,","You want to do that with out any client side code (javascript and ajax are just examples) and with out reloading your page (or at least part of it)? +If that is your question, then the answer unfortunately is you can't. You need to either have client side code or reload your page. +Think about it, once the client get's the page it will not change unless + +The client requests the same page from the server and the server returns and updated one +the page has some client side code (eg: javascript) that updates the page. + +I can not imagine a third possibility. I have not coded in Django for more than 30 mins and this is clearly obvious to me. If I am wrong plz down vote :D",1.2,True,2,218 2009-07-17 22:18:26.670,"How to override Py_GetPrefix(), Py_GetPath()?","I'm trying to embed the Python interpreter and need to customize the way the Python standard library is loaded. Our library will be loaded from the same directory as the executable, not from prefix/lib/. We have been successful in making this work by manually modifying sys.path after calling Py_Initialize(), however, this generates a warning because Py_Initialize is looking for site.py in ./lib/, and it's not present until after Py_Initialize has been called and we have updated sys.path. The Python c-api docs hint that it's possible to override Py_GetPrefix() and Py_GetPath(), but give no indication of how. Does anyone know how I would go about overriding them?",Have you considered using putenv to adjust PYTHONPATH before calling Py_Initialize?,0.3869120172231254,False,2,219 @@ -2694,20 +2694,6 @@ I'm just looking for documentation (although if it's an indicator to some checke I think a comment in the docstring is plenty. This allows any user of your method to type help(obj.method) and see that the method is an override. You can also explicitly extend an interface with class Foo(Interface), which will allow users to type help(Interface.method) to get an idea about the functionality your method is intended to provide.",0.1352210990936997,False,1,223 2009-07-22 22:05:47.193,"Recommended ways to split some functionality into functions, modules and packages?","There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project). -The question - how does one decide the parts to put in the same module, and the parts to put in a separate module? Same question for packages.","IMHO this should probably one of the things you do earlier in the development process. I have never worked on a large-scale project, but it would make sense that you make a roadmap of what's going to be done and where. (Not trying to rib you for asking about it like you made a mistake :D ) -Modules are generally grouped somehow, by purpose or functionality. You could try each implementation of an interface, or other connections.",0.0679224682270276,False,4,224 -2009-07-22 22:05:47.193,"Recommended ways to split some functionality into functions, modules and packages?","There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project). -The question - how does one decide the parts to put in the same module, and the parts to put in a separate module? Same question for packages.","Take out a pen and piece of paper. Try to draw how your software interacts on a high level. Draw the different layers of the software etc. Group items by functionality and purpose, maybe even by what sort of technology they use. If your software has multiple abstraction layers, I would say to group them by that. On a high level, the elements of a specific layer all share the same general purpose. Now that you have your software in layers, you can divide these layers into different projects based on specific functionality or specialization. -As for a certain stage that you reach in which you should do this? I'd say when you have multiple people working on the code base or if you want to keep your project as modular as possible. Hopefully your code is modular enough to do this with. If you are unable to break apart your software on a high level, then your software is probably spaghetti code and you should look at refactoring it. -Hopefully that will give you something to work with.",0.2655860252697744,False,4,224 -2009-07-22 22:05:47.193,"Recommended ways to split some functionality into functions, modules and packages?","There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project). -The question - how does one decide the parts to put in the same module, and the parts to put in a separate module? Same question for packages.","Actually it varies for each project you create but here is an example: - -core package contains modules that are your project cant live without. this may contain the main functionality of your application. -ui package contains modules that deals with the user interface. that is if you split the UI from your console. - -This is just an example. and it would really you that would be deciding which and what to go where.",0.0,False,4,224 -2009-07-22 22:05:47.193,"Recommended ways to split some functionality into functions, modules and packages?","There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project). The question - how does one decide the parts to put in the same module, and the parts to put in a separate module? Same question for packages.","I sympathize with you. You are suffering from self-doubt. Don't worry. If you can speak any language, including your mother tongue, you are qualified to do modularization on your own. For evidence, you may read ""The Language Instinct,"" or ""The Math Instinct."" Look around, but not too much. You can learn a lot from them, but you can learn many bad things from them too. @@ -2720,6 +2706,20 @@ Here is my help, proven in my experience. It is a lot like deciding what attributes go to which DB table, what properties/methods go to which class/object etc? On a deeper level, it is a lot like arranging furniture at home, or books in a shelf. You have done such things already. Software is the same, no big deal! Worry about ""cohesion"" first. e.g. Books (Leo Tolstoy, James Joyce, DE Lawrence) is choesive .(HTML, CSS, John Keats. jQuery, tinymce) is not. And there are many ways to arrange things. Even taxonomists are still in serious feuds over this. Then worry about ""coupling."" Be ""shy"". ""Don't talk to strangers."" Don't be over-friendly. Try to make your package/DB table/class/object/module/bookshelf as self-contained, as independent as possible. Joel has talked about his admiration for the Excel team that abhor all external dependencies and that even built their own compiler.",0.0679224682270276,False,4,224 +2009-07-22 22:05:47.193,"Recommended ways to split some functionality into functions, modules and packages?","There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project). +The question - how does one decide the parts to put in the same module, and the parts to put in a separate module? Same question for packages.","Actually it varies for each project you create but here is an example: + +core package contains modules that are your project cant live without. this may contain the main functionality of your application. +ui package contains modules that deals with the user interface. that is if you split the UI from your console. + +This is just an example. and it would really you that would be deciding which and what to go where.",0.0,False,4,224 +2009-07-22 22:05:47.193,"Recommended ways to split some functionality into functions, modules and packages?","There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project). +The question - how does one decide the parts to put in the same module, and the parts to put in a separate module? Same question for packages.","Take out a pen and piece of paper. Try to draw how your software interacts on a high level. Draw the different layers of the software etc. Group items by functionality and purpose, maybe even by what sort of technology they use. If your software has multiple abstraction layers, I would say to group them by that. On a high level, the elements of a specific layer all share the same general purpose. Now that you have your software in layers, you can divide these layers into different projects based on specific functionality or specialization. +As for a certain stage that you reach in which you should do this? I'd say when you have multiple people working on the code base or if you want to keep your project as modular as possible. Hopefully your code is modular enough to do this with. If you are unable to break apart your software on a high level, then your software is probably spaghetti code and you should look at refactoring it. +Hopefully that will give you something to work with.",0.2655860252697744,False,4,224 +2009-07-22 22:05:47.193,"Recommended ways to split some functionality into functions, modules and packages?","There comes a point where, in a relatively large sized project, one need to think about splitting the functionality into various functions, and then various modules, and then various packages. Sometimes across different source distributions (eg: extracting a common utility, such as optparser, into a separate project). +The question - how does one decide the parts to put in the same module, and the parts to put in a separate module? Same question for packages.","IMHO this should probably one of the things you do earlier in the development process. I have never worked on a large-scale project, but it would make sense that you make a roadmap of what's going to be done and where. (Not trying to rib you for asking about it like you made a mistake :D ) +Modules are generally grouped somehow, by purpose or functionality. You could try each implementation of an interface, or other connections.",0.0679224682270276,False,4,224 2009-07-25 17:36:18.193,How can I launch a background process in Pylons?,"I am trying to write an application that will allow a user to launch a fairly long-running process (5-30 seconds). It should then allow the user to check the output of the process as it is generated. The output will only be needed for the user's current session so nothing needs to be stored long-term. I have two questions regarding how to accomplish this while taking advantage of the Pylons framework: What is the best way to launch a background process such as this with a Pylons controller? @@ -2734,19 +2734,19 @@ have the process write its output to /tmp/project/ID in pylons, implement URLs of the form /job/ID or /job?id=ID. That will look into the database whether the job is completed or not, and merge the temporary output into the page. (*) It might be better for the subprocess to create another process immediately, and have the pylons process wait for the first child, so that there will be no zombie processes.",0.2012947653214861,False,1,225 +2009-07-26 23:01:51.647,How to associate py extension with python launcher on Mac OS X?,"Does anyone know how to associate the py extension with the python interpreter on Mac OS X 10.5.7? I have gotten as far as selecting the application with which to associate it (/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python), but the python executable appears as a non-selectable grayed-out item. Any ideas?","The python.org OS X Python installers include an application called ""Python Launcher.app"" which does exactly what you want. It gets installed into /Applications /Python n.n/ for n.n > 2.6 or /Applications/MacPython n.n/ for 2.5 and earlier. In its preference panel, you can specify which Python executable to launch; it can be any command-line path, including the Apple-installed one at /usr/bin/python2.5. You will also need to ensure that .py is associated with ""Python Launcher""; you can use the Finder's Get Info command to do that as described elsewhere. Be aware, though, that this could be a security risk if downloaded .py scripts are automatically launched by your browser(s). (Note, the Apple-supplied Python in 10.5 does not include ""Python Launcher.app"").",0.5457054096481145,False,3,226 2009-07-26 23:01:51.647,How to associate py extension with python launcher on Mac OS X?,"Does anyone know how to associate the py extension with the python interpreter on Mac OS X 10.5.7? I have gotten as far as selecting the application with which to associate it (/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python), but the python executable appears as a non-selectable grayed-out item. Any ideas?","The file associations are done with the ""Get Info"". You select your .PY file, select the File menu; Get Info menu item. Mid-way down the Get Info page is ""Open With"". You can pick the Python Launcher. There's a Change All.. button that changes the association for all .py files.",0.296905446847765,False,3,226 -2009-07-26 23:01:51.647,How to associate py extension with python launcher on Mac OS X?,"Does anyone know how to associate the py extension with the python interpreter on Mac OS X 10.5.7? I have gotten as far as selecting the application with which to associate it (/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python), but the python executable appears as a non-selectable grayed-out item. Any ideas?","The python.org OS X Python installers include an application called ""Python Launcher.app"" which does exactly what you want. It gets installed into /Applications /Python n.n/ for n.n > 2.6 or /Applications/MacPython n.n/ for 2.5 and earlier. In its preference panel, you can specify which Python executable to launch; it can be any command-line path, including the Apple-installed one at /usr/bin/python2.5. You will also need to ensure that .py is associated with ""Python Launcher""; you can use the Finder's Get Info command to do that as described elsewhere. Be aware, though, that this could be a security risk if downloaded .py scripts are automatically launched by your browser(s). (Note, the Apple-supplied Python in 10.5 does not include ""Python Launcher.app"").",0.5457054096481145,False,3,226 2009-07-26 23:01:51.647,How to associate py extension with python launcher on Mac OS X?,"Does anyone know how to associate the py extension with the python interpreter on Mac OS X 10.5.7? I have gotten as far as selecting the application with which to associate it (/System/Library/Frameworks/Python.framework/Versions/2.5/bin/python), but the python executable appears as a non-selectable grayed-out item. Any ideas?","The default python installation (atleast on 10.6.8) includes the Python Launcher.app in /System/Library/Frameworks/Python.framework/Resources/, which is aliased to the latest/current version of Python installed on the system. This application launches terminal and sets the right environment to run the script.",0.0,False,3,226 2009-07-27 12:44:15.817,How to exit from Python without traceback?,"I would like to know how to I exit from Python without having an traceback dump on the output. I still want want to be able to return an error code but I do not want to display the traceback log. -I want to be able to exit using exit(number) without trace but in case of an Exception (not an exit) I want the trace.",something like import sys; sys.exit(0) ?,0.3516689306882844,False,2,227 -2009-07-27 12:44:15.817,How to exit from Python without traceback?,"I would like to know how to I exit from Python without having an traceback dump on the output. -I still want want to be able to return an error code but I do not want to display the traceback log. I want to be able to exit using exit(number) without trace but in case of an Exception (not an exit) I want the trace.","Use the built-in python function quit() and that's it. No need to import any library. I'm using python 3.4",0.1218406379589197,False,2,227 +2009-07-27 12:44:15.817,How to exit from Python without traceback?,"I would like to know how to I exit from Python without having an traceback dump on the output. +I still want want to be able to return an error code but I do not want to display the traceback log. +I want to be able to exit using exit(number) without trace but in case of an Exception (not an exit) I want the trace.",something like import sys; sys.exit(0) ?,0.3516689306882844,False,2,227 2009-07-27 15:11:19.977,Python POST ordered params,"I have a web service that accepts passed in params using http POST but in a specific order, eg (name,password,data). I have tried to use httplib but all the Python http POST libraries seem to take a dictionary, which is an unordered data structure. Any thoughts on how to http POST params in order for Python? Thanks!","Why would you need a specific order in the POST parameters in the first place? As far as I know there are no requirements that POST parameter order is preserved by web servers. Every language I have used, has used a dictionary type object to hold these parameters as they are inherently key/value pairs.",1.2,True,1,228 @@ -2758,15 +2758,20 @@ Furthermore, I'm not even 100% sure that ASCII is what I need for a plaintext em Ideally, the amount of free RAM should consider only physical memory that can actually be allocated to the Python process.","You can't do this with just the standard Python library, although there might be some third party package that does it. Barring that, you can use the os package to determine which operating system you're on and use that information to acquire the info you want for that system (and encapsulate that into a single cross-platform function).",0.2401167094949473,False,1,231 2009-07-30 09:22:31.380,Neural net input/output,"Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out +if someone could provide examples in python that would be a big help","More complex data usually means adding more neurons in the input and output layers. +You can feed each ""field"" of your register, properly encoded as a real value (normalized, etc.) to each input neuron, or maybe you can even decompose even further into bit fields, assigning saturated inputs of 1 or 0 to the neurons... for the output, it depends on how you train the neural network, it will try to mimic the training set outputs.",0.0,False,4,232 +2009-07-30 09:22:31.380,Neural net input/output,"Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types +i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out +if someone could provide examples in python that would be a big help","You have to add the number of units for input and output you need for the problem. If the unknown function to approximate depends on n parameter, you will have n input units. The number of output units depends on the nature of the funcion. For real functions with n real parameters you will have one output unit. +Some problems, for example in forecasting of time series, you will have m output units for the m succesive values of the function. The encoding is important and depends on the choosen algorithm. For example, in backpropagation for feedforward nets, is better to transform, if possible, the greater number of features in discrete inputs, as for classification tasks. +Other aspect of the encoding is that you have to evaluate the number of input and hidden units in function of the amount of data. Too many units related to data may give poor approximation due the course ff dimensionality problem. In some cases, you may to aggregate some of the input data in some way to avoid that problem or use some reduction mechanism as PCA.",0.0,False,4,232 +2009-07-30 09:22:31.380,Neural net input/output,"Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types +i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out if someone could provide examples in python that would be a big help","You have to encode your input and your output to something that can be represented by the neural network units. ( for example 1 for ""x has a certain property p"" -1 for ""x doesn't have the property p"" if your units' range is in [-1, 1]) The way you encode your input and the way you decode your output depends on what you want to train the neural network for. Moreover, there are many ""neural networks"" algoritms and learning rules for different tasks( Back propagation, boltzman machines, self organizing maps).",1.2,True,4,232 2009-07-30 09:22:31.380,Neural net input/output,"Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out -if someone could provide examples in python that would be a big help","More complex data usually means adding more neurons in the input and output layers. -You can feed each ""field"" of your register, properly encoded as a real value (normalized, etc.) to each input neuron, or maybe you can even decompose even further into bit fields, assigning saturated inputs of 1 or 0 to the neurons... for the output, it depends on how you train the neural network, it will try to mimic the training set outputs.",0.0,False,4,232 -2009-07-30 09:22:31.380,Neural net input/output,"Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types -i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out if someone could provide examples in python that would be a big help","Your features must be decomposed into parts that can be represented as real numbers. The magic of a Neural Net is it's a black box, the correct associations will be made (with internal weights) during the training Inputs @@ -2789,28 +2794,23 @@ Complex number: [x,xi,...] ** Here your training vectors would be: 1.0 if it rained the next day, 0.0 if it didn't Of course, whether or not the problem can actually be modeled by a neural net is a different question.",0.2012947653214861,False,4,232 -2009-07-30 09:22:31.380,Neural net input/output,"Can anyone explain to me how to do more complex data sets like team stats, weather, dice, complex number types -i understand all the math and how everything works i just dont know how to input more complex data, and then how to read the data it spits out -if someone could provide examples in python that would be a big help","You have to add the number of units for input and output you need for the problem. If the unknown function to approximate depends on n parameter, you will have n input units. The number of output units depends on the nature of the funcion. For real functions with n real parameters you will have one output unit. -Some problems, for example in forecasting of time series, you will have m output units for the m succesive values of the function. The encoding is important and depends on the choosen algorithm. For example, in backpropagation for feedforward nets, is better to transform, if possible, the greater number of features in discrete inputs, as for classification tasks. -Other aspect of the encoding is that you have to evaluate the number of input and hidden units in function of the amount of data. Too many units related to data may give poor approximation due the course ff dimensionality problem. In some cases, you may to aggregate some of the input data in some way to avoid that problem or use some reduction mechanism as PCA.",0.0,False,4,232 2009-07-31 04:38:14.510,"Django ..""join"" query?","guys, how or where is the ""join"" query in Django? i think that Django dont have ""join""..but how ill make join? -Thanks","SQL Join queries are a hack because SQL doesn't have objects or navigation among objects. -Objects don't need ""joins"". Just access the related objects.",-0.9974579674738372,False,2,233 +Thanks","If you're using models, the select_related method will return the object for any foreign keys you have set up (up to a limit you specify) within that model.",1.2,True,2,233 2009-07-31 04:38:14.510,"Django ..""join"" query?","guys, how or where is the ""join"" query in Django? i think that Django dont have ""join""..but how ill make join? -Thanks","If you're using models, the select_related method will return the object for any foreign keys you have set up (up to a limit you specify) within that model.",1.2,True,2,233 +Thanks","SQL Join queries are a hack because SQL doesn't have objects or navigation among objects. +Objects don't need ""joins"". Just access the related objects.",-0.9974579674738372,False,2,233 +2009-07-31 08:47:34.600,downloading files to users machine?,"I am trying to download mp3 file to users machine without his/her consent while they are listening the song.So, next time they visit that web page they would not have to download same mp3, but palypack from the local file. this will save some bandwidth for me and for them. it something pandora used to do but I really don't know how to. +any ideas?","Don't do this. +Most files are cached anyway. +But if you really want to add this (because users asked for it), make it optional (default off).",0.2655860252697744,False,2,234 2009-07-31 08:47:34.600,downloading files to users machine?,"I am trying to download mp3 file to users machine without his/her consent while they are listening the song.So, next time they visit that web page they would not have to download same mp3, but palypack from the local file. this will save some bandwidth for me and for them. it something pandora used to do but I really don't know how to. any ideas?","You can't forcefully download files to a user without his consent. If that was possible you can only imagine what severe security flaw that would be. You can do one of two things: count on the browser to cache the media file serve the media via some 3rd party plugin (Flash, for example)",1.2,True,2,234 -2009-07-31 08:47:34.600,downloading files to users machine?,"I am trying to download mp3 file to users machine without his/her consent while they are listening the song.So, next time they visit that web page they would not have to download same mp3, but palypack from the local file. this will save some bandwidth for me and for them. it something pandora used to do but I really don't know how to. -any ideas?","Don't do this. -Most files are cached anyway. -But if you really want to add this (because users asked for it), make it optional (default off).",0.2655860252697744,False,2,234 2009-07-31 15:49:14.583,how can I get the uuid module for python 2.4.3,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?,"To continue where Alex left off.. Download the uuid-1.30.tar.gz from Alex's pypi link. @@ -2830,15 +2830,15 @@ Sasha A clarification of my question: My purpose is to download stock data from a certain web site. I need to perform it for many stocks so I need python to do it for me in a repetitive way. This specific site exports the data by letting me download it in Excel file by clicking a link. However after clicking the link I get a Web Page dialog box asking me if I am sure that I want to download this file. This Web page dialog is my problem - it is not an html page and it is not a regular windows dialog box. It is something else and I cannot configure how to control it with python. It has two buttons and I need to click on one of them (i.e. Continue). It seems like it is a special kind of window implemented in IE. It is distinguished by its title which looks like this: Webpage Dialog -- Download blalblabla. If I click Continue mannually it opens a regular windows dialog box (open,save,cancel) which i know how to handle with winGuiAuto library. Tried to use this library for the Webpage Dialog window with no luck. Tried to recognize the buttons with Autoit Info tool -no luck either. In fact, maybe these are not buttons, but actually links, however I cannot see the links and there is no source code visible... What I need is someone to tell me what this Web page Dialog box is and how to control it with Python. That was my question.","You can't, and you don't want to. When you ask a question, try explaining what you are trying to achieve, and not just the task immediately before you. You are likely barking down the wrong path. There is some other way of doing what you are trying to do.",0.0,False,1,237 2009-08-04 18:10:52.940,"With Python, can I keep a persistent dictionary and modify it?","So, I want to store a dictionary in a persistent file. Is there a way to use regular dictionary methods to add, print, or delete entries from the dictionary in that file? +It seems that I would be able to use cPickle to store the dictionary and load it, but I'm not sure where to take it from there.","pickling has one disadvantage. it can be expensive if your dictionary has to be read and written frequently from disk and it's large. pickle dumps the stuff down (whole). unpickle gets the stuff up (as a whole). +if you have to handle small dicts, pickle is ok. If you are going to work with something more complex, go for berkelydb. It is basically made to store key:value pairs.",0.0,False,3,238 +2009-08-04 18:10:52.940,"With Python, can I keep a persistent dictionary and modify it?","So, I want to store a dictionary in a persistent file. Is there a way to use regular dictionary methods to add, print, or delete entries from the dictionary in that file? It seems that I would be able to use cPickle to store the dictionary and load it, but I'm not sure where to take it from there.","Unpickle from file when program loads, modify as a normal dictionary in memory while program is running, pickle to file when program exits? Not sure exactly what more you're asking for here.",0.296905446847765,False,3,238 2009-08-04 18:10:52.940,"With Python, can I keep a persistent dictionary and modify it?","So, I want to store a dictionary in a persistent file. Is there a way to use regular dictionary methods to add, print, or delete entries from the dictionary in that file? It seems that I would be able to use cPickle to store the dictionary and load it, but I'm not sure where to take it from there.","Assuming the keys and values have working implementations of repr, one solution is that you save the string representation of the dictionary (repr(dict)) to file. YOu can load it using the eval function (eval(inputstring)). There are two main disadvantages of this technique: 1) Is will not work with types that have an unuseable implementation of repr (or may even seem to work, but fail). You'll need to pay at least some attention to what is going on. 2) Your file-load mechanism is basically straight-out executing Python code. Not great for security unless you fully control the input. It has 1 advantage: Absurdly easy to do.",0.0509761841073563,False,3,238 -2009-08-04 18:10:52.940,"With Python, can I keep a persistent dictionary and modify it?","So, I want to store a dictionary in a persistent file. Is there a way to use regular dictionary methods to add, print, or delete entries from the dictionary in that file? -It seems that I would be able to use cPickle to store the dictionary and load it, but I'm not sure where to take it from there.","pickling has one disadvantage. it can be expensive if your dictionary has to be read and written frequently from disk and it's large. pickle dumps the stuff down (whole). unpickle gets the stuff up (as a whole). -if you have to handle small dicts, pickle is ok. If you are going to work with something more complex, go for berkelydb. It is basically made to store key:value pairs.",0.0,False,3,238 2009-08-05 19:59:22.827,"In GTK, how do I make a window unable to be closed?","For example, graying out the ""X"" on windows systems.",Just call the set_deletable with False on the window in question. It will work as long as GTK can convince the window manager to make the window unclosable.,0.6730655149877884,False,1,239 2009-08-05 22:16:28.883,Compiling python modules with DEBUG defined on MSVC,"Python rather stupidly has a pragma directive in its include files that forces a link against python26_d.lib when the DEBUG preprocessor variable is defined. This is a problem because the python installer doesn't come with python26_d.lib! So I can't build applications in MSVC in debug mode. If I temporarily #undef DEBUG for just one file I get many complaints about inconsistent DLL linkage. If I change the pragma in pythons include file I get undefined references to various debug functions. I have tried compiling my own version of python but its somehow different enough from the python that gets distributed that I can't use my modules with apps built with the vanilla version of python @@ -2846,6 +2846,13 @@ Can anyone give me any advice on how to get round this?","This works also when l 2009-08-09 01:02:37.763,What is the importance of an IDE when programming in Python?,"I'm a beginning Python programmer, just getting my feet wet in the language and its tools and native practices. In the past, I've used languages that were tightly integrated into IDEs, and indeed I had never before considered that it was even possible to program outside of such a tool. However, much of the documentation and tutorials for Python eschew any sort of IDE, relying instead on powerful editors and interactive interpreters for writing and teaching the language. +How important is an IDE to normal Python development? +Are there good IDEs available for the language? +If you do use an IDE for Python, how do you use it effectively?","A matter of habit and personal preferences. Me, I use vim (I have to admit emacs is at least as powerful, but my fingers are deeply trained by over 30 years of vi, and any other editor gives me the jitters, especially when it tries to imitate vi and never really manages to get it 100% right;-), occasionally an interactive environment (python itself, sometimes ipython), and on even rarer occasions a debugger (pdb). A good editor gives me all I need in term of word completion, lookup, &c. +I've tried Eclipse, its plugins, eric, and Kommodo, but I just don't like them -- Wing, I think I could get used to, and I have to admit its debugger is absolutely out of this world... but, I very rarely use (or need!) advanced debugging functionality, so after every rare occasion I'd forget, and have to learn it all over again a few months later when the need arose again... nah!-)",0.2655860252697744,False,4,241 +2009-08-09 01:02:37.763,What is the importance of an IDE when programming in Python?,"I'm a beginning Python programmer, just getting my feet wet in the language and its tools and native practices. In the past, I've used languages that were tightly integrated into IDEs, and indeed I had never before considered that it was even possible to program outside of such a tool. +However, much of the documentation and tutorials for Python eschew any sort of IDE, relying instead on powerful editors and interactive interpreters for writing and teaching the language. + How important is an IDE to normal Python development? Are there good IDEs available for the language? If you do use an IDE for Python, how do you use it effectively?","How important is an IDE to normal Python development? @@ -2864,13 +2871,6 @@ N/A. I tried using Wing a few times but found that it interfered with my normal 2009-08-09 01:02:37.763,What is the importance of an IDE when programming in Python?,"I'm a beginning Python programmer, just getting my feet wet in the language and its tools and native practices. In the past, I've used languages that were tightly integrated into IDEs, and indeed I had never before considered that it was even possible to program outside of such a tool. However, much of the documentation and tutorials for Python eschew any sort of IDE, relying instead on powerful editors and interactive interpreters for writing and teaching the language. -How important is an IDE to normal Python development? -Are there good IDEs available for the language? -If you do use an IDE for Python, how do you use it effectively?","A matter of habit and personal preferences. Me, I use vim (I have to admit emacs is at least as powerful, but my fingers are deeply trained by over 30 years of vi, and any other editor gives me the jitters, especially when it tries to imitate vi and never really manages to get it 100% right;-), occasionally an interactive environment (python itself, sometimes ipython), and on even rarer occasions a debugger (pdb). A good editor gives me all I need in term of word completion, lookup, &c. -I've tried Eclipse, its plugins, eric, and Kommodo, but I just don't like them -- Wing, I think I could get used to, and I have to admit its debugger is absolutely out of this world... but, I very rarely use (or need!) advanced debugging functionality, so after every rare occasion I'd forget, and have to learn it all over again a few months later when the need arose again... nah!-)",0.2655860252697744,False,4,241 -2009-08-09 01:02:37.763,What is the importance of an IDE when programming in Python?,"I'm a beginning Python programmer, just getting my feet wet in the language and its tools and native practices. In the past, I've used languages that were tightly integrated into IDEs, and indeed I had never before considered that it was even possible to program outside of such a tool. -However, much of the documentation and tutorials for Python eschew any sort of IDE, relying instead on powerful editors and interactive interpreters for writing and teaching the language. - How important is an IDE to normal Python development? Are there good IDEs available for the language? If you do use an IDE for Python, how do you use it effectively?","(1) IDEs are less important than for other languages, but if you find one that is useful, it still makes things easier. Without IDEs -- what are doing? Always running Python from command line? @@ -2944,18 +2944,6 @@ Users of the system will be mechanical and electrical engineers making budgets, The 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. I'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. One 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. -Of 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?""","How malicious are your users? Really. -Exactly how malicious? -If 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. -If 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. -If you actually have desktop security issues (i.e., public safety, military, etc.) then rethink using the desktop. -Otherwise, relax, do the right thing, and don't worry about ""scripting"". -C++ programs are easier to hack because people are lazy and permit SQL injection.",1.2,True,2,253 -2009-09-02 00:03:32.233,How to deal with user authentication and wrongful modification in scripting languages?,"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). -Users 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. -The 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. -I'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. -One 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. Of 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?""","Possibly: The user enters their credentials into the desktop client. @@ -2963,13 +2951,25 @@ The client says to the server: ""Hi, my name username and my password is passwor The server checks these. The server says to the client: ""Hi, username. Here is your secret token: ..."" Subsequently the client uses the secret token together with the username to ""sign"" communications with the server.",0.2012947653214861,False,2,253 -2009-09-02 00:07:14.003,"On localhost, how do I pick a free port number?","I'm trying to play with inter-process communication and since I could not figure out how to use named pipes under Windows I thought I'll use network sockets. Everything happens locally. The server is able to launch slaves in a separate process and listens on some port. The slaves do their work and submit the result to the master. How do I figure out which port is available? I assume I cannot listen on port 80 or 21? -I'm using Python, if that cuts the choices down.",Bind the socket to port 0. A random free port from 1024 to 65535 will be selected. You may retrieve the selected port with getsockname() right after bind().,0.999999986313458,False,2,254 +2009-09-02 00:03:32.233,How to deal with user authentication and wrongful modification in scripting languages?,"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). +Users 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. +The 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. +I'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. +One 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. +Of 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?""","How malicious are your users? Really. +Exactly how malicious? +If 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. +If 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. +If you actually have desktop security issues (i.e., public safety, military, etc.) then rethink using the desktop. +Otherwise, relax, do the right thing, and don't worry about ""scripting"". +C++ programs are easier to hack because people are lazy and permit SQL injection.",1.2,True,2,253 2009-09-02 00:07:14.003,"On localhost, how do I pick a free port number?","I'm trying to play with inter-process communication and since I could not figure out how to use named pipes under Windows I thought I'll use network sockets. Everything happens locally. The server is able to launch slaves in a separate process and listens on some port. The slaves do their work and submit the result to the master. How do I figure out which port is available? I assume I cannot listen on port 80 or 21? I'm using Python, if that cuts the choices down.","You can listen on whatever port you want; generally, user applications should listen to ports 1024 and above (through 65535). The main thing if you have a variable number of listeners is to allocate a range to your app - say 20000-21000, and CATCH EXCEPTIONS. That is how you will know if a port is unusable (used by another process, in other words) on your computer. However, in your case, you shouldn't have a problem using a single hard-coded port for your listener, as long as you print an error message if the bind fails. Note also that most of your sockets (for the slaves) do not need to be explicitly bound to specific port numbers - only sockets that wait for incoming connections (like your master here) will need to be made a listener and bound to a port. If a port is not specified for a socket before it is used, the OS will assign a useable port to the socket. When the master wants to respond to a slave that sends it data, the address of the sender is accessible when the listener receives data. I presume you will be using UDP for this?",0.3153999413393242,False,2,254 +2009-09-02 00:07:14.003,"On localhost, how do I pick a free port number?","I'm trying to play with inter-process communication and since I could not figure out how to use named pipes under Windows I thought I'll use network sockets. Everything happens locally. The server is able to launch slaves in a separate process and listens on some port. The slaves do their work and submit the result to the master. How do I figure out which port is available? I assume I cannot listen on port 80 or 21? +I'm using Python, if that cuts the choices down.",Bind the socket to port 0. A random free port from 1024 to 65535 will be selected. You may retrieve the selected port with getsockname() right after bind().,0.999999986313458,False,2,254 2009-09-03 07:50:17.240,Importing external module in IronPython,"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. I 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? Maybe it is possible to copy the lib's .py file into app directory and import from there? @@ -2979,13 +2979,6 @@ Anyway, thanks for help ;)",If you have installed IronPython from NuGet packages 2009-09-04 01:40:30.637,calculate user inputed time with Python,"I need to calculate (using python) how much time a user has inputed, whether they input something like 3:30 or 3.5. I'm not really sure what the best way to go about this is and I thought I'd ask for advice from the experts. === Edit ================== To specify more clearly, I want the user to input hours and minutes or just minutes. I want them to be able to input the time in two formats, either in hh:mm (3:30 or 03:30) or as a float (3.5) hours. -The overall goal is to keep track of the time they have worked. So, I will be adding the time they enter up to get a total.","There are a few possible solutions, but at some point you're gonna run into ambiguous cases that will result in arbitrary conversions. -Overall I'd suggest taking any input and parsing the separators (whether : or . or something else) and then converting to seconds based on some schema of units you've defined. -Alternatively you could do a series of try/except statements to test it against different time formatting schemes to see if it matches. -I'm not sure what will be best in your case...",0.0,False,3,256 -2009-09-04 01:40:30.637,calculate user inputed time with Python,"I need to calculate (using python) how much time a user has inputed, whether they input something like 3:30 or 3.5. I'm not really sure what the best way to go about this is and I thought I'd ask for advice from the experts. -=== Edit ================== -To specify more clearly, I want the user to input hours and minutes or just minutes. I want them to be able to input the time in two formats, either in hh:mm (3:30 or 03:30) or as a float (3.5) hours. The overall goal is to keep track of the time they have worked. So, I will be adding the time they enter up to get a total.","First of all, you'll need some conventions. Is 3.55 five minutes to four hours, five milliseconds to four seconds, or 3 and 55/100 of a minute/hour/second? The same applies to 3:55. At least have a distinction between dot and colon, specifying that a dot means a fraction and a colon, a separator of hour/minute/second. Although you haven't specified what ""time"" is (since or o'clock?), you'll need that too. Then, it's simple a matter of having a final representation of a time that you want to work with, and keep converting the input until your final representation is achieved. Let's say you decide that ultimately time should be represented as MM:SS (two digits for minutes, a colon, two digits for seconds), you'll need to search the string for allowed occurrences of characters, and act accordingly. For example, having a colon and a dot at the same time is not allowed. If there's a single colon, you have a fraction, therefore you'll treat the second part as a fraction of 60. @@ -2994,6 +2987,13 @@ I don't know on what constraints you're working with, but the problem could be n 2009-09-04 01:40:30.637,calculate user inputed time with Python,"I need to calculate (using python) how much time a user has inputed, whether they input something like 3:30 or 3.5. I'm not really sure what the best way to go about this is and I thought I'd ask for advice from the experts. === Edit ================== To specify more clearly, I want the user to input hours and minutes or just minutes. I want them to be able to input the time in two formats, either in hh:mm (3:30 or 03:30) or as a float (3.5) hours. +The overall goal is to keep track of the time they have worked. So, I will be adding the time they enter up to get a total.","There are a few possible solutions, but at some point you're gonna run into ambiguous cases that will result in arbitrary conversions. +Overall I'd suggest taking any input and parsing the separators (whether : or . or something else) and then converting to seconds based on some schema of units you've defined. +Alternatively you could do a series of try/except statements to test it against different time formatting schemes to see if it matches. +I'm not sure what will be best in your case...",0.0,False,3,256 +2009-09-04 01:40:30.637,calculate user inputed time with Python,"I need to calculate (using python) how much time a user has inputed, whether they input something like 3:30 or 3.5. I'm not really sure what the best way to go about this is and I thought I'd ask for advice from the experts. +=== Edit ================== +To specify more clearly, I want the user to input hours and minutes or just minutes. I want them to be able to input the time in two formats, either in hh:mm (3:30 or 03:30) or as a float (3.5) hours. The overall goal is to keep track of the time they have worked. So, I will be adding the time they enter up to get a total.","Can you do this with a GUI and restrict the user input? Processing the text seems super error prone otherwise (on the part of the user, not to mention the programmer), and for hours worked... you sort-of want to get that right.",0.0,False,3,256 2009-09-05 12:33:03.783,Can I use __init__.py to define global variables?,"I want to define a constant that should be available in all of the submodules of a package. I've thought that the best place would be in in the __init__.py file of the root package. But I don't know how to do this. Suppose I have a few subpackages and each with several modules. How can I access that variable from these modules? Of course, if this is totally wrong, and there is a better alternative, I'd like to know it.","You can define global variables from anywhere, but it is a really bad idea. import the __builtin__ module and modify or add attributes to this modules, and suddenly you have new builtin constants or functions. In fact, when my application installs gettext, I get the _() function in all my modules, without importing anything. So this is possible, but of course only for Application-type projects, not for reusable packages or modules. @@ -3005,6 +3005,16 @@ A few hours ago, I tried the app on my laptop that has Python 2.6 installed. I g I installed Python 3.1 on my laptop without changing the app code. I ran it and it runs perfectly. I uninstalled Python 3.1 and the app crashes again. I put in code in my app to dynamically link from the local python31.dll, to ensure that it was using it, but I still get the crash. I don't know if the interpreter needs more than the DLL to start up or what. I haven't been able to find any resources on this. The Python documentation and other guides do not seem to ever address how to distribute your C/C++ applications that use Python embedding without having the users install Python locally. I know it's more of an issue on Windows than on Unix, but I've seen a number of Windows C/C++ applications that embed Python locally and I'm not sure how they do it. What else do I need other than the DLL? Why does it work when I install Python and then stop working when I uninstall it? It sounds like it should be so trivial; maybe that's why nobody really talks about it. Nevertheless, I can't really explain how to deal with this crash issue. +Thank you very much in advance.","A zip of the Python standard library worked for me with Python27. +I zipped the contents of Lib and dll, and made sure there was no additional python27-subfolder or Lib or dll subfolder. i.e. just a zip named python27.zip containing all the files. +I copied that zip and the python27.dll alongside the executable.",0.5457054096481145,False,2,258 +2009-09-07 06:56:51.613,C++ with Python embedding: crash if Python not installed,"I'm developing on Windows, and I've searched everywhere without finding anyone talking about this kind of thing. +I made a C++ app on my desktop that embedded Python 3.1 using MSVC. I linked python31.lib and included python31.dll in the app's run folder alongside the executable. It works great. My extension and embedding code definitely works and there are no crashes. +I sent the run folder to my friend who doesn't have Python installed, and the app crashes for him during the scripting setup phase. +A few hours ago, I tried the app on my laptop that has Python 2.6 installed. I got the same crash behavior as my friend, and through debugging found that it was the Py_Initialize() call that fails. +I installed Python 3.1 on my laptop without changing the app code. I ran it and it runs perfectly. I uninstalled Python 3.1 and the app crashes again. I put in code in my app to dynamically link from the local python31.dll, to ensure that it was using it, but I still get the crash. +I don't know if the interpreter needs more than the DLL to start up or what. I haven't been able to find any resources on this. The Python documentation and other guides do not seem to ever address how to distribute your C/C++ applications that use Python embedding without having the users install Python locally. I know it's more of an issue on Windows than on Unix, but I've seen a number of Windows C/C++ applications that embed Python locally and I'm not sure how they do it. +What else do I need other than the DLL? Why does it work when I install Python and then stop working when I uninstall it? It sounds like it should be so trivial; maybe that's why nobody really talks about it. Nevertheless, I can't really explain how to deal with this crash issue. Thank you very much in advance.","In addition to pythonxy.dll, you also need the entire Python library, i.e. the contents of the lib folder, plus the extension modules, i.e. the contents of the DLLs folder. Without the standard library, Python won't even start, since it tries to find os.py (in 3.x; string.py in 2.x). On startup, it imports a number of modules, in particular site.py. There are various locations where it searches for the standard library; in your cases, it eventually finds it in the registry. Before, uses the executable name (as set through Py_SetProgramName) trying to find the landmark; it also checks for a file python31.zip which should be a zipped copy of the standard library. It also checks for a environment variable PYTHONHOME. You are free to strip the library from stuff that you don't need; there are various tools that compute dependencies statically (modulefinder in particular). @@ -3013,16 +3023,6 @@ If you want to minimize the number of files, you can link all extension modules statically into your pythonxy.dll, or even link pythonxy.dll statically into your application use the freeze tool; this will allow linking the byte code of the standard library into your pythonxy.dll. (alternatively to 2.) use pythonxy.zip for the standard library.",1.2,True,2,258 -2009-09-07 06:56:51.613,C++ with Python embedding: crash if Python not installed,"I'm developing on Windows, and I've searched everywhere without finding anyone talking about this kind of thing. -I made a C++ app on my desktop that embedded Python 3.1 using MSVC. I linked python31.lib and included python31.dll in the app's run folder alongside the executable. It works great. My extension and embedding code definitely works and there are no crashes. -I sent the run folder to my friend who doesn't have Python installed, and the app crashes for him during the scripting setup phase. -A few hours ago, I tried the app on my laptop that has Python 2.6 installed. I got the same crash behavior as my friend, and through debugging found that it was the Py_Initialize() call that fails. -I installed Python 3.1 on my laptop without changing the app code. I ran it and it runs perfectly. I uninstalled Python 3.1 and the app crashes again. I put in code in my app to dynamically link from the local python31.dll, to ensure that it was using it, but I still get the crash. -I don't know if the interpreter needs more than the DLL to start up or what. I haven't been able to find any resources on this. The Python documentation and other guides do not seem to ever address how to distribute your C/C++ applications that use Python embedding without having the users install Python locally. I know it's more of an issue on Windows than on Unix, but I've seen a number of Windows C/C++ applications that embed Python locally and I'm not sure how they do it. -What else do I need other than the DLL? Why does it work when I install Python and then stop working when I uninstall it? It sounds like it should be so trivial; maybe that's why nobody really talks about it. Nevertheless, I can't really explain how to deal with this crash issue. -Thank you very much in advance.","A zip of the Python standard library worked for me with Python27. -I zipped the contents of Lib and dll, and made sure there was no additional python27-subfolder or Lib or dll subfolder. i.e. just a zip named python27.zip containing all the files. -I copied that zip and the python27.dll alongside the executable.",0.5457054096481145,False,2,258 2009-09-07 07:08:12.007,Django: Simple rate limiting,"Many of my views fetch external resources. I want to make sure that under heavy load I don't blow up the remote sites (and/or get banned). I only have 1 crawler so having a central lock will work fine. So the details: I want to allow at most 3 queries to a host per second, and have the rest block for a maximum of 15 seconds. How could I do this (easily)? @@ -3095,16 +3095,12 @@ def stringify(strlist): return rlist","Avoid concatenating all arguments into one string using that string. It's a lot simpler and better and safer to just pass a sequence (list or tuple) of arguments. This is specially true if any argument contains a space character (which is quite common for filenames).",0.1016881243684853,False,1,261 2009-09-12 20:10:43.223,"Python - Virtualenv , python 3?","Seems everyone recommends virtualenv for multiple python versions (on osx), but does it even work with python 3.0? I downloaded it, and it doesn't seem to.. And I don't really understand how it works, Can you 'turn on' on env at a time or something? What I want is to leave the system python 2.5 (obviously), and to have python 3.1.1 with subversion pygame to write my own stuff, and python 2.6 with normal stable pygame to use to run other things, like pygame games downloaded from pygame.org. Any help on how to accomplish that? Thanks. +OK I realized virtualenv is not what I'm looking for.",Your use case doesn't actually need virtualenv. You just need to install several different Python versions.,1.2,True,2,262 +2009-09-12 20:10:43.223,"Python - Virtualenv , python 3?","Seems everyone recommends virtualenv for multiple python versions (on osx), but does it even work with python 3.0? I downloaded it, and it doesn't seem to.. And I don't really understand how it works, Can you 'turn on' on env at a time or something? What I want is to leave the system python 2.5 (obviously), and to have python 3.1.1 with subversion pygame to write my own stuff, and python 2.6 with normal stable pygame to use to run other things, like pygame games downloaded from pygame.org. Any help on how to accomplish that? Thanks. OK I realized virtualenv is not what I'm looking for.","Not sure if I understood you correctly, but here goes :) I don't know about OS X, but in Linux you can install both 2.6 and 3. Then you can either specify to use python25 or python3, or change the /usr/bin/python symlink to the version you want to use by default.",0.0,False,2,262 -2009-09-12 20:10:43.223,"Python - Virtualenv , python 3?","Seems everyone recommends virtualenv for multiple python versions (on osx), but does it even work with python 3.0? I downloaded it, and it doesn't seem to.. And I don't really understand how it works, Can you 'turn on' on env at a time or something? What I want is to leave the system python 2.5 (obviously), and to have python 3.1.1 with subversion pygame to write my own stuff, and python 2.6 with normal stable pygame to use to run other things, like pygame games downloaded from pygame.org. Any help on how to accomplish that? Thanks. -OK I realized virtualenv is not what I'm looking for.",Your use case doesn't actually need virtualenv. You just need to install several different Python versions.,1.2,True,2,262 -2009-09-14 23:28:28.893,Default save path for Python IDLE?,"Does anyone know where or how to set the default path/directory on saving python scripts prior to running? -On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?","I am using windows 7 and by going to Start-> IDLE(Python 3.6 32-bit) -The click on properties and then in the shortcut tab go to -Start 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",0.0370887312438237,False,8,263 2009-09-14 23:28:28.893,Default save path for Python IDLE?,"Does anyone know where or how to set the default path/directory on saving python scripts prior to running? -On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?","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.",0.0740755660660223,False,8,263 +On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?","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.)",0.0370887312438237,False,8,263 2009-09-14 23:28:28.893,Default save path for Python IDLE?,"Does anyone know where or how to set the default path/directory on saving python scripts prior to running? On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?","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. 1) Right-click ""Properties"". @@ -3129,7 +3125,9 @@ os.chdir(os.path.expanduser('~/Documents')) with your desired path and then save the changes. Upon restarting the Python IDLE,you should find that your default Save as path to be the path you've indicated.",0.0370887312438237,False,8,263 2009-09-14 23:28:28.893,Default save path for Python IDLE?,"Does anyone know where or how to set the default path/directory on saving python scripts prior to running? -On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?","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.)",0.0370887312438237,False,8,263 +On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?","I am using windows 7 and by going to Start-> IDLE(Python 3.6 32-bit) +The click on properties and then in the shortcut tab go to +Start 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",0.0370887312438237,False,8,263 2009-09-14 23:28:28.893,Default save path for Python IDLE?,"Does anyone know where or how to set the default path/directory on saving python scripts prior to running? On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?","It seems like you can get idle into the directory you want if you run any module from that directory. I 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. @@ -3140,14 +3138,11 @@ Start IDLE. File -> Open to open your file. And set the current working directory.",0.0370887312438237,False,8,263 2009-09-14 23:28:28.893,Default save path for Python IDLE?,"Does anyone know where or how to set the default path/directory on saving python scripts prior to running? On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?","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.",0.0,False,8,263 +2009-09-14 23:28:28.893,Default save path for Python IDLE?,"Does anyone know where or how to set the default path/directory on saving python scripts prior to running? +On a Mac it wants to save them in the top level ~/Documents directory. I would like to specify a real location. Any ideas?","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.",0.0740755660660223,False,8,263 2009-09-15 04:48:36.987,Symmetrically adressable matrix,"I'm looking to create a 2d matrix of integers with symmetric addressing ( i.e. matrix[2,3] and matrix[3,2] will return the same value ) in python. The integers will have addition and subtraction done on them, and be used for logical comparisons. My initial idea was to create the integer objects up front and try to fill a list of lists with some python equivalent of pointers. I'm not sure how to do it, though. What is the best way to implement this, and should I be using lists or another data structure?","You're probably better off using a full square numpy matrix. Yes, it wastes half the memory storing redundant values, but rolling your own symmetric matrix in Python will waste even more memory and CPU by storing and processing the integers as Python objects.",0.2012947653214861,False,2,264 2009-09-15 04:48:36.987,Symmetrically adressable matrix,"I'm looking to create a 2d matrix of integers with symmetric addressing ( i.e. matrix[2,3] and matrix[3,2] will return the same value ) in python. The integers will have addition and subtraction done on them, and be used for logical comparisons. My initial idea was to create the integer objects up front and try to fill a list of lists with some python equivalent of pointers. I'm not sure how to do it, though. What is the best way to implement this, and should I be using lists or another data structure?",You only need to store the lower triangle of the matrix. Typically this is done with one n(n+1)/2 length list. You'll need to overload the __getitem__ method to interpret what the entry means.,0.1016881243684853,False,2,264 2009-09-17 19:44:09.870,Finding the command for a specific PID in Linux from Python,"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. -Any help would be great. Thanks.","The proc filesystem exports this (and other) information. -Look at the /proc/PID/cmd symlink.",0.0,False,3,265 -2009-09-17 19:44:09.870,Finding the command for a specific PID in Linux from Python,"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. -Any help would be great. Thanks.",Look in /proc/$PID/cmdline,0.336246259354525,False,3,265 -2009-09-17 19:44:09.870,Finding the command for a specific PID in Linux from Python,"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. Any help would be great. Thanks.","Look in /proc/$PID/cmdline, and then os.readlink() on /proc/$PID/exe. /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: @@ -3161,10 +3156,19 @@ However, nor is /proc/$PID/exe. Usually it is a symlink to the executable that i Also, 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 (#!). I 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. BTW. 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.",0.283556384140347,False,3,265 +2009-09-17 19:44:09.870,Finding the command for a specific PID in Linux from Python,"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. +Any help would be great. Thanks.",Look in /proc/$PID/cmdline,0.336246259354525,False,3,265 +2009-09-17 19:44:09.870,Finding the command for a specific PID in Linux from Python,"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. +Any help would be great. Thanks.","The proc filesystem exports this (and other) information. +Look at the /proc/PID/cmd symlink.",0.0,False,3,265 2009-09-18 17:52:53.017,Passing Python Data to JavaScript via Django,"I'm using Django and Apache to serve webpages. My JavaScript code currently includes a data object with values to be displayed in various HTML widgets based on the user's selection from a menu of choices. I want to derive these data from a Python dictionary. I think I know how to embed the JavaScript code in the HTML, but how do I embed the data object in that script (on the fly) so the script's functions can use it? Put another way, I want to create a JavaScript object or array from a Python dictionary, then insert that object into the JavaScript code, and then insert that JavaScript code into the HTML. I suppose this structure (e.g., data embedded in variables in the JavaScript code) is suboptimal, but as a newbie I don't know the alternatives. I've seen write-ups of Django serialization functions, but these don't help me until I can get the data into my JavaScript code in the first place. -I'm not (yet) using a JavaScript library like jQuery.",It is suboptimal. Have you considered passing your data as JSON using django's built in serializer for that?,0.1016881243684853,False,3,266 +I'm not (yet) using a JavaScript library like jQuery.","Putting Java Script embedded into Django template is rather always bad idea. +Rather, because there are some exceptions from this rule. +Everything depends on the your Java Script code site and functionality. +It is better to have seperately static files, like JS, but the problem is that every seperate file needs another connect/GET/request/response mechanism. Sometimes for small one, two liners code os JS to put this into template, bun then use django templatetags mechanism - you can use is in other templates ;) +About objects - the same. If your site has AJAX construction/web2.0 like favour - you can achieve very good effect putting some count/math operation onto client side. If objects are small - embedded into template, if large - response them in another connection to avoid hangind page for user.",0.0509761841073563,False,3,266 2009-09-18 17:52:53.017,Passing Python Data to JavaScript via Django,"I'm using Django and Apache to serve webpages. My JavaScript code currently includes a data object with values to be displayed in various HTML widgets based on the user's selection from a menu of choices. I want to derive these data from a Python dictionary. I think I know how to embed the JavaScript code in the HTML, but how do I embed the data object in that script (on the fly) so the script's functions can use it? Put another way, I want to create a JavaScript object or array from a Python dictionary, then insert that object into the JavaScript code, and then insert that JavaScript code into the HTML. I suppose this structure (e.g., data embedded in variables in the JavaScript code) is suboptimal, but as a newbie I don't know the alternatives. I've seen write-ups of Django serialization functions, but these don't help me until I can get the data into my JavaScript code in the first place. @@ -3173,11 +3177,7 @@ And Paul is right: it might be best to use a json module to create a JSON string 2009-09-18 17:52:53.017,Passing Python Data to JavaScript via Django,"I'm using Django and Apache to serve webpages. My JavaScript code currently includes a data object with values to be displayed in various HTML widgets based on the user's selection from a menu of choices. I want to derive these data from a Python dictionary. I think I know how to embed the JavaScript code in the HTML, but how do I embed the data object in that script (on the fly) so the script's functions can use it? Put another way, I want to create a JavaScript object or array from a Python dictionary, then insert that object into the JavaScript code, and then insert that JavaScript code into the HTML. I suppose this structure (e.g., data embedded in variables in the JavaScript code) is suboptimal, but as a newbie I don't know the alternatives. I've seen write-ups of Django serialization functions, but these don't help me until I can get the data into my JavaScript code in the first place. -I'm not (yet) using a JavaScript library like jQuery.","Putting Java Script embedded into Django template is rather always bad idea. -Rather, because there are some exceptions from this rule. -Everything depends on the your Java Script code site and functionality. -It is better to have seperately static files, like JS, but the problem is that every seperate file needs another connect/GET/request/response mechanism. Sometimes for small one, two liners code os JS to put this into template, bun then use django templatetags mechanism - you can use is in other templates ;) -About objects - the same. If your site has AJAX construction/web2.0 like favour - you can achieve very good effect putting some count/math operation onto client side. If objects are small - embedded into template, if large - response them in another connection to avoid hangind page for user.",0.0509761841073563,False,3,266 +I'm not (yet) using a JavaScript library like jQuery.",It is suboptimal. Have you considered passing your data as JSON using django's built in serializer for that?,0.1016881243684853,False,3,266 2009-09-20 16:01:16.207,How to stream binary data in python,"I want to stream a binary data using python. I do not have any idea how to achieve it. I did created python socket program using SOCK_DGRAM. Problem with SOCK_STREAM is that it does not work over internet as our isp dont allow tcp server socket. I want to transmit screen shots periodically to remote computer. I have an idea of maintaining a Que of binary data and have two threads write and read synchronously. @@ -3220,12 +3220,12 @@ This DLL can have any name, and is referenced in the registry at HKLM/Software/C Found examples using Delphi...",0.0,False,1,269 2009-09-22 20:57:06.170,What are sqlite development headers and how to install them?,"I am trying to install pysqlite and have troubles with that. I found out that the most probable reason of that is missing sqlite headers and I have to install them. However, I have no ideas what these headers are (where I can find them, what they are doing and how to install them). -Can anybody, pleas, help me with that?","pysqlite needs to compiled/build before you can use it. This requires C language header files (*.H) which come with the source code of sqllite itself. -i.e. sqllite and pysqlite are two different things. Did you install sqlite prior to trying and build pysqllte ? (or maybe you did, but did you do so just with the binaries; you need the source package (or at least its headers) for pysqlite purposes.",0.0,False,2,270 -2009-09-22 20:57:06.170,What are sqlite development headers and how to install them?,"I am trying to install pysqlite and have troubles with that. I found out that the most probable reason of that is missing sqlite headers and I have to install them. -However, I have no ideas what these headers are (where I can find them, what they are doing and how to install them). Can anybody, pleas, help me with that?","For me this worked (Redhat/CentOS): $ sudo yum install sqlite-devel",0.7408590612005881,False,2,270 +2009-09-22 20:57:06.170,What are sqlite development headers and how to install them?,"I am trying to install pysqlite and have troubles with that. I found out that the most probable reason of that is missing sqlite headers and I have to install them. +However, I have no ideas what these headers are (where I can find them, what they are doing and how to install them). +Can anybody, pleas, help me with that?","pysqlite needs to compiled/build before you can use it. This requires C language header files (*.H) which come with the source code of sqllite itself. +i.e. sqllite and pysqlite are two different things. Did you install sqlite prior to trying and build pysqllte ? (or maybe you did, but did you do so just with the binaries; you need the source package (or at least its headers) for pysqlite purposes.",0.0,False,2,270 2009-09-23 09:53:04.933,Install python 2.6 in CentOS,"I have a shell that runs CentOS. For a project I'm doing, I need python 2.5+, but centOS is pretty dependent on 2.4. From what I've read, a number of things will break if you upgrade to 2.5. @@ -3277,12 +3277,12 @@ If you need to figure out with finer granularity what is eating all your time, t 2009-10-01 04:36:27.693,Run a task every hour on the hour with App Engine's cron API,"I need to run a task every hour on the hour (00:00, 01:00, 02:00, ..., 23:00) every day of the week, but can't seem to find an example in App Engine's docs of how to do this. There is an example of running at ask every hour, but this doesn't fit because the ""start"" of that hour depends on when you deploy the application. That is, if I deploy at 4:37 PM, the cron scripts will get executed at 5:37, 6:37, ... instead of 5:00, 6:00, ... So far the only way that looks like it would work is to have 24 different cron entries, one for the specific hour of each day set to run each day at that specific time. -Does anyone know of anything that would let me use a schedule like ""every hour at :00"" or even ""every day 00:00, 01:00, ... 23:00""?","The docs say you can have 20 cron entries, so you can't have one for every hour of the day. -You could run your task every minute and check if it is the first minute of the hour - exit otherwise.",0.1016881243684853,False,2,279 +Does anyone know of anything that would let me use a schedule like ""every hour at :00"" or even ""every day 00:00, 01:00, ... 23:00""?","Looking over the docs, I agree that your 24 cron entry idea is the only documented way that would work. Not ideal, but should work.",-0.1016881243684853,False,2,279 2009-10-01 04:36:27.693,Run a task every hour on the hour with App Engine's cron API,"I need to run a task every hour on the hour (00:00, 01:00, 02:00, ..., 23:00) every day of the week, but can't seem to find an example in App Engine's docs of how to do this. There is an example of running at ask every hour, but this doesn't fit because the ""start"" of that hour depends on when you deploy the application. That is, if I deploy at 4:37 PM, the cron scripts will get executed at 5:37, 6:37, ... instead of 5:00, 6:00, ... So far the only way that looks like it would work is to have 24 different cron entries, one for the specific hour of each day set to run each day at that specific time. -Does anyone know of anything that would let me use a schedule like ""every hour at :00"" or even ""every day 00:00, 01:00, ... 23:00""?","Looking over the docs, I agree that your 24 cron entry idea is the only documented way that would work. Not ideal, but should work.",-0.1016881243684853,False,2,279 +Does anyone know of anything that would let me use a schedule like ""every hour at :00"" or even ""every day 00:00, 01:00, ... 23:00""?","The docs say you can have 20 cron entries, so you can't have one for every hour of the day. +You could run your task every minute and check if it is the first minute of the hour - exit otherwise.",0.1016881243684853,False,2,279 2009-10-01 23:32:12.717,How do I get fluent in Python?,"Once you have learned the basic commands in Python, you are often able to solve most programming problem you face. But the way in which this is done is not really Python-ic. What is common is to use the classical c++ or Java mentality to solve problems. But Python is more than that. It has functional programming incorporated; many libraries available; object oriented, and its own ways. In short there are often better, shorter, faster, more elegant ways to the same thing. It is a little bit like learning a new language. First you learn the words and the grammar, but then you need to get fluent. @@ -3323,25 +3323,25 @@ My goal is to make a sort of encyclopedic program for a game I'm playing right n My plan is for this application to be able to run under Windows, Linux and Mac (I'm under the impression that any code written in Python works 100% cross-platform, right?) Thanks a lot for your tremendous help brothers of SO. :P Edit: -I guess I should clarify that I'm looking for an IDE that supports drag and drop GUI design. I'm used to using VS and I'm not really sure how you can do it any other way.","Good IDE for python are Komodo or Eclipse with PyDev. -But even Notepad++ or any other text editor will enough to get you started, since you don't need to compile your code, just have a good editor. -The benefit of the above IDEs, is that you can use them to manage a large scale project and debug your code. -As for the cross platform issue, as long as you don't use the specific os libs (such as win32api), you are safe in being cross platform. -Seems like a very large project for a first time. Is it going to be web based or desktop? Since it will greatly change your design and choice of python libs.",0.0370887312438237,False,2,284 +I guess I should clarify that I'm looking for an IDE that supports drag and drop GUI design. I'm used to using VS and I'm not really sure how you can do it any other way.","Eclipse + Pydev is currently the gold standard IDE for Python. It's cross platform and since it's a general purpose IDE it has support for just about every other programming activity you might want to consider. +Eclipse is not bad for C++, and very mature for Java developers. It's quite amazing when you realize that all this great stuff costs nothing.",0.0,False,2,284 2009-10-04 21:29:10.883,"Coming from a Visual Studio background, what do you recommend I use to start my VERY FIRST Python project?","I'm locked in using C# and I don't like it one bit. I have to start branching out to better myself as a professional and as a person, so I've decided to start making things in my own time using Python. The problem is, I've basically programmed only in C#. What IDE should I use to make programs using Python? My goal is to make a sort of encyclopedic program for a game I'm playing right now, displaying hero information, names, stats, picture, etc. All of this information I'm going to parse from an XML file. My plan is for this application to be able to run under Windows, Linux and Mac (I'm under the impression that any code written in Python works 100% cross-platform, right?) Thanks a lot for your tremendous help brothers of SO. :P Edit: -I guess I should clarify that I'm looking for an IDE that supports drag and drop GUI design. I'm used to using VS and I'm not really sure how you can do it any other way.","Eclipse + Pydev is currently the gold standard IDE for Python. It's cross platform and since it's a general purpose IDE it has support for just about every other programming activity you might want to consider. -Eclipse is not bad for C++, and very mature for Java developers. It's quite amazing when you realize that all this great stuff costs nothing.",0.0,False,2,284 +I guess I should clarify that I'm looking for an IDE that supports drag and drop GUI design. I'm used to using VS and I'm not really sure how you can do it any other way.","Good IDE for python are Komodo or Eclipse with PyDev. +But even Notepad++ or any other text editor will enough to get you started, since you don't need to compile your code, just have a good editor. +The benefit of the above IDEs, is that you can use them to manage a large scale project and debug your code. +As for the cross platform issue, as long as you don't use the specific os libs (such as win32api), you are safe in being cross platform. +Seems like a very large project for a first time. Is it going to be web based or desktop? Since it will greatly change your design and choice of python libs.",0.0370887312438237,False,2,284 2009-10-05 14:52:40.987,Getting proper code completion for Python on Vim?,"I've gotten omnicompletion with Pysmell to work before, but I can't seem to do it again. I tried following some steps online, but most, if not all, of them are to vague and assume too much that you know what you are doing to some extent. -Can someone post a full, step-by-step tutorial on how to get code completion working properly, for complete Vim newbies (for dummies?)?",There's also Ctrl+n in insert mode which will autocomplete based on the words it has seen in any of the open buffers (even in other tabs).,0.3869120172231254,False,2,285 +Can someone post a full, step-by-step tutorial on how to get code completion working properly, for complete Vim newbies (for dummies?)?","Try hitting Ctrl-p while typing mid-word. Ctrl-p inserts the most recent word that starts with the prefix you're typing and Ctrl-n inserts the next match. If you have several possibilities, you can hit ctrl-p more than once to substitute each candidate in order.",0.0,False,2,285 2009-10-05 14:52:40.987,Getting proper code completion for Python on Vim?,"I've gotten omnicompletion with Pysmell to work before, but I can't seem to do it again. I tried following some steps online, but most, if not all, of them are to vague and assume too much that you know what you are doing to some extent. -Can someone post a full, step-by-step tutorial on how to get code completion working properly, for complete Vim newbies (for dummies?)?","Try hitting Ctrl-p while typing mid-word. Ctrl-p inserts the most recent word that starts with the prefix you're typing and Ctrl-n inserts the next match. If you have several possibilities, you can hit ctrl-p more than once to substitute each candidate in order.",0.0,False,2,285 +Can someone post a full, step-by-step tutorial on how to get code completion working properly, for complete Vim newbies (for dummies?)?",There's also Ctrl+n in insert mode which will autocomplete based on the words it has seen in any of the open buffers (even in other tabs).,0.3869120172231254,False,2,285 2009-10-05 18:28:55.523,Close Python when Parent is closed,"I have a Python program (PP) that loads another Program(AP) via COM, gets its window handle and sets it to be the PP parent. This works pretty well except that I can't control that AP still has their [X] button available in the top left corner. Since this is a pretty obvious place for the user to close when they are done with the program, I tried this and it left the PP in the Task Manager running, but not visible with no possible way to kill it other than through Task Manager. Any ideas on how to handle this? I expect it to be rather Common that the user closes in this manner. Thanks!","How's PP's control flow? If it's event-driven it could get appropriate events upon closure of that parent window or termination of that AP process; otherwise it could ""poll"" to check if the window or process are still around.",0.2012947653214861,False,1,286 @@ -3381,9 +3381,9 @@ If there is not a version, what would it take to upgrade it to work on Python 3. Note: I've run 2to3 on the Werkzeug source code, and it does python-compile without Edit: The project that we are starting is not slated to be finished until nearly a year from now. At which point, I'm guessing Python 3.X will be a lot more mainstream. Furthermore, considering that we are running the App (not distributing it), can anyone comment on the viability of bashing through some of the Python 3 issues now, so that when a year from now arrives, we are more-or-less already there? -Thoughts appreciated!","I can only answer question one: -I started using it for some small webstuff but now moved on to rework larger apps with it. Why Werkzeug? The modular concept is really helpful. You can hook in modules as you like, make stuff easily context aware and you get good request file handling for free which is able to cope with 300mb+ files by not storing it in memory. -Disadvantages... Well sometimes modularity needs some upfront thought (django f.ex. gives you everything all at once, stripping stuff out is hard to do there though) but for me it works fine.",0.1352210990936997,False,3,287 +Thoughts appreciated!","I haven't used Werkzeug, so I can only answer question 2: +No, Werkzeug does not work on Python 3. In fact, very little works on Python 3 as of today. Porting is not difficult, but you can't port until all your third-party libraries have been ported, so progress is slow. +One big stopper has been setuptools, which is a very popular package to use. Setuptools is unmaintained, but there is a maintained fork called Distribute. Distribute was released with Python 3 support just a week or two ago. I hope package support for Python 3 will pick up now. But it will still be a long time, at least months probably a year or so, before any major project like Werkzeug will be ported to Python 3.",0.1352210990936997,False,3,287 2009-10-06 05:13:48.790,"Werkzeug in General, and in Python 3.1","I've been looking really hard at all of the way**(s)** one can develop web applications using Python. For reference, we are using RHEL 64bit, apache, mod_wsgi. History: @@ -3401,11 +3401,11 @@ If there is not a version, what would it take to upgrade it to work on Python 3. Note: I've run 2to3 on the Werkzeug source code, and it does python-compile without Edit: The project that we are starting is not slated to be finished until nearly a year from now. At which point, I'm guessing Python 3.X will be a lot more mainstream. Furthermore, considering that we are running the App (not distributing it), can anyone comment on the viability of bashing through some of the Python 3 issues now, so that when a year from now arrives, we are more-or-less already there? -Thoughts appreciated!","I haven't used Werkzeug, so I can only answer question 2: -No, Werkzeug does not work on Python 3. In fact, very little works on Python 3 as of today. Porting is not difficult, but you can't port until all your third-party libraries have been ported, so progress is slow. -One big stopper has been setuptools, which is a very popular package to use. Setuptools is unmaintained, but there is a maintained fork called Distribute. Distribute was released with Python 3 support just a week or two ago. I hope package support for Python 3 will pick up now. But it will still be a long time, at least months probably a year or so, before any major project like Werkzeug will be ported to Python 3.",0.1352210990936997,False,3,287 -2009-10-06 10:15:14.313,How do I display images at different times on webpage,"I'm supposed to display images at certain times of the day on the webpage, Please can anyone tell me how to go about it","You could make a Date object in javascript. Check the current time and depending on the time, you set the img src to whatever image you want for that time of day :) or hide the image through myimg.style.visibility = ""hidden"" if you dont want to display an image at that moment.",0.0,False,2,288 +Thoughts appreciated!","I can only answer question one: +I started using it for some small webstuff but now moved on to rework larger apps with it. Why Werkzeug? The modular concept is really helpful. You can hook in modules as you like, make stuff easily context aware and you get good request file handling for free which is able to cope with 300mb+ files by not storing it in memory. +Disadvantages... Well sometimes modularity needs some upfront thought (django f.ex. gives you everything all at once, stripping stuff out is hard to do there though) but for me it works fine.",0.1352210990936997,False,3,287 2009-10-06 10:15:14.313,How do I display images at different times on webpage,"I'm supposed to display images at certain times of the day on the webpage, Please can anyone tell me how to go about it","If you need to change the image before a page refresh, you could use jquery ajax call to get the correct image. jquery has some interval functionality which would allow this.",0.0,False,2,288 +2009-10-06 10:15:14.313,How do I display images at different times on webpage,"I'm supposed to display images at certain times of the day on the webpage, Please can anyone tell me how to go about it","You could make a Date object in javascript. Check the current time and depending on the time, you set the img src to whatever image you want for that time of day :) or hide the image through myimg.style.visibility = ""hidden"" if you dont want to display an image at that moment.",0.0,False,2,288 2009-10-07 05:07:44.390,how to create new file using python,"how can i create new file in /var/log directory using python language in OSX leopard? i tried to do it using os.open function but i get ""permission denied"" thanks in advance",It probably failed because /var/log has user set to root and group set to wheel. Try running your python code as root and it will probably work.,0.1352210990936997,False,1,289 2009-10-07 06:41:49.477,Debugging a scripting language like ruby,"I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python. @@ -3417,24 +3417,6 @@ Comment everything but the portion I want to check Execute the script -Though it works, I am not able to debug like how I would do in, say, a VC++ environment or something like that. -My question is, is there any better way of debugging? -Note: I guess it may be a repeated question, if so, please point me to the 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. -Even 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. -Of 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: - -Start small. Don't write large programs and test them. Test each function as you write it, at least cursorily. -Use 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. -Debuggers 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.",0.0,False,4,290 -2009-10-07 06:41:49.477,Debugging a scripting language like ruby,"I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python. -I am wondering how to do debugging. -At present the steps I follow is, - -I complete a large script, -Comment everything but the portion I -want to check -Execute the script - Though it works, I am not able to debug like how I would do in, say, a VC++ environment or something like that. My question is, is there any better way of debugging? Note: I guess it may be a repeated question, if so, please point me to the answer.","My question is, is there any better way of debugging?"" @@ -3468,7 +3450,13 @@ Execute the script Though it works, I am not able to debug like how I would do in, say, a VC++ environment or something like that. My question is, is there any better way of debugging? -Note: I guess it may be a repeated question, if so, please point me to the 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.",0.0740755660660223,False,4,290 +Note: I guess it may be a repeated question, if so, please point me to the 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. +Even 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. +Of 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: + +Start small. Don't write large programs and test them. Test each function as you write it, at least cursorily. +Use 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. +Debuggers 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.",0.0,False,4,290 2009-10-07 06:41:49.477,Debugging a scripting language like ruby,"I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python. I am wondering how to do debugging. At present the steps I follow is, @@ -3488,6 +3476,18 @@ I review what I'd done to document and publish. Specifically, I execute before I complete. It's way too late by then. There are debuggers, of course, but with good tests and good design, I've almost never needed one.",1.2,True,4,290 +2009-10-07 06:41:49.477,Debugging a scripting language like ruby,"I am basically from the world of C language programming, now delving into the world of scripting languages like Ruby and Python. +I am wondering how to do debugging. +At present the steps I follow is, + +I complete a large script, +Comment everything but the portion I +want to check +Execute the script + +Though it works, I am not able to debug like how I would do in, say, a VC++ environment or something like that. +My question is, is there any better way of debugging? +Note: I guess it may be a repeated question, if so, please point me to the 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.",0.0740755660660223,False,4,290 2009-10-07 11:08:36.103,Incrementally building a numpy array and measuring memory usage,"I have a series of large text files (up to 1 gig) that are output from an experiment that need to be analysed in Python. They would be best loaded into a 2D numpy array, which presents the first question: As the number of rows is unknown at the beginning of the loading, how can @@ -3518,10 +3518,16 @@ my questions are: is there a way to make crc works on large file? i prefer to use crc than md5 if 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? -PS: 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.","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). -However, 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). -As 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. -It sounds like you're trying to do something very similar to what the rsync utility does. Can you just use rsync?",0.2012947653214861,False,5,293 +PS: 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.","It's an algorithm selection problem, rather than a library/language selection problem! +There appears to be two points to consider primarily: + +how much would the disk I/O affect the overall performance? +what is the expected reliability of the error detection feature? + +Apparently, 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. +Assuming 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. +The 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. +Side 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..)",0.3275988531455109,False,5,293 2009-10-07 16:28:08.397,the fastest way to create checksum for large files in python,"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. somehow 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. my questions are: @@ -3529,7 +3535,8 @@ my questions are: is there a way to make crc works on large file? i prefer to use crc than md5 if 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? -PS: 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.","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.",0.1352210990936997,False,5,293 +PS: 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.","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. +The 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.",0.0679224682270276,False,5,293 2009-10-07 16:28:08.397,the fastest way to create checksum for large files in python,"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. somehow 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. my questions are: @@ -3548,8 +3555,7 @@ my questions are: is there a way to make crc works on large file? i prefer to use crc than md5 if 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? -PS: 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.","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. -The 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.",0.0679224682270276,False,5,293 +PS: 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.","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.",0.1352210990936997,False,5,293 2009-10-07 16:28:08.397,the fastest way to create checksum for large files in python,"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. somehow 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. my questions are: @@ -3557,16 +3563,10 @@ my questions are: is there a way to make crc works on large file? i prefer to use crc than md5 if 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? -PS: 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.","It's an algorithm selection problem, rather than a library/language selection problem! -There appears to be two points to consider primarily: - -how much would the disk I/O affect the overall performance? -what is the expected reliability of the error detection feature? - -Apparently, 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. -Assuming 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. -The 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. -Side 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..)",0.3275988531455109,False,5,293 +PS: 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.","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). +However, 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). +As 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. +It sounds like you're trying to do something very similar to what the rsync utility does. Can you just use rsync?",0.2012947653214861,False,5,293 2009-10-07 20:40:37.623,Python: how to show results on a web page?,"Most likely it's a dumb question for those who knows the answer, but I'm a beginner, and here it goes: I have a Python script which I run in a command-line with some parameter, and it prints me some results. Let's say results are some HTML code. I never done any Python programming for web, and couldn't figure it out... I need to have a page (OK, I know how to upload files to a server, Apache is running, Python is installed on the server...) with an edit field, which will accept that parameter, and Submit button, and I need it to ""print"" the results on a web page after the user submitted a proper parameter, or show any output that in a command-line situation are printed. @@ -3579,13 +3579,6 @@ So, find out how use of Python for web applications is supported and work out wh 2009-10-08 15:36:25.743,How to sort all possible words out of a string?,"I'm wondering how to proceed with this task, take this string for example ""thingsandstuff"". How could I generate all possible strings out of this string as to look them up individually against an english dictionary? The goal is to find valid english words in a string that does not contain space. -Thanks","The brute force approach, i.e. checking every substring, is computationally unfeasible even for strings of middling lengths (a string of length N has O(N**2) substrings). Unless there is a pretty tight bound on the length of strings you care about, that doesn't scale well. -To make things more feasible, more knowledge is required -- are you interested in overlapping words (eg 'things' and 'sand' in your example) and/or words which would leave unaccounted for characters (eg 'thing' and 'and' in your example, leaving the intermediate 's' stranded), or you do you want a strict partition of the string into juxtaposed (not overlapping) words with no residue? -The latter would be the simplest problem, because the degrees of freedom drop sharply -- essentially to trying to determine a sequence of ""breaking points"", each between two adjacent characters, that would split the string into words. If that's the case, do you need every possible valid split (i.e. do you need both ""thing sand"" and ""things and""), or will any single valid split do, or are there criteria that your split must optimize? -If you clarify all of these issues it may be possible to give you more help!",0.1108597247651115,False,3,295 -2009-10-08 15:36:25.743,How to sort all possible words out of a string?,"I'm wondering how to proceed with this task, take this string for example ""thingsandstuff"". -How could I generate all possible strings out of this string as to look them up individually against an english dictionary? -The goal is to find valid english words in a string that does not contain space. Thanks","Well here is my idea Find all possible strings containing 1 character from the original @@ -3596,6 +3589,13 @@ Then add all up and go match with your dictionary",0.0,False,3,295 2009-10-08 15:36:25.743,How to sort all possible words out of a string?,"I'm wondering how to proceed with this task, take this string for example ""thingsandstuff"". How could I generate all possible strings out of this string as to look them up individually against an english dictionary? The goal is to find valid english words in a string that does not contain space. +Thanks","The brute force approach, i.e. checking every substring, is computationally unfeasible even for strings of middling lengths (a string of length N has O(N**2) substrings). Unless there is a pretty tight bound on the length of strings you care about, that doesn't scale well. +To make things more feasible, more knowledge is required -- are you interested in overlapping words (eg 'things' and 'sand' in your example) and/or words which would leave unaccounted for characters (eg 'thing' and 'and' in your example, leaving the intermediate 's' stranded), or you do you want a strict partition of the string into juxtaposed (not overlapping) words with no residue? +The latter would be the simplest problem, because the degrees of freedom drop sharply -- essentially to trying to determine a sequence of ""breaking points"", each between two adjacent characters, that would split the string into words. If that's the case, do you need every possible valid split (i.e. do you need both ""thing sand"" and ""things and""), or will any single valid split do, or are there criteria that your split must optimize? +If you clarify all of these issues it may be possible to give you more help!",0.1108597247651115,False,3,295 +2009-10-08 15:36:25.743,How to sort all possible words out of a string?,"I'm wondering how to proceed with this task, take this string for example ""thingsandstuff"". +How could I generate all possible strings out of this string as to look them up individually against an english dictionary? +The goal is to find valid english words in a string that does not contain space. Thanks","What if you break it up into syllables and then use those to construct words to compare to your dictionary. It's still a brute force method, but it would surely speed things up a bit.",0.0,False,3,295 2009-10-09 04:24:03.590,Upgrade Python to 2.6 on Mac,"I'd like to upgrade the default python installation (2.5.1) supplied with OS X Leopard to the latest version. Please let me know how I can achieve this. Thanks","May I suggest you leave the ""Default"" be, and install Python in /usr/local/bin. @@ -3613,13 +3613,13 @@ Thanks","When an OS is distributed with some specific Python release and uses it Rather, as other answers already suggested, install any other release you wish ""besides"" the system one -- why tamper with that crucial one, and risk breaking things, when installing others is so easy anyway?! On typical Mac OS X 10.5 machines (haven't upgraded any of my several macs to 10.6 yet), I have the Apple-supplied 2.5, a 2.4 on the side to support some old projects not worth the bother to upgrate, the latest 2.6 for new stuff, 3.1 as well to get the very newest -- they all live together in peace and quiet, I just type the release number explicitly, i.e. using python2.6 at the prompt, when I want a specific release. What release gets used when at the shell prompt you just say python is up to you (I personally prefer that to mean ""the system-supplied Python"", but it's a matter of taste: by setting paths, or shell aliases, &c, you can make it mean whatever you wish).",0.993424677228132,False,2,296 2009-10-10 17:56:09.687,Python for C++ or Java Programmer,"I have a background in C++ and Java and Objective C programming, but i am finding it hard to learn python, basically where its ""Main Function"" or from where the program start executing. So is there any tutorial/book which can teach python to people who have background in C++ or Java. Basically something which can show if how you were doing this in C++ and how this is done in Python. OK i think i did not put the question heading or question right, basically i was confused about the ""Main"" Function, otherwise other things are quite obvious from python official documentation except this concept. +Thanks to all",The pithiest comment I guess is that the entry point is the 1st line of your script that is not a function or a class. You don't necessarily need to use the if hack unless you want to and your script is meant to be imported.,0.0,False,2,297 +2009-10-10 17:56:09.687,Python for C++ or Java Programmer,"I have a background in C++ and Java and Objective C programming, but i am finding it hard to learn python, basically where its ""Main Function"" or from where the program start executing. So is there any tutorial/book which can teach python to people who have background in C++ or Java. Basically something which can show if how you were doing this in C++ and how this is done in Python. +OK i think i did not put the question heading or question right, basically i was confused about the ""Main"" Function, otherwise other things are quite obvious from python official documentation except this concept. Thanks to all","I started Python over a year ago too, also C++ background. I've learned that everything is simpler in Python, you don't need to worry so much if you're doing it right, you probably are. Most of the things came natural. I can't say I've read a book or anything, I usually pested the guys in #python on freenode a lot and looked at lots of other great code out there. Good luck :)",0.0,False,2,297 -2009-10-10 17:56:09.687,Python for C++ or Java Programmer,"I have a background in C++ and Java and Objective C programming, but i am finding it hard to learn python, basically where its ""Main Function"" or from where the program start executing. So is there any tutorial/book which can teach python to people who have background in C++ or Java. Basically something which can show if how you were doing this in C++ and how this is done in Python. -OK i think i did not put the question heading or question right, basically i was confused about the ""Main"" Function, otherwise other things are quite obvious from python official documentation except this concept. -Thanks to all",The pithiest comment I guess is that the entry point is the 1st line of your script that is not a function or a class. You don't necessarily need to use the if hack unless you want to and your script is meant to be imported.,0.0,False,2,297 2009-10-12 07:06:48.173,Generate random directories/files given number of files and depth,"I'd like to profile some VCS software, and to do so I want to generate a set of random files, in randomly arranged directories. I'm writing the script in Python, but my question is briefly: how do I generate a random directory tree with an average number of sub-directories per directory and some broad distribution of files per directory? Clarification: I'm not comparing different VCS repo formats (eg. SVN vs Git vs Hg), but profiling software that deals with SVN (and eventually other) working copies and repos. The constraints I'd like are to specify the total number of files (call it 'N', probably ~10k-100k) and the maximum depth of the directory structure ('L', probably 2-10). I don't care how many directories are generated at each level, and I don't want to end up with 1 file per dir, or 100k all in one dir. @@ -3658,14 +3658,7 @@ Write executables (in Perl) that mimic function calls; invoke those Perl executa Write Perl executables on-the-fly inside the Python dashboard, and invoke the (temporary) Perl executable. Find some kind of Perl-to-Python converter or binding. -Any 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.","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: - -Document 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. -Implement the services in Perl, possibly using Catalyst::Controller::SOAP, or just XML::Compile::SOAP. -Consume the services from your whatever-language GUI interface. -Profit. - -But 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.",0.1016881243684853,False,3,300 +Any 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.",Interesting project: I would opt for loose-coupling and consider an XML-RPC or JSON based approach.,0.0509761841073563,False,3,300 2009-10-12 20:22:08.483,Recommendations for perl-to-python interoperation?,"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. So... any suggestions on how achieve this? We are considering a few options: @@ -3688,14 +3681,23 @@ Write executables (in Perl) that mimic function calls; invoke those Perl executa Write Perl executables on-the-fly inside the Python dashboard, and invoke the (temporary) Perl executable. Find some kind of Perl-to-Python converter or binding. -Any 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.",Interesting project: I would opt for loose-coupling and consider an XML-RPC or JSON based approach.,0.0509761841073563,False,3,300 +Any 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.","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: + +Document 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. +Implement the services in Perl, possibly using Catalyst::Controller::SOAP, or just XML::Compile::SOAP. +Consume the services from your whatever-language GUI interface. +Profit. + +But 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.",0.1016881243684853,False,3,300 2009-10-15 05:13:02.970,Create a user-group in linux using python,"I want to create a user group using python on CentOS system. When I say 'using python' I mean I don't want to do something like os.system and give the unix command to create a new group. I would like to know if there is any python module that deals with this. Searching on the net did not reveal much about what I want, except for python user groups.. so I had to ask this. I learned about the grp module by searching here on SO, but couldn't find anything about creating a group. EDIT: I dont know if I have to start a new question for this, but I would also like to know how to add (existing) users to the newly created group. Any help appreciated. -Thank you.","I think you should use the commandline programs from your program, a lot of care has gone into making sure that they don't break the groups file if something goes wrong. -However the file format is quite straight forward to write something yourself if you choose to go that way",0.4701041941942874,False,3,301 +Thank you.","There are no library calls for creating a group. This is because there's really no such thing as creating a group. A GID is simply a number assigned to a process or a file. All these numbers exist already - there is nothing you need to do to start using a GID. With the appropriate privileges, you can call chown(2) to set the GID of a file to any number, or setgid(2) to set the GID of the current process (there's a little more to it than that, with effective IDs, supplementary IDs, etc). +Giving a name to a GID is done by an entry in /etc/group on basic Unix/Linux/POSIX systems, but that's really just a convention adhered to by the Unix/Linux/POSIX userland tools. Other network-based directories also exist, as mentioned by Jack Lloyd. +The man page group(5) describes the format of the /etc/group file, but it is not recommended that you write to it directly. Your distribution will have policies on how unnamed GIDs are allocated, such as reserving certain spaces for different purposes (fixed system groups, dynamic system groups, user groups, etc). The range of these number spaces differs on different distributions. These policies are usually encoded in the command-line tools that a sysadmin uses to assign unnamed GIDs. +This means the best way to add a group locally is to use the command-line tools.",0.1016881243684853,False,3,301 2009-10-15 05:13:02.970,Create a user-group in linux using python,"I want to create a user group using python on CentOS system. When I say 'using python' I mean I don't want to do something like os.system and give the unix command to create a new group. I would like to know if there is any python module that deals with this. Searching on the net did not reveal much about what I want, except for python user groups.. so I had to ask this. I learned about the grp module by searching here on SO, but couldn't find anything about creating a group. @@ -3716,21 +3718,19 @@ Searching on the net did not reveal much about what I want, except for python us I learned about the grp module by searching here on SO, but couldn't find anything about creating a group. EDIT: I dont know if I have to start a new question for this, but I would also like to know how to add (existing) users to the newly created group. Any help appreciated. -Thank you.","There are no library calls for creating a group. This is because there's really no such thing as creating a group. A GID is simply a number assigned to a process or a file. All these numbers exist already - there is nothing you need to do to start using a GID. With the appropriate privileges, you can call chown(2) to set the GID of a file to any number, or setgid(2) to set the GID of the current process (there's a little more to it than that, with effective IDs, supplementary IDs, etc). -Giving a name to a GID is done by an entry in /etc/group on basic Unix/Linux/POSIX systems, but that's really just a convention adhered to by the Unix/Linux/POSIX userland tools. Other network-based directories also exist, as mentioned by Jack Lloyd. -The man page group(5) describes the format of the /etc/group file, but it is not recommended that you write to it directly. Your distribution will have policies on how unnamed GIDs are allocated, such as reserving certain spaces for different purposes (fixed system groups, dynamic system groups, user groups, etc). The range of these number spaces differs on different distributions. These policies are usually encoded in the command-line tools that a sysadmin uses to assign unnamed GIDs. -This means the best way to add a group locally is to use the command-line tools.",0.1016881243684853,False,3,301 +Thank you.","I think you should use the commandline programs from your program, a lot of care has gone into making sure that they don't break the groups file if something goes wrong. +However the file format is quite straight forward to write something yourself if you choose to go that way",0.4701041941942874,False,3,301 +2009-10-17 10:21:43.707,How check if a task is already in python Queue?,"I'm writing a simple crawler in Python using the threading and Queue modules. I fetch a page, check links and put them into a queue, when a certain thread has finished processing page, it grabs the next one from the queue. I'm using an array for the pages I've already visited to filter the links I add to the queue, but if there are more than one threads and they get the same links on different pages, they put duplicate links to the queue. So how can I find out whether some url is already in the queue to avoid putting it there again?",SQLite is so simple to use and would fit perfectly... just a suggestion.,0.0313868613919487,False,5,302 2009-10-17 10:21:43.707,How check if a task is already in python Queue?,"I'm writing a simple crawler in Python using the threading and Queue modules. I fetch a page, check links and put them into a queue, when a certain thread has finished processing page, it grabs the next one from the queue. I'm using an array for the pages I've already visited to filter the links I add to the queue, but if there are more than one threads and they get the same links on different pages, they put duplicate links to the queue. So how can I find out whether some url is already in the queue to avoid putting it there again?","The way I solved this (actually I did this in Scala, not Python) was to use both a Set and a Queue, only adding links to the queue (and set) if they did not already exist in the set. Both the set and queue were encapsulated in a single thread, exposing only a queue-like interface to the consumer threads. Edit: someone else suggested SQLite and that is also something I am considering, if the set of visited URLs needs to grow large. (Currently each crawl is only a few hundred pages so it easily fits in memory.) But the database is something that can also be encapsulated within the set itself, so the consumer threads need not be aware of it.",0.0313868613919487,False,5,302 -2009-10-17 10:21:43.707,How check if a task is already in python Queue?,"I'm writing a simple crawler in Python using the threading and Queue modules. I fetch a page, check links and put them into a queue, when a certain thread has finished processing page, it grabs the next one from the queue. I'm using an array for the pages I've already visited to filter the links I add to the queue, but if there are more than one threads and they get the same links on different pages, they put duplicate links to the queue. So how can I find out whether some url is already in the queue to avoid putting it there again?",SQLite is so simple to use and would fit perfectly... just a suggestion.,0.0313868613919487,False,5,302 -2009-10-17 10:21:43.707,How check if a task is already in python Queue?,"I'm writing a simple crawler in Python using the threading and Queue modules. I fetch a page, check links and put them into a queue, when a certain thread has finished processing page, it grabs the next one from the queue. I'm using an array for the pages I've already visited to filter the links I add to the queue, but if there are more than one threads and they get the same links on different pages, they put duplicate links to the queue. So how can I find out whether some url is already in the queue to avoid putting it there again?","Also, instead of a set you might try using a dictionary. Operations on sets tend to get rather slow when they're big, whereas a dictionary lookup is nice and quick. -My 2c.",-0.0939139506950562,False,5,302 2009-10-17 10:21:43.707,How check if a task is already in python Queue?,"I'm writing a simple crawler in Python using the threading and Queue modules. I fetch a page, check links and put them into a queue, when a certain thread has finished processing page, it grabs the next one from the queue. I'm using an array for the pages I've already visited to filter the links I add to the queue, but if there are more than one threads and they get the same links on different pages, they put duplicate links to the queue. So how can I find out whether some url is already in the queue to avoid putting it there again?","Why only use the array (ideally, a dictionary would be even better) to filter things you've already visited? Add things to your array/dictionary as soon as you queue them up, and only add them to the queue if they're not already in the array/dict. Then you have 3 simple separate things: Links not yet seen (neither in queue nor array/dict) Links scheduled to be visited (in both queue and array/dict) Links already visited (in array/dict, not in queue)",0.0313868613919487,False,5,302 +2009-10-17 10:21:43.707,How check if a task is already in python Queue?,"I'm writing a simple crawler in Python using the threading and Queue modules. I fetch a page, check links and put them into a queue, when a certain thread has finished processing page, it grabs the next one from the queue. I'm using an array for the pages I've already visited to filter the links I add to the queue, but if there are more than one threads and they get the same links on different pages, they put duplicate links to the queue. So how can I find out whether some url is already in the queue to avoid putting it there again?","Also, instead of a set you might try using a dictionary. Operations on sets tend to get rather slow when they're big, whereas a dictionary lookup is nice and quick. +My 2c.",-0.0939139506950562,False,5,302 2009-10-17 10:21:43.707,How check if a task is already in python Queue?,"I'm writing a simple crawler in Python using the threading and Queue modules. I fetch a page, check links and put them into a queue, when a certain thread has finished processing page, it grabs the next one from the queue. I'm using an array for the pages I've already visited to filter the links I add to the queue, but if there are more than one threads and they get the same links on different pages, they put duplicate links to the queue. So how can I find out whether some url is already in the queue to avoid putting it there again?","instead of ""array of pages already visited"" make an ""array of pages already added to the queue""",0.0,False,5,302 2009-10-18 20:56:01.813,"PHP, Python, Ruby application with multiple RDBMS","I start feeling old fashioned when I see all these SQL generating database abstraction layers and all those ORMs out there, although I am far from being old. I understand the need for them, but their use spreads to places they normally don't belong to. I firmly believe that using database abstraction layers for SQL generation is not the right way of writing database applications that should run on multiple database engines, especially when you throw in really expensive databases like Oracle. And this is more or less global, it doesn't apply to only a few languages. @@ -3738,7 +3738,12 @@ Just a simple example, using query pagination and insertion: when using Oracle o By using only a limited set of features, commonly available to many RDBMS one doesn't exploit the possibilities that those expensive and advanced database engines have to offers. So getting back to the heart of the question: how do you develop PHP, Python, Ruby etc. applications that should run on multiple database engines? I am especially interested hearing how you separate/use the queries that are especially written for running on a single RDBMS. Say you've got a statement that should run on 3 RDBMS: Oracle, DB2 and Sql Server and for each of these you write a separate SQL statement in order to make use of all features this RDBMS has to offer. How do you do it? -Letting this aside, what is you opinion walking this path? Is it worth it in your experience? Why? Why not?","It would be great if code written for one platform would work on every other without any modification whatsoever, but this is usually not the case and probably never will be. What the current frameworks do is about all anyone can.",0.0,False,3,303 +Letting this aside, what is you opinion walking this path? Is it worth it in your experience? Why? Why not?","You cannot eat a cake and have it, choose on of the following options. + +Use your database abstraction layer whenever you can and in the rare cases when you have a need for a hand-made query (eg. performance reasons) stick to the lowest common denominator and don't use stored procedures or any proprietary extensions that you database has to offer. In this case deploying the application on a different RDBMS should be trivial. +Use the full power of your expensive RDBMS, but take into account that your application won't be easily portable. When the need arises you will have to spend considerable effort on porting and maintenance. Of course a decent layered design encapsulating all the differences in a single module or class will help in this endeavor. + +In other words you should consider how probable is it that your application will be deployed to multiple RDBMSes and make an informed choice.",1.2,True,3,303 2009-10-18 20:56:01.813,"PHP, Python, Ruby application with multiple RDBMS","I start feeling old fashioned when I see all these SQL generating database abstraction layers and all those ORMs out there, although I am far from being old. I understand the need for them, but their use spreads to places they normally don't belong to. I firmly believe that using database abstraction layers for SQL generation is not the right way of writing database applications that should run on multiple database engines, especially when you throw in really expensive databases like Oracle. And this is more or less global, it doesn't apply to only a few languages. Just a simple example, using query pagination and insertion: when using Oracle one could use the FIRST_ROWS and APPEND hints(where appropriate). Going to advanced examples I could mention putting in the database lots of Stored Procedures/Packages where it makes sense. And those are different for every RDBMS. @@ -3755,12 +3760,7 @@ Just a simple example, using query pagination and insertion: when using Oracle o By using only a limited set of features, commonly available to many RDBMS one doesn't exploit the possibilities that those expensive and advanced database engines have to offers. So getting back to the heart of the question: how do you develop PHP, Python, Ruby etc. applications that should run on multiple database engines? I am especially interested hearing how you separate/use the queries that are especially written for running on a single RDBMS. Say you've got a statement that should run on 3 RDBMS: Oracle, DB2 and Sql Server and for each of these you write a separate SQL statement in order to make use of all features this RDBMS has to offer. How do you do it? -Letting this aside, what is you opinion walking this path? Is it worth it in your experience? Why? Why not?","You cannot eat a cake and have it, choose on of the following options. - -Use your database abstraction layer whenever you can and in the rare cases when you have a need for a hand-made query (eg. performance reasons) stick to the lowest common denominator and don't use stored procedures or any proprietary extensions that you database has to offer. In this case deploying the application on a different RDBMS should be trivial. -Use the full power of your expensive RDBMS, but take into account that your application won't be easily portable. When the need arises you will have to spend considerable effort on porting and maintenance. Of course a decent layered design encapsulating all the differences in a single module or class will help in this endeavor. - -In other words you should consider how probable is it that your application will be deployed to multiple RDBMSes and make an informed choice.",1.2,True,3,303 +Letting this aside, what is you opinion walking this path? Is it worth it in your experience? Why? Why not?","It would be great if code written for one platform would work on every other without any modification whatsoever, but this is usually not the case and probably never will be. What the current frameworks do is about all anyone can.",0.0,False,3,303 2009-10-19 10:42:57.790,Caching system for dynamically created files?,"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. Inputs: @@ -3806,23 +3806,6 @@ I then have functions at the account level (create-acct(), display-all-accts(), The user sees a list of accounts, then can choose an account and see the underlying transactions, with ability to add, delete, edit, etc. the accounts and transactions. I currently implement everything in one large class, so that I can use self.variable throughout, rather than explicit globals. In short, I'm trying to figure out if re-organizing this into some classes would be useful and, if so, how to design those classes. I've read some oop books (most recently Object-Oriented Thought Process). I like to think my existing design is readable and does not repeat itself. -Any suggestions would be appreciated.","There are many 'mindsets' that you could adopt to help in the design process (some of which point towards OO and some that don't). I think it is often better to start with questions rather than answers (i.e. rather than say, 'how can I apply inheritance to this' you should ask how this system might expect to change over time). -Here's a few questions to answer that might point you towards design principles: - -Are other's going to use this API? Are they likely to break it? (info hiding) -do I need to deploy this across many machines? (state management, lifecycle management) -do i need to interoperate with other systems, runtimes, languages? (abstraction and standards) -what are my performance constraints? (state management, lifecycle management) -what kind of security environment does this component live in? (abstraction, info hiding, interoperability) -how would i construct my objects, assuming I used some? (configuration, inversion of control, object decoupling, hiding implementation details) - -These aren't direct answers to your question, but they might put you in the right frame of mind to answer it yourself. :)",0.0814518047658113,False,3,305 -2009-10-22 00:25:16.950,Object oriented design?,"I'm trying to learn object oriented programming, but am having a hard time overcoming my structured programming background (mainly C, but many others over time). I thought I'd write a simple check register program as an exercise. I put something together pretty quickly (python is a great language), with my data in some global variables and with a bunch of functions. I can't figure out if this design can be improved by creating a number of classes to encapsulate some of the data and functions and, if so, how to change the design. -My data is basically a list of accounts ['checking', 'saving', 'Amex'], a list of categories ['food', 'shelter', 'transportation'] and lists of dicts that represent transactions [{'date':xyz, 'cat':xyz, 'amount':xyz, 'description':xzy]. Each account has an associated list of dicts. -I then have functions at the account level (create-acct(), display-all-accts(), etc.) and the transaction level (display-entries-in-account(), enter-a-transaction(), edit-a-transaction(), display-entries-between-dates(), etc.) -The user sees a list of accounts, then can choose an account and see the underlying transactions, with ability to add, delete, edit, etc. the accounts and transactions. -I currently implement everything in one large class, so that I can use self.variable throughout, rather than explicit globals. -In short, I'm trying to figure out if re-organizing this into some classes would be useful and, if so, how to design those classes. I've read some oop books (most recently Object-Oriented Thought Process). I like to think my existing design is readable and does not repeat itself. Any suggestions would be appreciated.","You don't have to throw out structured programming to do object-oriented programming. The code is still structured, it just belongs to the objects rather than being separate from them. In classical programming, code is the driving force that operates on data, leading to a dichotomy (and the possibility that code can operate on the wrong data). In OO, data and code are inextricably entwined - an object contains both data and the code to operate on that data (although technically the code (and sometimes some data) belongs to the class rather than an individual object). Any client code that wants to use those objects should do so only by using the code within that object. This prevents the code/data mismatch problem. @@ -3835,6 +3818,23 @@ The overall accounting ""object"" (the ledger) is then simply the list of all ac Keep in mind that this is the ""back-end"" of the system (the data model). You will hopefully have separate classes for viewing the data (the view) which will allow you to easily change it, depending on user preferences. For example, you may want the whole ledger, just the balance sheet or just the P&L. Or you may want different date ranges. One thing I'd stress to make a good accounting system. You do need to think like a bookkeeper. By that I mean lose the artificial difference between ""accounts"" and ""categories"" since it will make your system a lot cleaner (you need to be able to have transactions between two asset-class accounts (such as a bank transfer) and this won't work if every transaction needs a ""category"". The data model should reflect the data, not the view. The only difficulty there is remembering that asset-class accounts have the opposite sign from which you expect (negative values for your cash-at-bank mean you have money in the bank and your very high positive value loan for that company sports car is a debt, for example). This will make the double-entry aspect work perfectly but you have to remember to reverse the signs of asset-class accounts (assets, liabilities and equity) when showing or printing the balance sheet.",0.5164076551851798,False,3,305 +2009-10-22 00:25:16.950,Object oriented design?,"I'm trying to learn object oriented programming, but am having a hard time overcoming my structured programming background (mainly C, but many others over time). I thought I'd write a simple check register program as an exercise. I put something together pretty quickly (python is a great language), with my data in some global variables and with a bunch of functions. I can't figure out if this design can be improved by creating a number of classes to encapsulate some of the data and functions and, if so, how to change the design. +My data is basically a list of accounts ['checking', 'saving', 'Amex'], a list of categories ['food', 'shelter', 'transportation'] and lists of dicts that represent transactions [{'date':xyz, 'cat':xyz, 'amount':xyz, 'description':xzy]. Each account has an associated list of dicts. +I then have functions at the account level (create-acct(), display-all-accts(), etc.) and the transaction level (display-entries-in-account(), enter-a-transaction(), edit-a-transaction(), display-entries-between-dates(), etc.) +The user sees a list of accounts, then can choose an account and see the underlying transactions, with ability to add, delete, edit, etc. the accounts and transactions. +I currently implement everything in one large class, so that I can use self.variable throughout, rather than explicit globals. +In short, I'm trying to figure out if re-organizing this into some classes would be useful and, if so, how to design those classes. I've read some oop books (most recently Object-Oriented Thought Process). I like to think my existing design is readable and does not repeat itself. +Any suggestions would be appreciated.","There are many 'mindsets' that you could adopt to help in the design process (some of which point towards OO and some that don't). I think it is often better to start with questions rather than answers (i.e. rather than say, 'how can I apply inheritance to this' you should ask how this system might expect to change over time). +Here's a few questions to answer that might point you towards design principles: + +Are other's going to use this API? Are they likely to break it? (info hiding) +do I need to deploy this across many machines? (state management, lifecycle management) +do i need to interoperate with other systems, runtimes, languages? (abstraction and standards) +what are my performance constraints? (state management, lifecycle management) +what kind of security environment does this component live in? (abstraction, info hiding, interoperability) +how would i construct my objects, assuming I used some? (configuration, inversion of control, object decoupling, hiding implementation details) + +These aren't direct answers to your question, but they might put you in the right frame of mind to answer it yourself. :)",0.0814518047658113,False,3,305 2009-10-22 03:06:24.590,How to get output?,"I am using the Python/C API with my app and am wondering how you can get console output with a gui app. When there is a script error, it is displayed via printf but this obviously has no effect with a gui app. I want to be able to obtain the output without creating a console. Can this be done? Edit - Im using Windows, btw. Edit - The Python/C library internally calls printf and does so before any script can be loaded and run. If there is an error I want to be able to get it.","If by printf you mean exactly thqt call from C code, you need to redirect (and un-buffer) your standard output (file descriptor 0) to somewhere you can pick up the data from -- far from trivial, esp. in Windows, although maybe doable. But why not just change that call in your C code to something more sensible? (Worst case, a geprintf function of your own devising that mimics printf to build a string then directs that string appropriately). @@ -3843,14 +3843,14 @@ If you actually mean print statements in Python code, it's much easier -- just s I am using the PyDev plugin under Eclipse, and basically all I want to find out is, is it possible to edit code whilst you're sitting at a breakpoint? I.e. Edit code whilst you're debugging. It allows me to do this at present, but it seems to still be executing the line of code that previously existed before I made changes. Also, are you able to drag program execution back like you can in VBA and C# for example? -If either of these are possible, how can I enable them?","When you start a Python program, it will be compiled into bytecode (and possibly saved as .pyc file). That means you can change the source but since you don't ""open"" the source again, the change won't be picked up. -There are systems like TurboGears (a web framework) which detect these changes and restart themselves but that's probably going to confuse the debugger. -Going back in time also isn't possible currently since the bytecode interpreter would need support for this.",0.2655860252697744,False,2,307 +If either of these are possible, how can I enable them?","You can run arbitrary commands in the console during the breakpoint. For my needs, this typically achieves the same purpose as coding live, although I do wish it were as elegant as simply using the editor.",0.2655860252697744,False,2,307 2009-10-23 14:41:46.160,Python Debugging: code editing on the fly,"I am new to python and haven't been able to find out whether this is possible or not. I am using the PyDev plugin under Eclipse, and basically all I want to find out is, is it possible to edit code whilst you're sitting at a breakpoint? I.e. Edit code whilst you're debugging. It allows me to do this at present, but it seems to still be executing the line of code that previously existed before I made changes. Also, are you able to drag program execution back like you can in VBA and C# for example? -If either of these are possible, how can I enable them?","You can run arbitrary commands in the console during the breakpoint. For my needs, this typically achieves the same purpose as coding live, although I do wish it were as elegant as simply using the editor.",0.2655860252697744,False,2,307 +If either of these are possible, how can I enable them?","When you start a Python program, it will be compiled into bytecode (and possibly saved as .pyc file). That means you can change the source but since you don't ""open"" the source again, the change won't be picked up. +There are systems like TurboGears (a web framework) which detect these changes and restart themselves but that's probably going to confuse the debugger. +Going back in time also isn't possible currently since the bytecode interpreter would need support for this.",0.2655860252697744,False,2,307 2009-10-23 15:24:32.580,How do I add text describing the code into a Python source file?,"When writing code in Python, how can you write something next to it that explains what the code is doing, but which doesn't affect the code?",Write a comment? Python comments start with #.,0.2655860252697744,False,1,308 2009-10-26 02:52:45.483,wx python card game,"I know python and I'm a newibe with wx python but I would like to make a card game. However I have no idea how to make a image follow the mouse and put it in the middle of the screen when the program running. It will be nice if you guys can help me out.","Going through the wxPython demo and looking at all the examples would be a good start. You'll likely find page Using Images | DragImage to be useful, since you'll probably want cards that you can drag. @@ -3891,9 +3891,12 @@ All processing is happening in Python: all the mdb file is doing is storing the All of the fields being inserted are valid fields (none are being excluded due to unique key violations, etc.) Given the above, I'll be looking into how to disable row level locking via odbc and considering presorting the data and/or removing then reinstating indexes. Thanks for the suggestions. -Any further suggestions still welcome.","Is your script executing a single INSERT statement per row of data? If so, pre-processing the data into a text file of many rows that could then be inserted with a single INSERT statement might improve the efficiency and cut down on the accumulating temporary crud that's causing it to bloat. -You might also make sure the INSERT is being executed without transactions. Whether or not that happens implicitly depends on the Jet version and the data interface library you're using to accomplish the task. By explicitly making sure it's off, you could improve the situation. -Another possibility is to drop the indexes before the insert, compact, run the insert, compact, re-instate the indexes, and run a final compact.",0.0679224682270276,False,4,313 +Any further suggestions still welcome.","A common trick, if feasible with regard to the schema and semantics of the application, is to have several MDB files with Linked tables. +Also, the way the insertions take place matters with regards to the way the file size balloons... For example: batched, vs. one/few records at a time, sorted (relative to particular index(es)), number of indexes (as you mentioned readily dropping some during the insert phase)... +Tentatively a pre-processing approach with say storing of new rows to a separate linked table, heap fashion (no indexes), then sorting/indexing this data is a minimal fashion, and ""bulk loading"" it to its real destination. Similar pre-processing in SQLite (has hinted in question) would serve the serve purpose. Keeping it ""ALL MDB"" is maybe easier (fewer languages/processes to learn, fewer inter-op issues [hopefuly ;-)]...) +EDIT: on why inserting records in a sorted/bulk fashion may slow down the MDB file's growth (question from Tony Toews) +One of the reasons for MDB files' propensity to grow more quickly than the rate at which text/data added to them (and their counterpart ability to be easily compacted back down) is that as information is added, some of the nodes that constitute the indexes have to be re-arranged (for overflowing / rebalancing etc.). Such management of the nodes seems to be implemented in a fashion which favors speed over disk space and harmony, and this approach typically serves simple applications / small data rather well. I do not know the specific logic in use for such management but I suspect that in several cases, node operations cause a particular node (or much of it) to be copied anew, and the old location simply being marked as free/unused but not deleted/compacted/reused. I do have ""clinical"" (if only a bit outdated) evidence that by performing inserts in bulk we essentially limit the number of opportunities for such duplication to occur and hence we slow the growth. +EDIT again: After reading and discussing things from Tony Toews and Albert Kallal it appears that a possibly more significant source of bloat, in particular in Jet Engine 4.0, is the way locking is implemented. It is therefore important to set the database in single user mode to avoid this. (Read Tony's and Albert's response for more details.",0.2012947653214861,False,4,313 2009-10-30 16:21:54.357,MS-Access Database getting very large during inserts,"I have a database which I regularly need to import large amounts of data into via some python scripts. Compacted, the data for a single months imports takes about 280mb, but during the import file size swells to over a gb. Given the 2gb size limit on mdb files, this is a bit of a concern. Apart from breaking the inserts into chunks and compacting inbetween each, are there any techniques for avoiding the increase in file size? Note that no temporary tables are being created/deleted during the process: just inserts into existing tables. @@ -3923,25 +3926,22 @@ All processing is happening in Python: all the mdb file is doing is storing the All of the fields being inserted are valid fields (none are being excluded due to unique key violations, etc.) Given the above, I'll be looking into how to disable row level locking via odbc and considering presorting the data and/or removing then reinstating indexes. Thanks for the suggestions. -Any further suggestions still welcome.","A common trick, if feasible with regard to the schema and semantics of the application, is to have several MDB files with Linked tables. -Also, the way the insertions take place matters with regards to the way the file size balloons... For example: batched, vs. one/few records at a time, sorted (relative to particular index(es)), number of indexes (as you mentioned readily dropping some during the insert phase)... -Tentatively a pre-processing approach with say storing of new rows to a separate linked table, heap fashion (no indexes), then sorting/indexing this data is a minimal fashion, and ""bulk loading"" it to its real destination. Similar pre-processing in SQLite (has hinted in question) would serve the serve purpose. Keeping it ""ALL MDB"" is maybe easier (fewer languages/processes to learn, fewer inter-op issues [hopefuly ;-)]...) -EDIT: on why inserting records in a sorted/bulk fashion may slow down the MDB file's growth (question from Tony Toews) -One of the reasons for MDB files' propensity to grow more quickly than the rate at which text/data added to them (and their counterpart ability to be easily compacted back down) is that as information is added, some of the nodes that constitute the indexes have to be re-arranged (for overflowing / rebalancing etc.). Such management of the nodes seems to be implemented in a fashion which favors speed over disk space and harmony, and this approach typically serves simple applications / small data rather well. I do not know the specific logic in use for such management but I suspect that in several cases, node operations cause a particular node (or much of it) to be copied anew, and the old location simply being marked as free/unused but not deleted/compacted/reused. I do have ""clinical"" (if only a bit outdated) evidence that by performing inserts in bulk we essentially limit the number of opportunities for such duplication to occur and hence we slow the growth. -EDIT again: After reading and discussing things from Tony Toews and Albert Kallal it appears that a possibly more significant source of bloat, in particular in Jet Engine 4.0, is the way locking is implemented. It is therefore important to set the database in single user mode to avoid this. (Read Tony's and Albert's response for more details.",0.2012947653214861,False,4,313 +Any further suggestions still welcome.","Is your script executing a single INSERT statement per row of data? If so, pre-processing the data into a text file of many rows that could then be inserted with a single INSERT statement might improve the efficiency and cut down on the accumulating temporary crud that's causing it to bloat. +You might also make sure the INSERT is being executed without transactions. Whether or not that happens implicitly depends on the Jet version and the data interface library you're using to accomplish the task. By explicitly making sure it's off, you could improve the situation. +Another possibility is to drop the indexes before the insert, compact, run the insert, compact, re-instate the indexes, and run a final compact.",0.0679224682270276,False,4,313 2009-11-01 10:48:38.313,How can a recursive regexp be implemented in python?,"I'm interested how can be implemented recursive regexp matching in Python (I've not found any examples :( ). For example how would one write expression which matches ""bracket balanced"" string like ""foo(bar(bar(foo)))(foo1)bar1""",You can't do it with a regexp. Python doesn't support recursive regexp,0.3153999413393242,False,1,314 -2009-11-03 10:27:04.573,What if setuptools isn't installed?,"I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?","I have used setuptools to compile many python scripts that I have written into windows EXEs. However, it has always been my understanding (from experience) that the computer running the compiled EXE does not need to have setup tools installed. -Hope that helps",0.1352210990936997,False,5,315 +2009-11-03 10:27:04.573,What if setuptools isn't installed?,"I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?","In most librarys I ever installed for python, a warning apears ""You have to install setuptools"". You could do it as well I think, you could add a link so the user don't have to search the internet for it.",0.1352210990936997,False,5,315 +2009-11-03 10:27:04.573,What if setuptools isn't installed?,"I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?",The standard way to distribute packages with setuptools includes an ez_setup.py script which will automatically download and install setuptools itself - on Windows I believe it will actually install an executable for easy_install. You can get this from the standard setuptools/easy_install distribution.,0.2655860252697744,False,5,315 +2009-11-03 10:27:04.573,What if setuptools isn't installed?,"I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?","You can't assume it's installed. There are ways around that, you can fall back to distutils (but then why have setuptools in the first place) or you can install setuptools in setup.py (but I think that's evil). +Use setuptools only if you need it. +When it comes to setuptools vs distrubute, they are compatible, and choosing one over the other is mainly up to the user. The setup.py is identical.",1.2,True,5,315 2009-11-03 10:27:04.573,What if setuptools isn't installed?,"I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?","I would say it depends on what kind of user you are addressing. If they are simply users and not Python programmers, or if they are basic programmers, using setuptools might be a little bit too much at first. For those the distutils is perfect. For clients, I would definitely stick to distutils. For more enthusiast programmers the setuptools would be fine. Somehow, it also depends on how you want to distribute updates, and how often. For example, do the users have an access to the Internet without a nasty proxy setup by their company that would block setuptools? - We do have one and it's an extra step to configure and make it work on every workstation.",0.0,False,5,315 -2009-11-03 10:27:04.573,What if setuptools isn't installed?,"I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?","You can't assume it's installed. There are ways around that, you can fall back to distutils (but then why have setuptools in the first place) or you can install setuptools in setup.py (but I think that's evil). -Use setuptools only if you need it. -When it comes to setuptools vs distrubute, they are compatible, and choosing one over the other is mainly up to the user. The setup.py is identical.",1.2,True,5,315 -2009-11-03 10:27:04.573,What if setuptools isn't installed?,"I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?",The standard way to distribute packages with setuptools includes an ez_setup.py script which will automatically download and install setuptools itself - on Windows I believe it will actually install an executable for easy_install. You can get this from the standard setuptools/easy_install distribution.,0.2655860252697744,False,5,315 -2009-11-03 10:27:04.573,What if setuptools isn't installed?,"I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?","In most librarys I ever installed for python, a warning apears ""You have to install setuptools"". You could do it as well I think, you could add a link so the user don't have to search the internet for it.",0.1352210990936997,False,5,315 +2009-11-03 10:27:04.573,What if setuptools isn't installed?,"I'm just learning the art of writing a setup.py file for my project. I see there's lots of talk about setuptools, which is supposed to be superior to distutils. There's one thing though that I fail to understand, and I didn't see it addressed in any tutorial I've read about this: What if setuptools isn't installed? I understand it's not part of the standard library, so how can you assume the person who wants to install your program will have it installed?","I have used setuptools to compile many python scripts that I have written into windows EXEs. However, it has always been my understanding (from experience) that the computer running the compiled EXE does not need to have setup tools installed. +Hope that helps",0.1352210990936997,False,5,315 2009-11-03 22:31:35.183,Changing web service url in SUDS library,Using SUDS SOAP client how do I specify web service URL. I can see clearly that WSDL path is specified in Client constructor but what if I wan't to change web service url?,I think you have to create a new Client object for each different URL.,0.1352210990936997,False,1,316 2009-11-04 13:30:16.327,How to match alphabetical chars without numeric chars with Python regexp?,"Using Python module re, how to get the equivalent of the ""\w"" (which matches alphanumeric chars) WITHOUT matching the numeric characters (those which can be matched by ""[0-9]"")? Notice that the basic need is to match any character (including all unicode variation) without numerical chars (which are matched by ""[0-9]""). @@ -3954,20 +3954,7 @@ A bit twisted, if you ask me, but it works. Should be faster than the lookahead 2009-11-04 15:51:16.753,how to process long-running requests in python workers?,"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. I 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. how 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) -btw. workers are using read-only data so there is no need to maintain locking and communication between them","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? -The standard arrangement in deployments of Python is: - -The webserver start a number of processes each running a complete python interpreter and loading all your data into memory. -HTTP request comes in and gets dispatched off to some process -Process does your calculation and returns the result directly to the webserver and user -When you need to change your code or the graph data, you restart the webserver and go back to step 1. - -This is the architecture used Django and other popular web frameworks.",0.0582430451621389,False,4,318 -2009-11-04 15:51:16.753,how to process long-running requests in python workers?,"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. -I 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. -how 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) -btw. workers are using read-only data so there is no need to maintain locking and communication between them","Another option is a queue table in the database. -The worker processes run in a loop or off cron and poll the queue table for new jobs.",0.0,False,4,318 +btw. workers are using read-only data so there is no need to maintain locking and communication between them","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.",0.0,False,4,318 2009-11-04 15:51:16.753,how to process long-running requests in python workers?,"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. I 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. how 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) @@ -3987,9 +3974,22 @@ responsive and friendly.",0.0,False,4,318 2009-11-04 15:51:16.753,how to process long-running requests in python workers?,"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. I 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. how 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) -btw. workers are using read-only data so there is no need to maintain locking and communication between them","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.",0.0,False,4,318 -2009-11-04 21:42:33.000,How to get a reference to a module inside the module itself?,"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?","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.",0.7319638163949052,False,2,319 +btw. workers are using read-only data so there is no need to maintain locking and communication between them","Another option is a queue table in the database. +The worker processes run in a loop or off cron and poll the queue table for new jobs.",0.0,False,4,318 +2009-11-04 15:51:16.753,how to process long-running requests in python workers?,"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. +I 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. +how 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) +btw. workers are using read-only data so there is no need to maintain locking and communication between them","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? +The standard arrangement in deployments of Python is: + +The webserver start a number of processes each running a complete python interpreter and loading all your data into memory. +HTTP request comes in and gets dispatched off to some process +Process does your calculation and returns the result directly to the webserver and user +When you need to change your code or the graph data, you restart the webserver and go back to step 1. + +This is the architecture used Django and other popular web frameworks.",0.0582430451621389,False,4,318 2009-11-04 21:42:33.000,How to get a reference to a module inside the module itself?,"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?",If all you need is to get access to module variable then use globals()['bzz'] (or vars()['bzz'] if it's module level).,0.0,False,2,319 +2009-11-04 21:42:33.000,How to get a reference to a module inside the module itself?,"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?","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.",0.7319638163949052,False,2,319 2009-11-05 15:08:46.430,how to get tz_info object corresponding to current timezone?,"Is there a cross-platform function in python (or pytz) that returns a tzinfo object corresponding to the timezone currently set on the computer? environment variables cannot be counted on as they are not cross-platform","Maybe try: import time @@ -4018,21 +4018,27 @@ I'm not fond of either of these approaches. The more complex your template needs Say you have a kind defines, and you want to keep a record of deleted entities of that kind. But you want to separate the storage of live object and archived objects. Kinds are basically just serialized dicts in the bigtable anyway. And maybe you don't need to index the archive in the same way as the live data. -So how would you make a move or copy of a entity of one kind to another kind.","Unless someone's written utilities for this kind of thing, the way to go is to read from one and write to the other kind!",0.2012947653214861,False,2,323 +So how would you make a move or copy of a entity of one kind to another kind.","No - once created, the kind is a part of the entity's immutable key. You need to create a new entity and copy everything across. One way to do this would be to use the low-level google.appengine.api.datastore interface, which treats entities as dicts.",1.2,True,2,323 2009-11-07 17:39:19.647,Move or copy an entity to another kind,"Is there a way to move an entity to another kind in appengine. Say you have a kind defines, and you want to keep a record of deleted entities of that kind. But you want to separate the storage of live object and archived objects. Kinds are basically just serialized dicts in the bigtable anyway. And maybe you don't need to index the archive in the same way as the live data. -So how would you make a move or copy of a entity of one kind to another kind.","No - once created, the kind is a part of the entity's immutable key. You need to create a new entity and copy everything across. One way to do this would be to use the low-level google.appengine.api.datastore interface, which treats entities as dicts.",1.2,True,2,323 +So how would you make a move or copy of a entity of one kind to another kind.","Unless someone's written utilities for this kind of thing, the way to go is to read from one and write to the other kind!",0.2012947653214861,False,2,323 2009-11-08 10:29:19.143,"Does WordNet have ""levels""? (NLP)","For example... Chicken is an animal. Burrito is a food. WordNet allows you to do ""is-a""...the hiearchy feature. However, how do I know when to stop travelling up the tree? I want a LEVEL. That is consistent. -For example, if presented with a bunch of words, I want wordNet to categorize all of them, but at a certain level, so it doesn't go too far up. Categorizing ""burrito"" as a ""thing"" is too broad, yet ""mexican wrapped food"" is too specific. I want to go up the hiearchy or down..until the right LEVEL.","In order to get levels, you need to predefine the content of each level. An ontology often defines these as the immediate IS_A children of a specific concept, but if that is absent, you need to develop a method of that yourself. -The next step is to put a priority on each concept, in case you want to present only one category for each word. The priority can be done in multiple ways, for instance as the count of IS_A relations between the category and the word, or manually selected priorities for each category. For each word, you can then pick the category with the highest priority. For instance, you may want meat to be ""food"" rather than chemical substance. -You may also want to pick some words, that change priority if they are in the path. For instance, if you want some chemicals which are also food, to be announced as chemicals, but others should still be food.",0.1618299653758019,False,4,324 +For example, if presented with a bunch of words, I want wordNet to categorize all of them, but at a certain level, so it doesn't go too far up. Categorizing ""burrito"" as a ""thing"" is too broad, yet ""mexican wrapped food"" is too specific. I want to go up the hiearchy or down..until the right LEVEL.","sorry, may I ask which tool could judge ""difficulty level"" of sentences? +I wish to find out ""similar difficulty level"" of sentences for user to read.",0.0,False,4,324 +2009-11-08 10:29:19.143,"Does WordNet have ""levels""? (NLP)","For example... +Chicken is an animal. +Burrito is a food. +WordNet allows you to do ""is-a""...the hiearchy feature. +However, how do I know when to stop travelling up the tree? I want a LEVEL. +That is consistent. +For example, if presented with a bunch of words, I want wordNet to categorize all of them, but at a certain level, so it doesn't go too far up. Categorizing ""burrito"" as a ""thing"" is too broad, yet ""mexican wrapped food"" is too specific. I want to go up the hiearchy or down..until the right LEVEL.","WordNet's hypernym tree ends with a single root synset for the word ""entity"". If you are using WordNet's C library, then you can get a while recursive structure for a synset's ancestors using traceptrs_ds, and you can get the whole synset tree by recursively following nextss and ptrlst pointers until you hit null pointers.",0.0,False,4,324 2009-11-08 10:29:19.143,"Does WordNet have ""levels""? (NLP)","For example... Chicken is an animal. Burrito is a food. @@ -4058,27 +4064,26 @@ Burrito is a food. WordNet allows you to do ""is-a""...the hiearchy feature. However, how do I know when to stop travelling up the tree? I want a LEVEL. That is consistent. -For example, if presented with a bunch of words, I want wordNet to categorize all of them, but at a certain level, so it doesn't go too far up. Categorizing ""burrito"" as a ""thing"" is too broad, yet ""mexican wrapped food"" is too specific. I want to go up the hiearchy or down..until the right LEVEL.","WordNet's hypernym tree ends with a single root synset for the word ""entity"". If you are using WordNet's C library, then you can get a while recursive structure for a synset's ancestors using traceptrs_ds, and you can get the whole synset tree by recursively following nextss and ptrlst pointers until you hit null pointers.",0.0,False,4,324 -2009-11-08 10:29:19.143,"Does WordNet have ""levels""? (NLP)","For example... -Chicken is an animal. -Burrito is a food. -WordNet allows you to do ""is-a""...the hiearchy feature. -However, how do I know when to stop travelling up the tree? I want a LEVEL. -That is consistent. -For example, if presented with a bunch of words, I want wordNet to categorize all of them, but at a certain level, so it doesn't go too far up. Categorizing ""burrito"" as a ""thing"" is too broad, yet ""mexican wrapped food"" is too specific. I want to go up the hiearchy or down..until the right LEVEL.","sorry, may I ask which tool could judge ""difficulty level"" of sentences? -I wish to find out ""similar difficulty level"" of sentences for user to read.",0.0,False,4,324 +For example, if presented with a bunch of words, I want wordNet to categorize all of them, but at a certain level, so it doesn't go too far up. Categorizing ""burrito"" as a ""thing"" is too broad, yet ""mexican wrapped food"" is too specific. I want to go up the hiearchy or down..until the right LEVEL.","In order to get levels, you need to predefine the content of each level. An ontology often defines these as the immediate IS_A children of a specific concept, but if that is absent, you need to develop a method of that yourself. +The next step is to put a priority on each concept, in case you want to present only one category for each word. The priority can be done in multiple ways, for instance as the count of IS_A relations between the category and the word, or manually selected priorities for each category. For each word, you can then pick the category with the highest priority. For instance, you may want meat to be ""food"" rather than chemical substance. +You may also want to pick some words, that change priority if they are in the path. For instance, if you want some chemicals which are also food, to be announced as chemicals, but others should still be food.",0.1618299653758019,False,4,324 2009-11-08 16:24:29.113,Django/SQL: keeping track of who who read what in a forum,"I'm working on a not-so-big project in django that will among other things incorporate a forum system. I have most of the system at a more or less functioning state, but I'm still missing a feature to mark unread threads for the users when there are new posts. The thing is I can't really think of a way to properly store that information. My first idea was to create another model that will store a list of threads with changes in them for each user. Something with one ForeignKey(User) and one ForeignKey(Thread) and just keep adding new entries each time a thread is posted or a post is added to a thread. But then, I'm not sure how well that would scale with say several hundred threads after a while and maybe 50-200 users. So add 200 rows for each new post for the users who aren't logged on? Sounds like a lot. How do other forum systems do it anyway? And how can I implement a system to work these things out in Django. -Thanks!","You're much better off storing the ""read"" bit, not the ""unread"" bit. And you can store them not as relational data, but in a giant bit-blob. Then you don't have to modify the read data at all when new posts are added, only when a user reads posts.",0.3869120172231254,False,2,325 +Thanks!",You might also simply store the last time a user was reading a particular forum. Any posts that have been updated since that date are new. You'll only be storing one additional piece of information per user as opposed to a piece of information per post per user.,1.2,True,2,325 2009-11-08 16:24:29.113,Django/SQL: keeping track of who who read what in a forum,"I'm working on a not-so-big project in django that will among other things incorporate a forum system. I have most of the system at a more or less functioning state, but I'm still missing a feature to mark unread threads for the users when there are new posts. The thing is I can't really think of a way to properly store that information. My first idea was to create another model that will store a list of threads with changes in them for each user. Something with one ForeignKey(User) and one ForeignKey(Thread) and just keep adding new entries each time a thread is posted or a post is added to a thread. But then, I'm not sure how well that would scale with say several hundred threads after a while and maybe 50-200 users. So add 200 rows for each new post for the users who aren't logged on? Sounds like a lot. How do other forum systems do it anyway? And how can I implement a system to work these things out in Django. -Thanks!",You might also simply store the last time a user was reading a particular forum. Any posts that have been updated since that date are new. You'll only be storing one additional piece of information per user as opposed to a piece of information per post per user.,1.2,True,2,325 +Thanks!","You're much better off storing the ""read"" bit, not the ""unread"" bit. And you can store them not as relational data, but in a giant bit-blob. Then you don't have to modify the read data at all when new posts are added, only when a user reads posts.",0.3869120172231254,False,2,325 +2009-11-08 17:01:35.417,"Which database should I use to store records, and how should I use it?","I'm developing an application that will store a sizeable number of records. These records will be something like (URL, date, title, source, {optional data...}) +As this is a client-side app, I don't want to use a database server, I just want the info stored into files. +I want the files to be readable from various languages (at least python and C++), so something language specific like python's pickle is out of the game. +I am seeing two possibilities: sqlite and BerkeleyDB. As my use case is clearly not relational, I am tempted to go with BerkeleyDB, however I don't really know how I should use it to store my records, as it only stores key/value pairs. +Is my reasoning correct? If so, how should I use BDB to store my records? Can you link me to relevant info? Or am I missing a better solution?","Ok, so you say just storing the data..? You really only need a DB for retrieval, lookup, summarising, etc. So, for storing, just use simple text files and append lines. Compress the data if you need to, use delims between fields - just about any language will be able to read such files. If you do want to retrieve, then focus on your retrieval needs, by date, by key, which keys, etc. If you want simple client side, then you need simple client db. SQLite is far easier than BDB, but look at things like Sybase Advantage (very fast and free for local clients but not open-source) or VistaDB or firebird... but all will require local config/setup/maintenance. If you go local XML for a 'sizable' number of records will give you some unnecessarily bloated file-sizes..!",0.0,False,3,326 2009-11-08 17:01:35.417,"Which database should I use to store records, and how should I use it?","I'm developing an application that will store a sizeable number of records. These records will be something like (URL, date, title, source, {optional data...}) As this is a client-side app, I don't want to use a database server, I just want the info stored into files. I want the files to be readable from various languages (at least python and C++), so something language specific like python's pickle is out of the game. @@ -4093,11 +4098,6 @@ I want the files to be readable from various languages (at least python and C++) I am seeing two possibilities: sqlite and BerkeleyDB. As my use case is clearly not relational, I am tempted to go with BerkeleyDB, however I don't really know how I should use it to store my records, as it only stores key/value pairs. Is my reasoning correct? If so, how should I use BDB to store my records? Can you link me to relevant info? Or am I missing a better solution?","Personally I would use sqlite anyway. It has always just worked for me (and for others I work with). When your app grows and you suddenly do want to do something a little more sophisticated, you won't have to rewrite. On the other hand, I've seen various comments on the Python dev list about Berkely DB that suggest it's less than wonderful; you only get dict-style access (what if you want to select certain date ranges or titles instead of URLs); and it's not even in Python 3's standard set of libraries.",0.1352210990936997,False,3,326 -2009-11-08 17:01:35.417,"Which database should I use to store records, and how should I use it?","I'm developing an application that will store a sizeable number of records. These records will be something like (URL, date, title, source, {optional data...}) -As this is a client-side app, I don't want to use a database server, I just want the info stored into files. -I want the files to be readable from various languages (at least python and C++), so something language specific like python's pickle is out of the game. -I am seeing two possibilities: sqlite and BerkeleyDB. As my use case is clearly not relational, I am tempted to go with BerkeleyDB, however I don't really know how I should use it to store my records, as it only stores key/value pairs. -Is my reasoning correct? If so, how should I use BDB to store my records? Can you link me to relevant info? Or am I missing a better solution?","Ok, so you say just storing the data..? You really only need a DB for retrieval, lookup, summarising, etc. So, for storing, just use simple text files and append lines. Compress the data if you need to, use delims between fields - just about any language will be able to read such files. If you do want to retrieve, then focus on your retrieval needs, by date, by key, which keys, etc. If you want simple client side, then you need simple client db. SQLite is far easier than BDB, but look at things like Sybase Advantage (very fast and free for local clients but not open-source) or VistaDB or firebird... but all will require local config/setup/maintenance. If you go local XML for a 'sizable' number of records will give you some unnecessarily bloated file-sizes..!",0.0,False,3,326 2009-11-09 11:24:40.500,Environment on google Appengine,"does someone have an idea how to get the environment variables on Google-AppEngine ? I'm trying to write a simple Script that shall use the Client-IP (for Authentication) and a parameter (geturl or so) from the URL (for e.g. http://thingy.appspot.dom/index?geturl=www.google.at) I red that i should be able to get the Client-IP via ""request.remote_addr"" but i seem to lack 'request' even tho i imported webapp from google.appengine.ext @@ -4200,11 +4200,11 @@ but you have ""wintracker2""? I wanted to buy it but the company said ""it's not ready to seal"".",0.0,False,1,338 2009-11-17 18:01:16.637,Django development server CPU intensive - how to analyse?,"I'm noticing that my django development server (version 1.1.1) on my local windows7 machine is using a lot of CPU (~30%, according to task manager's python.exe entry), even in idle state, i.e. no request coming in/going out. Is there an established way of analysing what might be responsible for this? Thanks! -Martin","Hit Control-C and crash the process. It will probably crash somewhere that it's spending a lot of time. -Or you could use a profiler.",0.3869120172231254,False,2,339 +Martin","FWIW, you should do the profiling, but when you do I'll bet you find that the answer is ""polling for changes to your files so it can auto-reload."" You might do a quick test with ""python manage.py runserver --noreload"" and see how that affects the CPU usage.",1.2,True,2,339 2009-11-17 18:01:16.637,Django development server CPU intensive - how to analyse?,"I'm noticing that my django development server (version 1.1.1) on my local windows7 machine is using a lot of CPU (~30%, according to task manager's python.exe entry), even in idle state, i.e. no request coming in/going out. Is there an established way of analysing what might be responsible for this? Thanks! -Martin","FWIW, you should do the profiling, but when you do I'll bet you find that the answer is ""polling for changes to your files so it can auto-reload."" You might do a quick test with ""python manage.py runserver --noreload"" and see how that affects the CPU usage.",1.2,True,2,339 +Martin","Hit Control-C and crash the process. It will probably crash somewhere that it's spending a lot of time. +Or you could use a profiler.",0.3869120172231254,False,2,339 2009-11-20 17:41:19.937,pysvn with svn+ssh,"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. The 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'). Any 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?","Check out ssh configuration option PasswordAuthentication. @@ -4275,6 +4275,21 @@ Overwriting the existing file (starting to write to the original file) is obviou A better option would be to write to a temporary file somewhere, and when the write method has finished, you copy the temporary file to the original file. Now, if the copy somehow fails, you still have correctly saved data in the temporary file. And if the copy succeeds, you can remove the temporary file. On POSIX systems I guess you can use the rename system call which is an atomic operation. But how would you do this best on a Windows system? In particular, how do you handle this best using Python? +Also, is there another scheme for safely writing to files?","If you see Python's documentation, it clearly mentions that os.rename() is an atomic operation. So in your case, writing data to a temporary file and then renaming it to the original file would be quite safe. +Another way could work like this: + +let original file be abc.xml +create abc.xml.tmp and write new data to it +rename abc.xml to abc.xml.bak +rename abc.xml.tmp to abc.xml +after new abc.xml is properly put in place, remove abc.xml.bak + +As you can see that you have the abc.xml.bak with you which you can use to restore if there are any issues related with the tmp file and of copying it back.",1.2,True,2,349 +2009-11-28 09:46:38.660,How to safely write to a file?,"Imagine you have a library for working with some sort of XML file or configuration file. The library reads the whole file into memory and provides methods for editing the content. When you are done manipulating the content you can call a write to save the content back to file. The question is how to do this in a safe way. +Overwriting the existing file (starting to write to the original file) is obviously not safe. If the write method fails before it is done you end up with a half written file and you have lost data. +A better option would be to write to a temporary file somewhere, and when the write method has finished, you copy the temporary file to the original file. +Now, if the copy somehow fails, you still have correctly saved data in the temporary file. And if the copy succeeds, you can remove the temporary file. +On POSIX systems I guess you can use the rename system call which is an atomic operation. But how would you do this best on a Windows system? In particular, how do you handle this best using Python? Also, is there another scheme for safely writing to files?","The standard solution is this. Write a new file with a similar name. X.ext# for example. @@ -4286,32 +4301,17 @@ X.ext# (the new one) to X.ext (Only for the crazy paranoids) call the OS sync function to force dirty buffer writes. At no time is anything lost or corruptable. The only glitch can happen during the renames. But you haven't lost anything or corrupted anything. The original is recoverable right up until the final rename.",0.2012947653214861,False,2,349 -2009-11-28 09:46:38.660,How to safely write to a file?,"Imagine you have a library for working with some sort of XML file or configuration file. The library reads the whole file into memory and provides methods for editing the content. When you are done manipulating the content you can call a write to save the content back to file. The question is how to do this in a safe way. -Overwriting the existing file (starting to write to the original file) is obviously not safe. If the write method fails before it is done you end up with a half written file and you have lost data. -A better option would be to write to a temporary file somewhere, and when the write method has finished, you copy the temporary file to the original file. -Now, if the copy somehow fails, you still have correctly saved data in the temporary file. And if the copy succeeds, you can remove the temporary file. -On POSIX systems I guess you can use the rename system call which is an atomic operation. But how would you do this best on a Windows system? In particular, how do you handle this best using Python? -Also, is there another scheme for safely writing to files?","If you see Python's documentation, it clearly mentions that os.rename() is an atomic operation. So in your case, writing data to a temporary file and then renaming it to the original file would be quite safe. -Another way could work like this: - -let original file be abc.xml -create abc.xml.tmp and write new data to it -rename abc.xml to abc.xml.bak -rename abc.xml.tmp to abc.xml -after new abc.xml is properly put in place, remove abc.xml.bak - -As you can see that you have the abc.xml.bak with you which you can use to restore if there are any issues related with the tmp file and of copying it back.",1.2,True,2,349 2009-11-29 02:20:09.160,Allow only one concurrent login per user in django app,"is it possible to allow only one concurrent login per user in django application? if yes, how do you approach?","I'm going to assume that you mean logged in at once, and not one ""login"" at the same time. I've never written a Django application before. But one method I've used in other languages, is to store the session ID of the logged in user in their user row in the database. For example, if you have a users table in your database, add a field ""session_id"" and then when the user logs in, set that to their current session_id. On every page load check to see if their current session matches the session_id in the users table. Remember whenever you regenerate their session_id in your application, you'll need to update the database so they don't get logged out. Some people when a user logs in, just store all the users details into a session and never re-call the database on a new page load. So for some this ""extra"" SQL query might seem wrong. For me, I always do a new query on each page load to re-authenticate the user and make sure their account wasn't removed/suspended and to make sure their username/password combo is still the same. (What if someone from another location changed the password, or an administrator?)",0.0,False,1,350 2009-11-30 10:20:03.557,Close and open a new browser in Selenium,"I'm writing a script which needs the browser that selenium is operating close and re-open, without losing its cookies. Any idea on how to go about it? -Basically, it's a check to see that if the user opens and closes his browser, his cookies stay intact.","This is a feature of the browser and not your concern: If there is a bug in the browser, then there is little you can do. If you need to know whether a certain version of the browser works correctly, then define a manual test (write a document that explains the steps), do it once and record the result somewhere (like ""Browser XXX version YYY works""). -When you know that a certain browser (version) works, then that's not going to change, so there is no need to repeat the test.",0.0,False,2,351 +Basically, it's a check to see that if the user opens and closes his browser, his cookies stay intact.","You should be able to use the stop and start commands. You will need to ensure that you are not clearing cookies between sessions, and depending on the browser you're launching you may also need to use the -browserSessionReuse command line option.",0.5457054096481145,False,2,351 2009-11-30 10:20:03.557,Close and open a new browser in Selenium,"I'm writing a script which needs the browser that selenium is operating close and re-open, without losing its cookies. Any idea on how to go about it? -Basically, it's a check to see that if the user opens and closes his browser, his cookies stay intact.","You should be able to use the stop and start commands. You will need to ensure that you are not clearing cookies between sessions, and depending on the browser you're launching you may also need to use the -browserSessionReuse command line option.",0.5457054096481145,False,2,351 +Basically, it's a check to see that if the user opens and closes his browser, his cookies stay intact.","This is a feature of the browser and not your concern: If there is a bug in the browser, then there is little you can do. If you need to know whether a certain version of the browser works correctly, then define a manual test (write a document that explains the steps), do it once and record the result somewhere (like ""Browser XXX version YYY works""). +When you know that a certain browser (version) works, then that's not going to change, so there is no need to repeat the test.",0.0,False,2,351 2009-11-30 13:42:54.487,Javascript communication with Selenium (RC),"My Application has a lot of calculation being done in JavaScript according to how and when the user acts on the application. The project prints out valuable information (through console calls) as to how this calculation is going on, and so we can easily spot any NaNs creeping in. We are planning to integrate Selenium (RC with python) to test or project, but if we could get the console output messages in the python test case, we can identify any NaNs or even any miscalculations. So, is there a way that Selenium can absorb these outputs (preferably in a console-less environment)? @@ -4342,7 +4342,8 @@ If this would happen, how do I get rid of the zero? How do I open the file to read/write in binary/decimal/hex rather than just text? I've mostly worked with Python, but I can muddle through C if I must. -Thank you.","Just use gzip compression, and save 60-70% with 0% effort!",0.9950547536867304,False,3,354 +Thank you.","""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."" +Correct. Your plan will do nothing.",0.0,False,3,354 2009-12-03 04:43:05.963,Compressing UTF-8(or other 8-bit encoding) to 7 or fewer bits,"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. How would I go about doing this? There 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. @@ -4377,24 +4378,14 @@ If this would happen, how do I get rid of the zero? How do I open the file to read/write in binary/decimal/hex rather than just text? I've mostly worked with Python, but I can muddle through C if I must. -Thank you.","""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."" -Correct. Your plan will do nothing.",0.0,False,3,354 -2009-12-03 21:57:03.280,how to transition from C# to python?,"i feel like i'm going back to the stone age. -how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","I'm not too familiar with Python so I'll give some general advice. Make sure to print out some reference pages of common functions. Keep them by you(or pinned to a wall or desk) at all times when your programming.. I'm traditionally a ""stone age"" developer and after developing in VS for a few months I'm finding my hobby programming is difficult without intellisense.. but keep at it to memorize the most common functions and eventually it'll just be natural -You'll also have to get use to a bit more ""difficult"" of debugging(not sure how that works with python) -While your learning though, you should enjoy the goodness(at least compared to C#) of Python even if you don't have intellisense.. hopefully this will motivate you!",0.0,False,10,355 -2009-12-03 21:57:03.280,how to transition from C# to python?,"i feel like i'm going back to the stone age. -how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","One step at a time? -Start off with simple programs (things you can write with your eyes closed in C#), and keep going... You will end up knowing the API by heart.",0.126863772113723,False,10,355 -2009-12-03 21:57:03.280,how to transition from C# to python?,"i feel like i'm going back to the stone age. -how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","I've only ever used IDLE for python development and it is not fun in the least. I would recommend getting your favorite text editor, mine is notepad++, and praying for a decent plugin for it. I only ever had to go from Eclipse to Visual Studio so my opinions are generally invalid in these contexts.",0.0,False,10,355 +Thank you.","Just use gzip compression, and save 60-70% with 0% effort!",0.9950547536867304,False,3,354 2009-12-03 21:57:03.280,how to transition from C# to python?,"i feel like i'm going back to the stone age. -how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?",You could always start with IronPython and continue to develop in Visual Studio.,0.0509761841073563,False,10,355 +how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","A mistake people coming from C# or Java make a lot is recreate a large class hierarchy like is common in those languages. With Python this is almost never useful. Instead, learn about duck typing. And don't worry too much about the lack of static typing: in practice, it's almost never an issue.",0.0255046717588776,False,10,355 2009-12-03 21:57:03.280,how to transition from C# to python?,"i feel like i'm going back to the stone age. -how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?",The python ide from wingware is pretty nice. Thats what I ended up using going from visual studio C++/.net to doing python.,0.0509761841073563,False,10,355 +how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","I suggest going cold turkey - languages like Python shine with great text editors. Choose one you want to become amazing at (vim, emacs, etc.) and never look back.",0.0,False,10,355 2009-12-03 21:57:03.280,how to transition from C# to python?,"i feel like i'm going back to the stone age. -how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","Don't worry about intellisense. Python is really simple and there really isn't that much to know, so after a few projects you'll be conceiving of python code while driving, eating, etc., without really even trying. Plus, python's built in text editor (IDLE) has a wimpy version of intellisense that has always been more than sufficient for my purposes. If you ever go blank and want to know what methods/properties and object has, just type this in an interactive session: -dir(myobject)",0.0255046717588776,False,10,355 +how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","Same way you do anything else that doesn't have IntelliStuff. +I'm betting you wrote that question without the aid of an IntelliEnglish computer program that showed you a list of verbs you could use and automatically added punctuation at the end of your sentences, for example. :-)",0.0255046717588776,False,10,355 2009-12-03 21:57:03.280,how to transition from C# to python?,"i feel like i'm going back to the stone age. how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?"," This is sort of the reason that I think being a good visual studio user makes you a bad developer. Instead of learning an API, you look in the object browser until you find something that sounds more or less like what you are looking for, instantiate it, then hit . and start looking for what sounds like the right thing to use. While this is very quick, it also means it takes forever to learn an API in any depth, which often means you end up either re-inventing the wheel (because the wheel is buried under a mountain worth of household appliances and you had no idea it was there), or just doing things in a sub-optimal way. Just because you can find A solution quickly, doesn't mean it is THE BEST solution. @@ -4403,12 +4394,21 @@ In the case of .NET, which ships with about a billion APIs for everything under Pythonic code favors one, obvious way to do any given thing. This tends to make the APIs very straight forward and readable. The trick is to learn the language and learn the APIs. It is not terribly hard to do, especially in the case of python, and while not being able to rely on intellisense may be jarring at first, it shouldn't take more then a week or two before you get used to it not being there. Learn the language and the basic standard libraries with a good book. When it comes to a new library API, I find the REPL and some exploratory coding can get me to a pretty good understanding of what is going on fairly quickly.",0.1016881243684853,False,10,355 2009-12-03 21:57:03.280,how to transition from C# to python?,"i feel like i'm going back to the stone age. -how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","Same way you do anything else that doesn't have IntelliStuff. -I'm betting you wrote that question without the aid of an IntelliEnglish computer program that showed you a list of verbs you could use and automatically added punctuation at the end of your sentences, for example. :-)",0.0255046717588776,False,10,355 +how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","Don't worry about intellisense. Python is really simple and there really isn't that much to know, so after a few projects you'll be conceiving of python code while driving, eating, etc., without really even trying. Plus, python's built in text editor (IDLE) has a wimpy version of intellisense that has always been more than sufficient for my purposes. If you ever go blank and want to know what methods/properties and object has, just type this in an interactive session: +dir(myobject)",0.0255046717588776,False,10,355 2009-12-03 21:57:03.280,how to transition from C# to python?,"i feel like i'm going back to the stone age. -how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","I suggest going cold turkey - languages like Python shine with great text editors. Choose one you want to become amazing at (vim, emacs, etc.) and never look back.",0.0,False,10,355 +how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?",You could always start with IronPython and continue to develop in Visual Studio.,0.0509761841073563,False,10,355 2009-12-03 21:57:03.280,how to transition from C# to python?,"i feel like i'm going back to the stone age. -how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","A mistake people coming from C# or Java make a lot is recreate a large class hierarchy like is common in those languages. With Python this is almost never useful. Instead, learn about duck typing. And don't worry too much about the lack of static typing: in practice, it's almost never an issue.",0.0255046717588776,False,10,355 +how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","I'm not too familiar with Python so I'll give some general advice. Make sure to print out some reference pages of common functions. Keep them by you(or pinned to a wall or desk) at all times when your programming.. I'm traditionally a ""stone age"" developer and after developing in VS for a few months I'm finding my hobby programming is difficult without intellisense.. but keep at it to memorize the most common functions and eventually it'll just be natural +You'll also have to get use to a bit more ""difficult"" of debugging(not sure how that works with python) +While your learning though, you should enjoy the goodness(at least compared to C#) of Python even if you don't have intellisense.. hopefully this will motivate you!",0.0,False,10,355 +2009-12-03 21:57:03.280,how to transition from C# to python?,"i feel like i'm going back to the stone age. +how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?",The python ide from wingware is pretty nice. Thats what I ended up using going from visual studio C++/.net to doing python.,0.0509761841073563,False,10,355 +2009-12-03 21:57:03.280,how to transition from C# to python?,"i feel like i'm going back to the stone age. +how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","I've only ever used IDLE for python development and it is not fun in the least. I would recommend getting your favorite text editor, mine is notepad++, and praying for a decent plugin for it. I only ever had to go from Eclipse to Visual Studio so my opinions are generally invalid in these contexts.",0.0,False,10,355 +2009-12-03 21:57:03.280,how to transition from C# to python?,"i feel like i'm going back to the stone age. +how do i relearn to develop without intellisense (pydev intellisense doesn't count).. in general, how does one successfully leave the comfort of visual studio ?","One step at a time? +Start off with simple programs (things you can write with your eyes closed in C#), and keep going... You will end up knowing the API by heart.",0.126863772113723,False,10,355 2009-12-04 14:02:47.403,Best XMPP Library for Python Web Application,"I want to learn how to use XMPP and to create a simple web application with real collaboration features. I am writing the application with Python(WSGI), and the application will require javascript enabled because I am going to use jQuery or Dojo. I have downloaded Openfire for the server and which lib to choose? SleekXMPP making trouble with tlslite module(python 2.5 and I need only python 2.6). @@ -4466,13 +4466,13 @@ Edit : Commenters Peter H asked if I was working with numpy arrays. The answer is yes.",take a look at module struct ?,0.0,False,1,361 2009-12-13 14:46:44.253,How to return a float point number with a defined number of decimal places?,"So I know how to print a floating point number with a certain decimal places. My question is how to return it with a specified number of decimal places? +Thanks.","In order to get two decimal places, multiply the number by 100, floor it, then divide by 100. +And note that the number you will return will not really have only two decimal places because division by 100 cannot be represented exactly in IEEE-754 floating-point arithmetic most of the time. It will only be the closest representable approximation to a number with only two decimal places.",0.3869120172231254,False,2,362 +2009-12-13 14:46:44.253,How to return a float point number with a defined number of decimal places?,"So I know how to print a floating point number with a certain decimal places. +My question is how to return it with a specified number of decimal places? Thanks.","Floating point numbers have infinite number of decimal places. The physical representation on the computer is dependent on the representation of float, or double, or whatever and is dependent on a) language b) construct, e.g. float, double, etc. c) compiler implementation d) hardware. Now, given that you have a representation of a floating point number (i.e. a real) within a particular language, is your question how to round it off or truncate it to a specific number of digits? There is no need to do this within the return call, since you can always truncate/round afterwards. In fact, you would usually not want to truncate until actually printing, to preserve more precision. An exception might be if you wanted to ensure that results were consistent across different algorithms/hardware, ie. say you had some financial trading software that needed to pass unit tests across different languages/platforms etc.",0.2012947653214861,False,2,362 -2009-12-13 14:46:44.253,How to return a float point number with a defined number of decimal places?,"So I know how to print a floating point number with a certain decimal places. -My question is how to return it with a specified number of decimal places? -Thanks.","In order to get two decimal places, multiply the number by 100, floor it, then divide by 100. -And note that the number you will return will not really have only two decimal places because division by 100 cannot be represented exactly in IEEE-754 floating-point arithmetic most of the time. It will only be the closest representable approximation to a number with only two decimal places.",0.3869120172231254,False,2,362 2009-12-13 21:07:43.213,Executing server-side Unix scripts asynchronously,"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: Asks for relevant data to pass into scripts. @@ -4510,13 +4510,13 @@ If this fixes it, you just need to get rid of your python bash alias.",1.2,True, 2009-12-15 18:03:17.750,How to clean up my Python Installation for a fresh start,"I'm developing on Snow Leopard and going through the various ""how tos"" to get the MySQLdb package installed and working (uphill battle). Things are a mess and I'd like to regain confidence with a fresh, clean, as close to factory install of Python 2.6. What folders should I clean out? What should I run? -What symbolic links should I destroy or create?","My experience doing development on MacOSX is that the directories for libraries and installation tools are just different enough to cause a lot of problems that you end up having to fix by hand. Eventually, your computer becomes a sketchy wasteland of files and folders duplicated all over the place in an effort to solve these problems. A lot of hand-tuned configuration files, too. The thought of getting my environment set up again from scratch gives me the chills. -Then, when it's time to deploy, you've got to do it over again in reverse (unless you're deploying to an XServe, which is unlikely). -Learn from my mistake: set up a Linux VM and do your development there. At least, run your development ""server"" there, even if you edit the code files on your Mac.",0.1016881243684853,False,2,367 +What symbolic links should I destroy or create?","when doing an ""port selfupdate"", rsync timesout with rsync.macports.org. There are mirror sites available to use.",0.0,False,2,367 2009-12-15 18:03:17.750,How to clean up my Python Installation for a fresh start,"I'm developing on Snow Leopard and going through the various ""how tos"" to get the MySQLdb package installed and working (uphill battle). Things are a mess and I'd like to regain confidence with a fresh, clean, as close to factory install of Python 2.6. What folders should I clean out? What should I run? -What symbolic links should I destroy or create?","when doing an ""port selfupdate"", rsync timesout with rsync.macports.org. There are mirror sites available to use.",0.0,False,2,367 +What symbolic links should I destroy or create?","My experience doing development on MacOSX is that the directories for libraries and installation tools are just different enough to cause a lot of problems that you end up having to fix by hand. Eventually, your computer becomes a sketchy wasteland of files and folders duplicated all over the place in an effort to solve these problems. A lot of hand-tuned configuration files, too. The thought of getting my environment set up again from scratch gives me the chills. +Then, when it's time to deploy, you've got to do it over again in reverse (unless you're deploying to an XServe, which is unlikely). +Learn from my mistake: set up a Linux VM and do your development there. At least, run your development ""server"" there, even if you edit the code files on your Mac.",0.1016881243684853,False,2,367 2009-12-16 01:04:08.380,Python: How do I find why IDLE restarts?,"I am using python 2.5 on windows. All I am doing is unpickling a large file (18MB - a list of dictionaries) and modifiying some of its values. Now this works fine. But when I add a couple of prints, IDLE restarts. And weirdly enough it seems to be happening where I added the print. I figured this out commenting and uncommenting things line by line. I added a try catch around the print, but am not able to catch anything. When does IDLE restart? And how do I catch any exceptions or errors it throws(if it does)?",Enable the debugger and see if it tells you anything.,0.0,False,1,368 2009-12-16 04:11:41.030,deleter decorator using Property in Python,"I'm playing around with property in Python and I was wondering how this @propertyName.deleter decorator works. I'm probably missing something, I could not find clear answers by Google. @@ -4558,12 +4558,12 @@ if __name__ == '__main__': Thank you very much (:","In Python 3 you WOULD see the print's result -- and then an AttributeError for the last print (because _m has disappeared). You may be using Python 2.6, in which case you need to change the class clause to class M(object): to make M new-style, and then you'll get the same behavior as in Python 3.",0.9997532108480276,False,1,369 +2009-12-16 04:44:50.613,Django: Where to put helper functions?,I have a couple of functions that I wrote that I need to use in my django app. Where would I put the file with them and how would I make them callable within my views?,"If they are related to a specific app, I usually just put them in the related app folder and name the file, 'functions.py'. +If they're not specific to an app, I make a commons app for components (tests, models, functions, etc) that are shared across apps.",0.996997635486526,False,3,370 +2009-12-16 04:44:50.613,Django: Where to put helper functions?,I have a couple of functions that I wrote that I need to use in my django app. Where would I put the file with them and how would I make them callable within my views?,I am using new python file service.py in app folder. The file contains mostly helper queries for specific app. Also I used to create a folder inside Django application that contains global helper functions and constants.,0.2012947653214861,False,3,370 2009-12-16 04:44:50.613,Django: Where to put helper functions?,I have a couple of functions that I wrote that I need to use in my django app. Where would I put the file with them and how would I make them callable within my views?,"create a reusable app that include your generic functions so you can share between projects. use for example a git repo to store this app and manage deployments and evolution (submodule) use a public git repo so you can share with the community :)",0.9997532108480276,False,3,370 -2009-12-16 04:44:50.613,Django: Where to put helper functions?,I have a couple of functions that I wrote that I need to use in my django app. Where would I put the file with them and how would I make them callable within my views?,I am using new python file service.py in app folder. The file contains mostly helper queries for specific app. Also I used to create a folder inside Django application that contains global helper functions and constants.,0.2012947653214861,False,3,370 -2009-12-16 04:44:50.613,Django: Where to put helper functions?,I have a couple of functions that I wrote that I need to use in my django app. Where would I put the file with them and how would I make them callable within my views?,"If they are related to a specific app, I usually just put them in the related app folder and name the file, 'functions.py'. -If they're not specific to an app, I make a commons app for components (tests, models, functions, etc) that are shared across apps.",0.996997635486526,False,3,370 2009-12-16 23:00:08.263,split a pdf based on outline,"i would like to use pyPdf to split a pdf file based on the outline where each destination in the outline refers to a different page within the pdf. example outline: @@ -4605,9 +4605,17 @@ Where is the python search path defined under the default python installation in If I've put the pywn files in /Users/nick/programming/pywn, what is the best way of adding this to the search path? Is this the best place to put the files?",I think by default /Library/Python/2.5/site-packages/ is part of your search path. This directory is usually used for third party libraries.,1.2,True,1,375 2009-12-25 00:25:16.753,"Start a ""throwaway"" MySQL session for testing code?","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? -My application is in Python, and I'm using unittest on Ubuntu 9.10.",--datadir for just the data or --basedir,1.2,True,2,376 -2009-12-25 00:25:16.753,"Start a ""throwaway"" MySQL session for testing code?","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? My application is in Python, and I'm using unittest on Ubuntu 9.10.",You can try the Blackhole and Memory table types in MySQL.,0.0,False,2,376 +2009-12-25 00:25:16.753,"Start a ""throwaway"" MySQL session for testing code?","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? +My application is in Python, and I'm using unittest on Ubuntu 9.10.",--datadir for just the data or --basedir,1.2,True,2,376 +2009-12-26 02:05:47.180,python source code conversion to uml diagram with Sparx Systems Enterprise Architect,"Please let me know how to create a uml diagram along with its equivalent documentation for the source code(.py format) using enterprise architecture 7.5 +Please help me find the solution, I have read the solution for the question on this website related to my topic but in vain","Go to project browser +Create a model +Right-click model > Add > Add View > Class +Right-click class > Code Engineering > Import Source Directory... +Check ""one package per folder"" + +The last one ensures you'll have an interesting diagram full of classes.",0.1016881243684853,False,2,377 2009-12-26 02:05:47.180,python source code conversion to uml diagram with Sparx Systems Enterprise Architect,"Please let me know how to create a uml diagram along with its equivalent documentation for the source code(.py format) using enterprise architecture 7.5 Please help me find the solution, I have read the solution for the question on this website related to my topic but in vain","File / New Project / enter your project name. In the Project Browser, create a package named ""source"" @@ -4617,14 +4625,6 @@ Set ""Source Type"" to Python Enable ""Recursively Process Subdirectories"" Select ""Package Per File"" Click ""OK"".",0.3869120172231254,False,2,377 -2009-12-26 02:05:47.180,python source code conversion to uml diagram with Sparx Systems Enterprise Architect,"Please let me know how to create a uml diagram along with its equivalent documentation for the source code(.py format) using enterprise architecture 7.5 -Please help me find the solution, I have read the solution for the question on this website related to my topic but in vain","Go to project browser -Create a model -Right-click model > Add > Add View > Class -Right-click class > Code Engineering > Import Source Directory... -Check ""one package per folder"" - -The last one ensures you'll have an interesting diagram full of classes.",0.1016881243684853,False,2,377 2009-12-26 04:02:57.850,How do I make a simple file browser in wxPython?,"I'm starting to learn both Python and wxPython and as part of the app I'm doing, I need to have a simple browser on the left pane of my app. I'm wondering how do I do it? Or at least point me to the right direction that'll help me more on how to do one. Thanks in advance! EDIT: a sort of side question, how much of wxPython do I need to learn? Should I use tools like wxGlade?","You can take a look at the wxPython examples, they also include code samples for almost all of the widgets supported by wxPython. If you use Windows they can be found in the Start Menu folder of WxPython.",0.1352210990936997,False,1,378 @@ -4679,6 +4679,8 @@ Try it. If it works, using FTP from within Python will be a very simple task.",0 where can I put the create-thread-and-start code? Is there any hook for the django runserver?","Why would you want to do that? runserver is for development only, it should never be used in production. And if you're running via Apache, it should manage threads/processes for you anyway.",0.9981778976111988,False,2,382 2010-01-03 10:14:58.217,how to start a thread when django runserver?,"I want to start a thread when django project runserver successfully. where can I put the create-thread-and-start code? Is there any hook for the django runserver?","Agree with the above answer, you probably don't want to do this. Runserver should be used for development only. Once you deploy, you'll want to move to Apache/WSGI. On my dev machine (where I do use runserver), I usually throw it in a screen session, so it doesn't get in the way, but I can pull it back up if I need to see a traceback.",0.0,False,2,382 +2010-01-05 17:36:48.483,How to use C# client to consume Django/Python web service (all methods are returning null)?,"I have a C# command-line client that I'm testing the consumption of SOAP/WSDL via Django/Python/soaplib created WSDL. I've managed to successfully connect to the web service by adding a service reference. I then call one of service's methods, and the service processes the data I send, but it returns null instead of the integer I'm expecting. Any ideas on how to get back something other than a null response? Thanks for any help or suggestions!","We faced the similar problem while consuming a web service it was the type of data returned we were getting data in UTF-16 format. +Please check if you have proper data type in use.",0.0,False,2,383 2010-01-05 17:36:48.483,How to use C# client to consume Django/Python web service (all methods are returning null)?,"I have a C# command-line client that I'm testing the consumption of SOAP/WSDL via Django/Python/soaplib created WSDL. I've managed to successfully connect to the web service by adding a service reference. I then call one of service's methods, and the service processes the data I send, but it returns null instead of the integer I'm expecting. Any ideas on how to get back something other than a null response? Thanks for any help or suggestions!","One thing you can do is start by building a manual proxy using WebClient, or WebRequest/WebResponse. Construct your manual proxy to send the desired data to the WS for testing. Couple of things to check on the WSDL implementation: @@ -4687,8 +4689,11 @@ Namespace definitions need to match exactly, including trailing slashes Check the profile of the generated proxy and make sure it conforms with what your desired profile is (i.e. basic or none if needed) If you post your generated proxy we can look at it and see if there is anything out of the ordinary.",0.0,False,2,383 -2010-01-05 17:36:48.483,How to use C# client to consume Django/Python web service (all methods are returning null)?,"I have a C# command-line client that I'm testing the consumption of SOAP/WSDL via Django/Python/soaplib created WSDL. I've managed to successfully connect to the web service by adding a service reference. I then call one of service's methods, and the service processes the data I send, but it returns null instead of the integer I'm expecting. Any ideas on how to get back something other than a null response? Thanks for any help or suggestions!","We faced the similar problem while consuming a web service it was the type of data returned we were getting data in UTF-16 format. -Please check if you have proper data type in use.",0.0,False,2,383 +2010-01-06 00:47:29.197,"Speeding up the python ""import"" loader","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. +Do 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.).","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. +If 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.",0.0814518047658113,False,3,384 +2010-01-06 00:47:29.197,"Speeding up the python ""import"" loader","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. +Do 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.).","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.",0.7153027079198643,False,3,384 2010-01-06 00:47:29.197,"Speeding up the python ""import"" loader","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. Do 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.).","The first things that come to mind are: @@ -4698,11 +4703,6 @@ Make sure you don't double import, or import too much Other 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? Maybe a defrag is in order?",0.3153999413393242,False,3,384 -2010-01-06 00:47:29.197,"Speeding up the python ""import"" loader","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. -Do 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.).","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.",0.7153027079198643,False,3,384 -2010-01-06 00:47:29.197,"Speeding up the python ""import"" loader","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. -Do 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.).","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. -If 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.",0.0814518047658113,False,3,384 2010-01-06 15:09:00.097,Django: How should I store a money value?,"I'm running into a paradigm problem here. I don't know whether I should store money as a Decimal(), or if I should store it as a string and convert it to a decimal myself. My reasoning is this: PayPal requires 2 decimal places, so if I have a product that is 49 dollars even, PayPal wants to see 49.00 come across the wire. Django's DecimalField() doesn't set a decimal amount. It only stores a maximum decimal places amount. So, if you have 49 in there, and you have the field set to 2 decimal places, it'll still store it as 49. I know that Django is basically type casting when it deserializes back from the database into a Decimal (since Databases don't have decimal fields), so I'm not completely concerned with the speed issues as much as I am with the design issues of this problem. I want to do what's best for extensibility. Or, better yet, does anyone know how to configure a django DecimalField() to always format with the TWO_PLACES formatting style.","You store it as a DecimalField and manually add the decimals if you need to, as Valya said, using basic formatting techniques. @@ -4721,7 +4721,10 @@ now i need to get the byte of the variable and if it is greater than 102400 , th update : i cannot open the files , since it is present in a tar file. the content is already getting copied to a variable called 'data' i am able to print contents of the variable data. i just need to check if it has more than 102400 bytes. -thanks",len(data) gives you the size in bytes if it's binary data. With strings the size depends on the encoding used.,0.0814518047658113,False,2,387 +thanks","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: +Just open the file in binary mode +f = open(filename, 'rb') +read/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.",0.0,False,2,387 2010-01-07 12:45:37.600,how do i get the byte count of a variable in python just like wc -c gives in unix,"i am facing some problem with files with huge data. i need to skip doing some execution on those files. i get the data of the file into a variable. @@ -4729,10 +4732,7 @@ now i need to get the byte of the variable and if it is greater than 102400 , th update : i cannot open the files , since it is present in a tar file. the content is already getting copied to a variable called 'data' i am able to print contents of the variable data. i just need to check if it has more than 102400 bytes. -thanks","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: -Just open the file in binary mode -f = open(filename, 'rb') -read/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.",0.0,False,2,387 +thanks",len(data) gives you the size in bytes if it's binary data. With strings the size depends on the encoding used.,0.0814518047658113,False,2,387 2010-01-07 16:14:40.953,how to make fillable forms with reportlab in python,"can anyone please help me with creating forms in python using the reportlab lib. i am totally new to this and i would appreciate sample code thanks","Apparently reportlab does not support creating fillable pdf forms. The only thing I found about it being present in the API dates from 2003, afterwards all statements clearly say no. @@ -4750,10 +4750,9 @@ We can show the user their order is complete/failed/etc. Fin. If at all possible, UK or EU based and developer friendly. We don't need any concept of a shopping basket as we have that all handled in our code already. We have (or at least will have by launch) a proper merchant banking account - so cover services like Paypay aren't needed. -If their API covers Python (we're using Django) explicitly, all the better but I think I'm capable enough to decipher any other examples and transcode them into Python myself.","I just finished something exactly like this using First Data Global Gateway (don't really want to provide a link, can find with Google). There's no Python API because their interface is nothing but http POST. -You have the choice of gathering credit card info yourself before posting the form to their server, as long as the connection is SSL and the referring URL is known to them (meaning it's your form but you can't store or process the data first). -In the FDGG gateway ""terminal interface"" you configure your URL endpoints for authorization accepted/failed and it will POST transaction information. -I can't say it was fun and their ""test"" mode was buggy but it works. Sorry, don't know if it's available in UK/EU but it's misnamed if it isn't :)",0.1618299653758019,False,3,389 +If their API covers Python (we're using Django) explicitly, all the better but I think I'm capable enough to decipher any other examples and transcode them into Python myself.","It sounds like you want something like Worldpay or even Google Checkout. But it all depends what your turnover is, because these sorts of providers (who host the payment page themselves), tend to take a percentage of every transaction, rather than a fixed monthly fee that you can get from elsewhere. +The other thing to consider is, if you have any way of taking orders over the phone, and the phone operators need to take customers' credit card details, then your whole internal network will need to be PCI compliant, too. +If you JUST need it for a website, then that makes it easier. If you have a low turnover, then check out the sites mentioned above. If you have a high turnover, then it may work out more cost effective in the long run to get PCI-DSS certified and still keep control of credit card transactions in-house, giving you more flexibility, and cheaper transaction costs.",0.1618299653758019,False,3,389 2010-01-07 17:01:27.297,Looking for a payment gateway,"I'm looking for a payment gateway company so we can avoid tiresome PCI-DSS certification and its associated expenses. I'll get this out the way now, I don't want Paypal. It does what I want but it's really not a company I want to trust with any sort of money. It needs to support the following flow: @@ -4767,9 +4766,10 @@ We can show the user their order is complete/failed/etc. Fin. If at all possible, UK or EU based and developer friendly. We don't need any concept of a shopping basket as we have that all handled in our code already. We have (or at least will have by launch) a proper merchant banking account - so cover services like Paypay aren't needed. -If their API covers Python (we're using Django) explicitly, all the better but I think I'm capable enough to decipher any other examples and transcode them into Python myself.","It sounds like you want something like Worldpay or even Google Checkout. But it all depends what your turnover is, because these sorts of providers (who host the payment page themselves), tend to take a percentage of every transaction, rather than a fixed monthly fee that you can get from elsewhere. -The other thing to consider is, if you have any way of taking orders over the phone, and the phone operators need to take customers' credit card details, then your whole internal network will need to be PCI compliant, too. -If you JUST need it for a website, then that makes it easier. If you have a low turnover, then check out the sites mentioned above. If you have a high turnover, then it may work out more cost effective in the long run to get PCI-DSS certified and still keep control of credit card transactions in-house, giving you more flexibility, and cheaper transaction costs.",0.1618299653758019,False,3,389 +If their API covers Python (we're using Django) explicitly, all the better but I think I'm capable enough to decipher any other examples and transcode them into Python myself.","I just finished something exactly like this using First Data Global Gateway (don't really want to provide a link, can find with Google). There's no Python API because their interface is nothing but http POST. +You have the choice of gathering credit card info yourself before posting the form to their server, as long as the connection is SSL and the referring URL is known to them (meaning it's your form but you can't store or process the data first). +In the FDGG gateway ""terminal interface"" you configure your URL endpoints for authorization accepted/failed and it will POST transaction information. +I can't say it was fun and their ""test"" mode was buggy but it works. Sorry, don't know if it's available in UK/EU but it's misnamed if it isn't :)",0.1618299653758019,False,3,389 2010-01-07 17:01:27.297,Looking for a payment gateway,"I'm looking for a payment gateway company so we can avoid tiresome PCI-DSS certification and its associated expenses. I'll get this out the way now, I don't want Paypal. It does what I want but it's really not a company I want to trust with any sort of money. It needs to support the following flow: @@ -4794,10 +4794,9 @@ Try to patch a forum solution to make it ""backwards compatible"" with 0.96 (pos Use two different djangos: 0.96 and 1.x and (since we're using Apache w/mod_python) have two different Location directives; adjust PYTHONPATH for each appropriately (or use virtualenv, etc.) But will option #3 even work? I don't know enough about how django.contrib.auth and friends work so if I run two different versions of django will the user stay logged in? I didn't mention trying to patch our 0.96 project to bring it to 1.x but we don't really have the time to do that. -Any suggestions?","It's possible to expose Django 0.96 tables to 1.1 - you can use unmanaged models wrapped around database VIEWs. In other words you issue: -CREATE VIEW auth_user AS SELECT * from django096db.auth_user; -(and similar cmd for other tables) -and then you have Django 1.1 synchronized with 0.96 (assuming 0.96 tables are compatible with 1.1, I haven't checked that).",0.0,False,3,390 +Any suggestions?","It's possible, but it may be pretty painful to do option #3. +How about Option 4: bite the bullet and upgrade to Django 1.1.1. I did this with a couple of 0.97pre sites and it took less time than I thought it would. The biggest pain was dealing with admin stuff. Instead of going with separate admin.py files, we simply put the Admin classes directly below the Model classes. +I use Mercurial for my DVCS and I just cloned, hacked, merged and it worked. It took about 3-5 hours per site and that included some custom template tag munging.",1.2,True,3,390 2010-01-07 17:18:28.730,Running Different Django Versions But Sharing Authentication,"Brand new to django. We have a legacy django project using django 0.96x that does authentication, ldap, etc., and it's pretty involved so we don't want to rewrite that code. We want to add a forum solution (off the shelf) but all of the ones I've seen so far require django 1.x I'm trying to figure out how to get this working and I've narrowed it down to the following: @@ -4818,9 +4817,10 @@ Try to patch a forum solution to make it ""backwards compatible"" with 0.96 (pos Use two different djangos: 0.96 and 1.x and (since we're using Apache w/mod_python) have two different Location directives; adjust PYTHONPATH for each appropriately (or use virtualenv, etc.) But will option #3 even work? I don't know enough about how django.contrib.auth and friends work so if I run two different versions of django will the user stay logged in? I didn't mention trying to patch our 0.96 project to bring it to 1.x but we don't really have the time to do that. -Any suggestions?","It's possible, but it may be pretty painful to do option #3. -How about Option 4: bite the bullet and upgrade to Django 1.1.1. I did this with a couple of 0.97pre sites and it took less time than I thought it would. The biggest pain was dealing with admin stuff. Instead of going with separate admin.py files, we simply put the Admin classes directly below the Model classes. -I use Mercurial for my DVCS and I just cloned, hacked, merged and it worked. It took about 3-5 hours per site and that included some custom template tag munging.",1.2,True,3,390 +Any suggestions?","It's possible to expose Django 0.96 tables to 1.1 - you can use unmanaged models wrapped around database VIEWs. In other words you issue: +CREATE VIEW auth_user AS SELECT * from django096db.auth_user; +(and similar cmd for other tables) +and then you have Django 1.1 synchronized with 0.96 (assuming 0.96 tables are compatible with 1.1, I haven't checked that).",0.0,False,3,390 2010-01-12 04:28:37.153,Creating waitable objects in Python,"I more or less know how to use select() to take a list of sockets, and only return the ones that are ready to read/write something. The project I'm working on now has a class called 'user'. Each 'user' object contains its own socket. What I would like to do is pass a list of users to a select(), and get back a list of only the users where user.socket is ready to read/write. Any thoughts on where to start on this? Edit: Changed switch() to select(). I need to proofread better.","You should have your User class implement a fileno(self) method which returns self.thesocket.fileno() -- that's the way to make select work on your own classes (sockets only on windows, arbitrary files on Unix-like systems). Not sure what switch is supposed to me -- don't recognize it as a standard library (or built-in) Python concept...?",1.2,True,1,391 2010-01-15 00:04:59.403,key/value (general) and tokyo cabinet (python tc-specific) question,"i have been in the RDBMS world for many years now but wish to explore the whole nosql movement. so here's my first question: @@ -4845,8 +4845,11 @@ No big deal right? Just generate a list of numbers, shove them into an array and 6) Prepend or append time based information to the random number (i.e. unix timestamp) to reduce chances of a collision, again I get larger numbers than I need. Anyone have any clever ideas that will reduce the chances of a ""collision"" (i.e. generating a random number that is already taken) but will also allow me to keep the number ""small"" (i.e. less than a billion (or a thousand million for your europeans =)). Answer and why I accepted it: -So I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use ""small"" numbers (i.e. 9 digits instead of an MD5/etc.).","I'd rethink the problem itself... You don't seem to be doing anything sequential with the numbers... and you've got an index on the column which has them. Do they actually need to be numbers? -Consider a sha hash... you don't actually need the entire thing. Do what git or other url shortening services do, and take first 3/4/5 characters of the hash. Given that each character now has 36 possible values instead of 10, you have 2,176,782,336 combinations instead of 999,999 combinations (for six digits). Combine that with a quick check on whether the combination exists (a pure index query) and a seed like a timestamp + random number and it should do for almost any situation.",0.0,False,5,395 +So I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use ""small"" numbers (i.e. 9 digits instead of an MD5/etc.).","You can run 1) without running into the problem of too many wrong random numbers if you just decrease the random interval by one each time. +For this method to work, you will need to save the numbers already given (which you want to do anyway) and also save the quantity of numbers taken. +It is pretty obvious that, after having collected 10 numbers, your pool of possible random numbers will have been decreased by 10. Therefore, you must not choose a number between 1 and 1.000.000 but between 1 an 999.990. Of course this number is not the real number but only an index (unless the 10 numbers collected have been 999.991, 999.992, …); you’d have to count now from 1 omitting all the numbers already collected. +Of course, your algorithm should be smarter than just counting from 1 to 1.000.000 but I hope you understand the method. +I don’t like drawing random numbers until I get one which fits either. It just feels wrong.",0.0240049913710709,False,5,395 2010-01-16 09:27:22.083,Generating non-repeating random numbers in Python,"Ok this is one of those trickier than it sounds questions so I'm turning to stack overflow because I can't think of a good answer. Here is what I want: I need Python to generate a simple a list of numbers from 0 to 1,000,000,000 in random order to be used for serial numbers (using a random number so that you can't tell how many have been assigned or do timing attacks as easily, i.e. guessing the next one that will come up). These numbers are stored in a database table (indexed) along with the information linked to them. The program generating them doesn't run forever so it can't rely on internal state. No big deal right? Just generate a list of numbers, shove them into an array and use Python ""random.shuffle(big_number_array)"" and we're done. Problem is I'd like to avoid having to store a list of numbers (and thus read the file, pop one off the top, save the file and close it). I'd rather generate them on the fly. Problem is that the solutions I can think of have problems: 1) Generate a random number and then check if it has already been used. If it has been used generate a new number, check, repeat as needed until I find an unused one. Problem here is that I may get unlucky and generate a lot of used numbers before getting one that is unused. Possible fix: use a very large pool of numbers to reduce the chances of this (but then I end up with silly long numbers). @@ -4857,7 +4860,7 @@ No big deal right? Just generate a list of numbers, shove them into an array and 6) Prepend or append time based information to the random number (i.e. unix timestamp) to reduce chances of a collision, again I get larger numbers than I need. Anyone have any clever ideas that will reduce the chances of a ""collision"" (i.e. generating a random number that is already taken) but will also allow me to keep the number ""small"" (i.e. less than a billion (or a thousand million for your europeans =)). Answer and why I accepted it: -So I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use ""small"" numbers (i.e. 9 digits instead of an MD5/etc.).","Do you need this to be cryptographically secure or just hard to guess? How bad are collisions? Because if it needs to be cryptographically strong and have zero collisions, it is, sadly, impossible.",0.0,False,5,395 +So I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use ""small"" numbers (i.e. 9 digits instead of an MD5/etc.).",I think you are overestimating the problems with approach 1). Unless you have hard-realtime requirements just checking by random choice terminates rather fast. The probability of needing more than a number of iterations decays exponentially. With 100M numbers outputted (10% fillfactor) you'll have one in billion chance of requiring more than 9 iterations. Even with 50% of numbers taken you'll on average need 2 iterations and have one in a billion chance of requiring more than 30 checks. Or even the extreme case where 99% of the numbers are already taken might still be reasonable - you'll average a 100 iterations and have 1 in a billion change of requiring 2062 iterations,0.1194746325784017,False,5,395 2010-01-16 09:27:22.083,Generating non-repeating random numbers in Python,"Ok this is one of those trickier than it sounds questions so I'm turning to stack overflow because I can't think of a good answer. Here is what I want: I need Python to generate a simple a list of numbers from 0 to 1,000,000,000 in random order to be used for serial numbers (using a random number so that you can't tell how many have been assigned or do timing attacks as easily, i.e. guessing the next one that will come up). These numbers are stored in a database table (indexed) along with the information linked to them. The program generating them doesn't run forever so it can't rely on internal state. No big deal right? Just generate a list of numbers, shove them into an array and use Python ""random.shuffle(big_number_array)"" and we're done. Problem is I'd like to avoid having to store a list of numbers (and thus read the file, pop one off the top, save the file and close it). I'd rather generate them on the fly. Problem is that the solutions I can think of have problems: 1) Generate a random number and then check if it has already been used. If it has been used generate a new number, check, repeat as needed until I find an unused one. Problem here is that I may get unlucky and generate a lot of used numbers before getting one that is unused. Possible fix: use a very large pool of numbers to reduce the chances of this (but then I end up with silly long numbers). @@ -4868,7 +4871,7 @@ No big deal right? Just generate a list of numbers, shove them into an array and 6) Prepend or append time based information to the random number (i.e. unix timestamp) to reduce chances of a collision, again I get larger numbers than I need. Anyone have any clever ideas that will reduce the chances of a ""collision"" (i.e. generating a random number that is already taken) but will also allow me to keep the number ""small"" (i.e. less than a billion (or a thousand million for your europeans =)). Answer and why I accepted it: -So I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use ""small"" numbers (i.e. 9 digits instead of an MD5/etc.).",I think you are overestimating the problems with approach 1). Unless you have hard-realtime requirements just checking by random choice terminates rather fast. The probability of needing more than a number of iterations decays exponentially. With 100M numbers outputted (10% fillfactor) you'll have one in billion chance of requiring more than 9 iterations. Even with 50% of numbers taken you'll on average need 2 iterations and have one in a billion chance of requiring more than 30 checks. Or even the extreme case where 99% of the numbers are already taken might still be reasonable - you'll average a 100 iterations and have 1 in a billion change of requiring 2062 iterations,0.1194746325784017,False,5,395 +So I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use ""small"" numbers (i.e. 9 digits instead of an MD5/etc.).","Do you need this to be cryptographically secure or just hard to guess? How bad are collisions? Because if it needs to be cryptographically strong and have zero collisions, it is, sadly, impossible.",0.0,False,5,395 2010-01-16 09:27:22.083,Generating non-repeating random numbers in Python,"Ok this is one of those trickier than it sounds questions so I'm turning to stack overflow because I can't think of a good answer. Here is what I want: I need Python to generate a simple a list of numbers from 0 to 1,000,000,000 in random order to be used for serial numbers (using a random number so that you can't tell how many have been assigned or do timing attacks as easily, i.e. guessing the next one that will come up). These numbers are stored in a database table (indexed) along with the information linked to them. The program generating them doesn't run forever so it can't rely on internal state. No big deal right? Just generate a list of numbers, shove them into an array and use Python ""random.shuffle(big_number_array)"" and we're done. Problem is I'd like to avoid having to store a list of numbers (and thus read the file, pop one off the top, save the file and close it). I'd rather generate them on the fly. Problem is that the solutions I can think of have problems: 1) Generate a random number and then check if it has already been used. If it has been used generate a new number, check, repeat as needed until I find an unused one. Problem here is that I may get unlucky and generate a lot of used numbers before getting one that is unused. Possible fix: use a very large pool of numbers to reduce the chances of this (but then I end up with silly long numbers). @@ -4879,10 +4882,8 @@ No big deal right? Just generate a list of numbers, shove them into an array and 6) Prepend or append time based information to the random number (i.e. unix timestamp) to reduce chances of a collision, again I get larger numbers than I need. Anyone have any clever ideas that will reduce the chances of a ""collision"" (i.e. generating a random number that is already taken) but will also allow me to keep the number ""small"" (i.e. less than a billion (or a thousand million for your europeans =)). Answer and why I accepted it: -So I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use ""small"" numbers (i.e. 9 digits instead of an MD5/etc.).","The standard Linear Congruential random number generator's seed sequence CANNOT repeat until the full set of numbers from the starting seed value have been generated. Then it MUST repeat precisely. -The internal seed is often large (48 or 64 bits). The generated numbers are smaller (32 bits usually) because the entire set of bits are not random. If you follow the seed values they will form a distinct non-repeating sequence. -The question is essentially one of locating a good seed that generates ""enough"" numbers. You can pick a seed, and generate numbers until you get back to the starting seed. That's the length of the sequence. It may be millions or billions of numbers. -There are some guidelines in Knuth for picking suitable seeds that will generate very long sequences of unique numbers.",0.0957442344773168,False,5,395 +So I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use ""small"" numbers (i.e. 9 digits instead of an MD5/etc.).","I'd rethink the problem itself... You don't seem to be doing anything sequential with the numbers... and you've got an index on the column which has them. Do they actually need to be numbers? +Consider a sha hash... you don't actually need the entire thing. Do what git or other url shortening services do, and take first 3/4/5 characters of the hash. Given that each character now has 36 possible values instead of 10, you have 2,176,782,336 combinations instead of 999,999 combinations (for six digits). Combine that with a quick check on whether the combination exists (a pure index query) and a seed like a timestamp + random number and it should do for almost any situation.",0.0,False,5,395 2010-01-16 09:27:22.083,Generating non-repeating random numbers in Python,"Ok this is one of those trickier than it sounds questions so I'm turning to stack overflow because I can't think of a good answer. Here is what I want: I need Python to generate a simple a list of numbers from 0 to 1,000,000,000 in random order to be used for serial numbers (using a random number so that you can't tell how many have been assigned or do timing attacks as easily, i.e. guessing the next one that will come up). These numbers are stored in a database table (indexed) along with the information linked to them. The program generating them doesn't run forever so it can't rely on internal state. No big deal right? Just generate a list of numbers, shove them into an array and use Python ""random.shuffle(big_number_array)"" and we're done. Problem is I'd like to avoid having to store a list of numbers (and thus read the file, pop one off the top, save the file and close it). I'd rather generate them on the fly. Problem is that the solutions I can think of have problems: 1) Generate a random number and then check if it has already been used. If it has been used generate a new number, check, repeat as needed until I find an unused one. Problem here is that I may get unlucky and generate a lot of used numbers before getting one that is unused. Possible fix: use a very large pool of numbers to reduce the chances of this (but then I end up with silly long numbers). @@ -4893,11 +4894,10 @@ No big deal right? Just generate a list of numbers, shove them into an array and 6) Prepend or append time based information to the random number (i.e. unix timestamp) to reduce chances of a collision, again I get larger numbers than I need. Anyone have any clever ideas that will reduce the chances of a ""collision"" (i.e. generating a random number that is already taken) but will also allow me to keep the number ""small"" (i.e. less than a billion (or a thousand million for your europeans =)). Answer and why I accepted it: -So I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use ""small"" numbers (i.e. 9 digits instead of an MD5/etc.).","You can run 1) without running into the problem of too many wrong random numbers if you just decrease the random interval by one each time. -For this method to work, you will need to save the numbers already given (which you want to do anyway) and also save the quantity of numbers taken. -It is pretty obvious that, after having collected 10 numbers, your pool of possible random numbers will have been decreased by 10. Therefore, you must not choose a number between 1 and 1.000.000 but between 1 an 999.990. Of course this number is not the real number but only an index (unless the 10 numbers collected have been 999.991, 999.992, …); you’d have to count now from 1 omitting all the numbers already collected. -Of course, your algorithm should be smarter than just counting from 1 to 1.000.000 but I hope you understand the method. -I don’t like drawing random numbers until I get one which fits either. It just feels wrong.",0.0240049913710709,False,5,395 +So I will simply go with 1, and hope it's not an issue, however if it is I will go with the deterministic solution of generating all the numbers and storing them so that there is a guarentee of getting a new random number, and I can use ""small"" numbers (i.e. 9 digits instead of an MD5/etc.).","The standard Linear Congruential random number generator's seed sequence CANNOT repeat until the full set of numbers from the starting seed value have been generated. Then it MUST repeat precisely. +The internal seed is often large (48 or 64 bits). The generated numbers are smaller (32 bits usually) because the entire set of bits are not random. If you follow the seed values they will form a distinct non-repeating sequence. +The question is essentially one of locating a good seed that generates ""enough"" numbers. You can pick a seed, and generate numbers until you get back to the starting seed. That's the length of the sequence. It may be millions or billions of numbers. +There are some guidelines in Knuth for picking suitable seeds that will generate very long sequences of unique numbers.",0.0957442344773168,False,5,395 2010-01-16 13:58:20.070,"DB a table for the category and another table for the subcategory with similar fields, why?","I recently joined a new company and the development team was in the progress of a project to rebuild the database categories structure as follows: if we have category and subcategory for items, like food category and italian food category in food category. They were building a table for each category, instead of having one table and a link to the category id. @@ -4908,11 +4908,11 @@ I have asked around and it seems that some DBA prefers this design. I would like The only reason I can come up with is that you have inexperienced DBA's that does not know how to performance-tune a database, and seems to think that a table with less rows will always vastly outperform a table with more rows. With good indices, that need not be the case.",0.3869120172231254,False,1,396 2010-01-18 05:30:36.243,How would I discover the memory used by an application through a python script?,"Recently I've found myself testing an aplication in Froglogic's Squish, using Python to create test scripts. Just the other day, the question of how much memory the program is using has come up, and I've found myself unable to answer it. -It seems reasonable to assume that there's a way to query the os (windows 7) API for the information, but I've no idea where to begin. Does anyone know how I'd go about this?","In command line: tasklist /FO LIST and parse the results? -Sorry, I don't know a Pythonic way. =P",-0.1352210990936997,False,2,397 -2010-01-18 05:30:36.243,How would I discover the memory used by an application through a python script?,"Recently I've found myself testing an aplication in Froglogic's Squish, using Python to create test scripts. Just the other day, the question of how much memory the program is using has come up, and I've found myself unable to answer it. It seems reasonable to assume that there's a way to query the os (windows 7) API for the information, but I've no idea where to begin. Does anyone know how I'd go about this?","Remember that Squish allows remote testing of the application. A system parameter queried via Python directly will only apply to the case of local testing. An approach that works in either case is to call the currentApplicationContext() function that will give you a handle to the Application Under Test. It has a usedMemory property you can query. I don't recall which process property exactly is being queried but it should provide a rough indication.",0.0,False,2,397 +2010-01-18 05:30:36.243,How would I discover the memory used by an application through a python script?,"Recently I've found myself testing an aplication in Froglogic's Squish, using Python to create test scripts. Just the other day, the question of how much memory the program is using has come up, and I've found myself unable to answer it. +It seems reasonable to assume that there's a way to query the os (windows 7) API for the information, but I've no idea where to begin. Does anyone know how I'd go about this?","In command line: tasklist /FO LIST and parse the results? +Sorry, I don't know a Pythonic way. =P",-0.1352210990936997,False,2,397 2010-01-18 10:55:11.800,populating data from xml file to a sqlite database using python,"I have a question related to some guidances to solve a problem. I have with me an xml file, I have to populate it into a database system (whatever, it might be sqlite, mysql) using scripting language: Python. Does anyone have any idea on how to proceed? @@ -4928,11 +4928,11 @@ xml.dom.minidom To save tha data to DB, you can use standard module sqlite3 or look for binding to mysql. Or you may wish to use something more abstract, like SQLAlchemy or Django's ORM.",0.1016881243684853,False,1,398 2010-01-18 15:17:06.783,How can I determine if a python script is executed from crontab?,"I would like to know how can I determine if a python script is executed from crontab? -I 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).","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.",0.0679224682270276,False,4,399 +I 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).","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.",1.2,True,4,399 2010-01-18 15:17:06.783,How can I determine if a python script is executed from crontab?,"I would like to know how can I determine if a python script is executed from crontab? I 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).","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).",0.0,False,4,399 2010-01-18 15:17:06.783,How can I determine if a python script is executed from crontab?,"I would like to know how can I determine if a python script is executed from crontab? -I 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).","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.",1.2,True,4,399 +I 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).","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.",0.0679224682270276,False,4,399 2010-01-18 15:17:06.783,How can I determine if a python script is executed from crontab?,"I would like to know how can I determine if a python script is executed from crontab? I 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).","Set an environment variable at the cron command invocation. That works even within a module, as you can just check os.getenv().",0.3275988531455109,False,4,399 2010-01-18 23:31:34.390,Streaming Ironpython output to my editor,"We embed ironpython in our app sob that scripts can be executed in the context of our application. @@ -4957,9 +4957,10 @@ Threads are like processes, but they share memory. Threads often have hardware, OS, and language support, which might make them better than processes. There are lots of fussy little things that threads need to support (like locks and semaphores) so they don't get the memory they share into an inconsistent state. This makes them a little difficult to use. Locking isn't automatic (in the languages I know), so you have to be very careful with the memory they (implicitly) share.",0.0814518047658113,False,5,403 -2010-01-23 01:06:04.163,Can Someone Explain Threads to Me?,"I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered ""thread safe"". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing but a hindrance? Can someone point the way to some resources to help me learn more or explain here?","Threads are simply a way of executing multiple things simultaneously (assuming that the platform on which they are being run is capable of parallel execution). Thread safety is simply (well, nothing with threads is truly simple) making sure that the threads don't affect each other in harmful ways. -In general, you are unlikely to see systems use multiple threads for rendering graphics on the screen due to the multiple performance implications and complexity issues that may arise from that. Other tasks related to state management (or AI) can potentially be moved to separate threads however.",0.0407936753323291,False,5,403 -2010-01-23 01:06:04.163,Can Someone Explain Threads to Me?,"I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered ""thread safe"". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing but a hindrance? Can someone point the way to some resources to help me learn more or explain here?","Threads don't speed up applications. Algorithms speed up applications. Threads can be used in algorithms, if appropriate.",0.0407936753323291,False,5,403 +2010-01-23 01:06:04.163,Can Someone Explain Threads to Me?,"I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered ""thread safe"". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing but a hindrance? Can someone point the way to some resources to help me learn more or explain here?","Well someone will probably answer this better, but threads are for the purpose of having background processing that won't freeze the user interface. You don't want to stop accepting keyboard input or mouse input, and tell the user, ""just a moment, I want to finish this computation, it will only be a few more seconds."" (And yet its amazing how many times commercial programs do this. +As far as thread safe, it means a function that does not have some internal saved state. If it did you couldn't have multiple threads using it simutaneously. +As far as thread programming you just have to start doing it, and then you'll start encountering various issues unique to thread programming, for example simultaneuous access to data, in which case you have to decide to use some syncronization method such as critical sections or mutexes or something else, each one having slightly different nuances in their behavior. +As far as the differences between processes and threads (which you didn't ask) processes are an OS level entity, whereas threads are associated with a program. In certain instances your program may want to create a process rather than a thread.",0.0407936753323291,False,5,403 2010-01-23 01:06:04.163,Can Someone Explain Threads to Me?,"I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered ""thread safe"". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing but a hindrance? Can someone point the way to some resources to help me learn more or explain here?","This is a very broad topic. But here are the things I would want to know if I knew nothing about threads: They are units of execution within a single process that happen ""in parallel"" - what this means is that the current unit of execution in the processor switches rapidly. This can be achieved via different means. Switching is called ""context switching"", and there is some overhead associated with this. @@ -4969,10 +4970,9 @@ Thread-safe means that there are no race conditions, which is the term used for A couple of common ways avoid race conditions include synchronization, which excludes mutual access to shared state, or just not having any shared state at all. But this is just the tip of the iceberg - thread-safety is quite a broad topic. I hope that helps! Understand that this was a very quick introduction to something that requires a good bit of learning. I would recommend finding a resource about multithreading in your preferred language, whatever that happens to be, and giving it a thorough read.",1.2,True,5,403 -2010-01-23 01:06:04.163,Can Someone Explain Threads to Me?,"I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered ""thread safe"". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing but a hindrance? Can someone point the way to some resources to help me learn more or explain here?","Well someone will probably answer this better, but threads are for the purpose of having background processing that won't freeze the user interface. You don't want to stop accepting keyboard input or mouse input, and tell the user, ""just a moment, I want to finish this computation, it will only be a few more seconds."" (And yet its amazing how many times commercial programs do this. -As far as thread safe, it means a function that does not have some internal saved state. If it did you couldn't have multiple threads using it simutaneously. -As far as thread programming you just have to start doing it, and then you'll start encountering various issues unique to thread programming, for example simultaneuous access to data, in which case you have to decide to use some syncronization method such as critical sections or mutexes or something else, each one having slightly different nuances in their behavior. -As far as the differences between processes and threads (which you didn't ask) processes are an OS level entity, whereas threads are associated with a program. In certain instances your program may want to create a process rather than a thread.",0.0407936753323291,False,5,403 +2010-01-23 01:06:04.163,Can Someone Explain Threads to Me?,"I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered ""thread safe"". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing but a hindrance? Can someone point the way to some resources to help me learn more or explain here?","Threads don't speed up applications. Algorithms speed up applications. Threads can be used in algorithms, if appropriate.",0.0407936753323291,False,5,403 +2010-01-23 01:06:04.163,Can Someone Explain Threads to Me?,"I have been considering adding threaded procedures to my application to speed up execution, but the problem is that I honestly have no idea how to use threads, or what is considered ""thread safe"". For example, how does a game engine utilize threads in its rendering processes, or in what contexts would threads only be considered nothing but a hindrance? Can someone point the way to some resources to help me learn more or explain here?","Threads are simply a way of executing multiple things simultaneously (assuming that the platform on which they are being run is capable of parallel execution). Thread safety is simply (well, nothing with threads is truly simple) making sure that the threads don't affect each other in harmful ways. +In general, you are unlikely to see systems use multiple threads for rendering graphics on the screen due to the multiple performance implications and complexity issues that may arise from that. Other tasks related to state management (or AI) can potentially be moved to separate threads however.",0.0407936753323291,False,5,403 2010-01-23 13:27:09.017,python threading/fork?,"I'm making a python script that needs to do 3 things simultaneously. What is a good way to achieve this as do to what i've heard about the GIL i'm not so lean into using threads anymore. 2 of the things that the script needs to do will be heavily active, they will have lots of work to do and then i need to have the third thing reporting to the user over a socket when he asks (so it will be like a tiny server) about the status of the other 2 processes. @@ -5012,12 +5012,12 @@ Bottom line though - if your stored procedures are going to do database work, us I only need a solution for Linux, but a cross platform solution would be ideal.","You can use time.gmtime() to get time GMT (UTC) from any machine no matter the timezone, then you can apply your offset.",1.2,True,1,408 2010-01-30 17:48:45.377,How can I create my own corpus in the Python Natural Language Toolkit?,"I have recently expanded the names corpus in nltk and would like to know how I can turn the two files I have (male.txt, female.txt) in to a corpus so I can access them using the existing nltk.corpus methods. Does anyone have any suggestions? Many thanks, -James.","Alex is right, start with the docs, and figure out which corpus reader will work for your corpus. The simple instantiate it, given the path to your corpus file(s). As you'll see in the docs, the builtin corpora are simply instances of particular corpus reader classes. Look thru the code in the nltk.corpus package should be helpful as well.",0.0,False,2,409 -2010-01-30 17:48:45.377,How can I create my own corpus in the Python Natural Language Toolkit?,"I have recently expanded the names corpus in nltk and would like to know how I can turn the two files I have (male.txt, female.txt) in to a corpus so I can access them using the existing nltk.corpus methods. Does anyone have any suggestions? -Many thanks, James.","Came to understand how corpus reading works by looking at the source code in nltk.corpus and then looking at the corpora (located in /home/[user]/nltk_data/corpora/names - this will probably be in My Documents for XP and somewhere in User for Win7 users). The structure of the corpus and its related function will give a good understanding of how to use the different corpora available in NLTK. In my case I looked at the names variable in nltk.corpus' source code and was interested in the WordListCorpusReader function as the names corpus is simply a list of words.",0.1352210990936997,False,2,409 +2010-01-30 17:48:45.377,How can I create my own corpus in the Python Natural Language Toolkit?,"I have recently expanded the names corpus in nltk and would like to know how I can turn the two files I have (male.txt, female.txt) in to a corpus so I can access them using the existing nltk.corpus methods. Does anyone have any suggestions? +Many thanks, +James.","Alex is right, start with the docs, and figure out which corpus reader will work for your corpus. The simple instantiate it, given the path to your corpus file(s). As you'll see in the docs, the builtin corpora are simply instances of particular corpus reader classes. Look thru the code in the nltk.corpus package should be helpful as well.",0.0,False,2,409 2010-01-31 20:37:42.613,What is the keyboard shortcut to run all unit tests in the current project in PyDev + Eclipse?,"I know Ctrl + F9 runs a single file. How to run them all? If there is no such thing, how to bind one keyboard shortcut to it?",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.,0.1352210990936997,False,1,410 @@ -5035,8 +5035,8 @@ any help will be thanked for","You do it exactly the same way as you did before, 2010-02-03 21:52:53.457,"Python class has method ""set"", how to reference builtin set type?","If you have a method called ""set"" in a class and want to create a standard builtin ""set"" object somewhere else in the class, Python seems to reference the method when I do that. How can you be more specific to let Python know you mean the builtin ""set"", not the method ""set""? More specifically, set() is being created in an _____exit_____ function.","Usually method names are disambiguated from global names because you have to prefix self.. So self.set() invokes your class method and set() invokes the global set. If this doesn't help, perhaps post the code you're having trouble with.",0.1618299653758019,False,3,414 -2010-02-03 21:52:53.457,"Python class has method ""set"", how to reference builtin set type?","If you have a method called ""set"" in a class and want to create a standard builtin ""set"" object somewhere else in the class, Python seems to reference the method when I do that. How can you be more specific to let Python know you mean the builtin ""set"", not the method ""set""? More specifically, set() is being created in an _____exit_____ function.","Object attributes are always accessed via a reference, so there is no way for an object attribute to shadow a builtin.",0.2401167094949473,False,3,414 2010-02-03 21:52:53.457,"Python class has method ""set"", how to reference builtin set type?","If you have a method called ""set"" in a class and want to create a standard builtin ""set"" object somewhere else in the class, Python seems to reference the method when I do that. How can you be more specific to let Python know you mean the builtin ""set"", not the method ""set""? More specifically, set() is being created in an _____exit_____ function.",You can refer to built-in set as __builtins__.set.,0.1618299653758019,False,3,414 +2010-02-03 21:52:53.457,"Python class has method ""set"", how to reference builtin set type?","If you have a method called ""set"" in a class and want to create a standard builtin ""set"" object somewhere else in the class, Python seems to reference the method when I do that. How can you be more specific to let Python know you mean the builtin ""set"", not the method ""set""? More specifically, set() is being created in an _____exit_____ function.","Object attributes are always accessed via a reference, so there is no way for an object attribute to shadow a builtin.",0.2401167094949473,False,3,414 2010-02-04 17:02:37.263,Need a way to count entities in GAE datastore that meet a certain condition? (over 1000 entities),"I'm building an app on GAE that needs to report on events occurring. An event has a type and I also need to report by event type. For example, say there is an event A, B and C. They occur periodically at random. User logs in and creates a set of entities to which those events can be attributed. When the user comes back to check the status, I need to be able to tell how many events of A, B and/or C occurred during a specific time range, say a day or a month. The 1000 limit is throwing a wrench into how I would normally do it. I don't need to retrieve all of the entities and present them to the user, but I do need to show the total count for a specific date range. Any suggestions? @@ -5050,15 +5050,15 @@ So Im thinking in metamodels, creating a generic model defined by key/values, bu But, you are the experts community and I hope you help me to see beyond.","One, popular, option would be to use something like tags. So you'd have the stuff that's common to all items, like an item ID, name, description, price. Then you'd have some more generic tags or described tags in another table, associated with those items. You could have a tag that represents the season, or automobile specifications, etc... Of course, it really depends on how you design the system to cope with that additional information.",0.0,False,1,416 2010-02-05 16:55:56.177,Detect 64bit OS (windows) in Python,"Does anyone know how I would go about detected what bit version Windows is under Python. I need to know this as a way of using the right folder for Program Files. -Many thanks",I guess you should look in os.environ['PROGRAMFILES'] for the program files folder.,0.6075377397865339,False,4,417 -2010-02-05 16:55:56.177,Detect 64bit OS (windows) in Python,"Does anyone know how I would go about detected what bit version Windows is under Python. I need to know this as a way of using the right folder for Program Files. Many thanks","There should be a directory under Windows 64bit, a Folder called \Windows\WinSxS64 for 64 bit, under Windows 32bit, it's WinSxS.",-0.0370887312438237,False,4,417 2010-02-05 16:55:56.177,Detect 64bit OS (windows) in Python,"Does anyone know how I would go about detected what bit version Windows is under Python. I need to know this as a way of using the right folder for Program Files. -Many thanks","You should be using environment variables to access this. The program files directory is stored in the environment variable PROGRAMFILES on x86 Windows, the 32-bit program files is directory is stored in the PROGRAMFILES(X86) environment variable, these can be accessed by using os.environ('PROGRAMFILES'). -Use sys.getwindowsversion() or the existence of PROGRAMFILES(X86) (if 'PROGRAMFILES(X86)' in os.environ) to determine what version of Windows you are using.",0.0556012235839412,False,4,417 +Many thanks",I guess you should look in os.environ['PROGRAMFILES'] for the program files folder.,0.6075377397865339,False,4,417 2010-02-05 16:55:56.177,Detect 64bit OS (windows) in Python,"Does anyone know how I would go about detected what bit version Windows is under Python. I need to know this as a way of using the right folder for Program Files. Many thanks","Many of these proposed solutions, such as platform.architecture(), fail because their results depend on whether you are running 32-bit or 64-bit Python. The only reliable method I have found is to check for the existence of os.environ['PROGRAMFILES(X86)'], which is unfortunately hackish.",0.1108597247651115,False,4,417 +2010-02-05 16:55:56.177,Detect 64bit OS (windows) in Python,"Does anyone know how I would go about detected what bit version Windows is under Python. I need to know this as a way of using the right folder for Program Files. +Many thanks","You should be using environment variables to access this. The program files directory is stored in the environment variable PROGRAMFILES on x86 Windows, the 32-bit program files is directory is stored in the PROGRAMFILES(X86) environment variable, these can be accessed by using os.environ('PROGRAMFILES'). +Use sys.getwindowsversion() or the existence of PROGRAMFILES(X86) (if 'PROGRAMFILES(X86)' in os.environ) to determine what version of Windows you are using.",0.0556012235839412,False,4,417 2010-02-06 03:57:19.137,Building an Inference Engine in Python,"I am seeking direction and attempting to label this problem: I am attempting to build a simple inference engine (is there a better name?) in Python which will take a string and - 1 - create a list of tokens by simply creating a list of white space separated values @@ -5082,11 +5082,11 @@ Using a bit set uses less memory than a hash table or tree data structure, becau My specific case is this. I have a shopping cart, each cart instance has an invoice number field, however the invoice number is only generated if the cart goes to a paid status, so not all shopping cart instances will have an invoice number. I want all invoice numbers to be sequential with no gaps between them, so the default pk isn't perfect in this case, so I want a class variable that acts as a counter for the invoice numbers, and is accessable by all instances.","The default primary key will already be a unique monotonic integer (even in SQLite if you don't delete any records), so you can just use that for it.",1.2,True,1,420 2010-02-08 15:58:51.017,Making your own statements,"Is there a way to define new statements like def, with, for of my own in Python? Of course, I don't mean to override the existing statements, only create some of my own. -If so, how do I do it? Can you point me to good docs on the subject?","No, you cannot add new syntax within a Python program. The only way to alter the language is to edit and recompile the grammar file and supporting C code, to obtain a new altered interpreter, compiler and runtime.",1.2,True,3,421 +If so, how do I do it? Can you point me to good docs on the subject?","There are programming languages that let you do this (Tcl, for example), but Python isn't one of those languages.",0.0814518047658113,False,3,421 2010-02-08 15:58:51.017,Making your own statements,"Is there a way to define new statements like def, with, for of my own in Python? Of course, I don't mean to override the existing statements, only create some of my own. If so, how do I do it? Can you point me to good docs on the subject?","You can't (re)define language keywords without rewriting a compiler/interpreter/etc. What you could do perhaps is write a something like a DSL (domain-specific language) and something that translates your keyword statements into proper python statements, which might be an easier route.",0.2401167094949473,False,3,421 2010-02-08 15:58:51.017,Making your own statements,"Is there a way to define new statements like def, with, for of my own in Python? Of course, I don't mean to override the existing statements, only create some of my own. -If so, how do I do it? Can you point me to good docs on the subject?","There are programming languages that let you do this (Tcl, for example), but Python isn't one of those languages.",0.0814518047658113,False,3,421 +If so, how do I do it? Can you point me to good docs on the subject?","No, you cannot add new syntax within a Python program. The only way to alter the language is to edit and recompile the grammar file and supporting C code, to obtain a new altered interpreter, compiler and runtime.",1.2,True,3,421 2010-02-09 08:48:47.107,cross-platform html widget for pygtk,"I'm trying to write a small gui app in pygtk which needs an html-rendering widget. I'd like to be able to use it in a windows environment. Currently I'm using pywebkitgtk on my GNU/Linux system, and it works extremely well, but it seems it's not possible to use this on Windows at this time. Can anyone give me any suggestions on how to proceed? Do I need to work out how to embed IE using COM objects under Windows, and stick with pywebkitgtk on GNU/Linux? @@ -5145,7 +5145,13 @@ I've been using Tornado and I can safely say it's been the biggest hassle to get I've been using nginx as a front-end to Tornado, I could run nginx right in front of Django FastCGI workers, but those don't have the reliability of Tornado when you crank up the concurrency level. This isn't really an option for me, but I figured I might as well list it. There's also Apache, which Django recommends you use through mod_wsgi. I personally don't like Apache that much, I understand it's very, very, very mature and what not, but it just seems so... fat, compared to nginx and lighttpd. Apache/mod_python isn't even an option, as I have very limited RAM. Segue to Lighttpd! Not much to say here, I've never used it. I've heard you can run it in front of Apache/mod_wsgi or run it in front of Django FastCGI workers, also. I've heard it has minor memory leaking issues, I'm sure that could be solved with a cron job, though. -What I'm looking for is what you have seen as the ""best"" deployment of Django for your needs. Any input or clarifications of what I've said above would be more than welcome.",Personally I find one of the BSD systems far superior to Linux distros for server related tasks. Give OpenBSD or perhaps FreeBSD a chance. Once you do you´ll never go back.,0.0,False,3,429 +What I'm looking for is what you have seen as the ""best"" deployment of Django for your needs. Any input or clarifications of what I've said above would be more than welcome.","At the place I rent server, they have shaved down the Ubuntu images to bare minimum. Presumably because they had to make a special image anyway with just the right drivers and such in it, but I don't know exactly. +They have even removed wget and nano. So you get all the apt-get goodness and not a whole lot of ""cookie-cutter"" OS. +Just saying this because I would imagine that this is the way it is done almost everywhere and therefore playing around with a normal Ubuntu-server install will not provide you with the right information to make your decision. +Other than that, I agree with the others, that it is not much of a lock-in so you could just try something. +On the webserver-side I would suggest taking a look at cherokee, if have not done so already. +It might not be your cup of joe, but there is no harm in trying it. +I prefer the easy setup of both Ubuntu and Cherokee. Although I play around with a lot of things for fun, I prefer these for my business. I have other things to do than manage servers, so any solution that helps me do it faster, is just good. If these projects are mostly for fun then this will most likely not apply since you won't get a whole lot of experience from these easy-setup-with-nice-gui-and-very-helpfull-wizards",0.296905446847765,False,3,429 2010-02-13 08:47:09.740,Recommended Django Deployment,"Short version: How do you deploy your Django servers? What application server, front-end (if any, and by front-end I mean reverse proxy), and OS do you run it on? Any input would be greatly appreciated, I'm quite a novice when it comes to Python and even more as a server administrator. Long version: I'm migrating between server hosts, so much for weekends... it's not all bad, though. I have the opportunity to move to a different, possibly better ""deployment"" of Django. @@ -5203,13 +5209,7 @@ I've been using Tornado and I can safely say it's been the biggest hassle to get I've been using nginx as a front-end to Tornado, I could run nginx right in front of Django FastCGI workers, but those don't have the reliability of Tornado when you crank up the concurrency level. This isn't really an option for me, but I figured I might as well list it. There's also Apache, which Django recommends you use through mod_wsgi. I personally don't like Apache that much, I understand it's very, very, very mature and what not, but it just seems so... fat, compared to nginx and lighttpd. Apache/mod_python isn't even an option, as I have very limited RAM. Segue to Lighttpd! Not much to say here, I've never used it. I've heard you can run it in front of Apache/mod_wsgi or run it in front of Django FastCGI workers, also. I've heard it has minor memory leaking issues, I'm sure that could be solved with a cron job, though. -What I'm looking for is what you have seen as the ""best"" deployment of Django for your needs. Any input or clarifications of what I've said above would be more than welcome.","At the place I rent server, they have shaved down the Ubuntu images to bare minimum. Presumably because they had to make a special image anyway with just the right drivers and such in it, but I don't know exactly. -They have even removed wget and nano. So you get all the apt-get goodness and not a whole lot of ""cookie-cutter"" OS. -Just saying this because I would imagine that this is the way it is done almost everywhere and therefore playing around with a normal Ubuntu-server install will not provide you with the right information to make your decision. -Other than that, I agree with the others, that it is not much of a lock-in so you could just try something. -On the webserver-side I would suggest taking a look at cherokee, if have not done so already. -It might not be your cup of joe, but there is no harm in trying it. -I prefer the easy setup of both Ubuntu and Cherokee. Although I play around with a lot of things for fun, I prefer these for my business. I have other things to do than manage servers, so any solution that helps me do it faster, is just good. If these projects are mostly for fun then this will most likely not apply since you won't get a whole lot of experience from these easy-setup-with-nice-gui-and-very-helpfull-wizards",0.296905446847765,False,3,429 +What I'm looking for is what you have seen as the ""best"" deployment of Django for your needs. Any input or clarifications of what I've said above would be more than welcome.",Personally I find one of the BSD systems far superior to Linux distros for server related tasks. Give OpenBSD or perhaps FreeBSD a chance. Once you do you´ll never go back.,0.0,False,3,429 2010-02-15 09:42:17.037,How to read from stdin or from a file if no data is piped in Python?,"I have a CLI script and want it to read data from a file. It should be able to read it in two ways : cat data.txt | ./my_script.py @@ -5231,10 +5231,10 @@ I don't know how to implement ""if nothing in stdin, read from a file in args"" I'd like a portable way to do this if possible.","There is no reliable way to detect if sys.stdin is connected to anything, nor is it appropriate do so (e.g., the user wants to paste the data in). Detect the presence of a filename as an argument, and use stdin if none is found.",0.2012947653214861,False,1,430 2010-02-15 19:11:23.243,Can you auto hide frames/dialogs using wxPython?,"I would like to create an application that has 3-4 frames (or windows) where each frame is attached/positioned to a side of the screen (like a task bar). When a frame is inactive I would like it to auto hide (just like the Windows task bar does; or the dock in OSX). When I move my mouse pointer to the position on the edge of the screen where the frame is hidden, I would like it to come back into focus. The application is written in Python (using wxPython for the basic GUI aspects). Does anyone know how to do this in Python? I'm guessing it's probably OS dependent? If so, I'd like to focus on Windows first. -I don't do GUI programming very often so my apologies if this makes no sense at all.","Personally, I would combine the EVT_ENTER_WINDOW and EVT_LEAVE_WINDOW that FogleBird mentioned with a wx.Timer. Then whenever it the frame or dialog is inactive for x seconds, you would just call its Hide() method.",0.0,False,2,431 +I don't do GUI programming very often so my apologies if this makes no sense at all.","I think you could easily just make a window that is the same size as the desktop then do some while looping for an inactivity variable based on mouse position, then thread off a timer for loop for the 4 inactivity variables. I'd personally design it so that when they reach 0 from 15, they change size and position to become tabular and create a button on them to reactivate. lots of technical work on this one, but easily done if you figure it out",0.0,False,2,431 2010-02-15 19:11:23.243,Can you auto hide frames/dialogs using wxPython?,"I would like to create an application that has 3-4 frames (or windows) where each frame is attached/positioned to a side of the screen (like a task bar). When a frame is inactive I would like it to auto hide (just like the Windows task bar does; or the dock in OSX). When I move my mouse pointer to the position on the edge of the screen where the frame is hidden, I would like it to come back into focus. The application is written in Python (using wxPython for the basic GUI aspects). Does anyone know how to do this in Python? I'm guessing it's probably OS dependent? If so, I'd like to focus on Windows first. -I don't do GUI programming very often so my apologies if this makes no sense at all.","I think you could easily just make a window that is the same size as the desktop then do some while looping for an inactivity variable based on mouse position, then thread off a timer for loop for the 4 inactivity variables. I'd personally design it so that when they reach 0 from 15, they change size and position to become tabular and create a button on them to reactivate. lots of technical work on this one, but easily done if you figure it out",0.0,False,2,431 +I don't do GUI programming very often so my apologies if this makes no sense at all.","Personally, I would combine the EVT_ENTER_WINDOW and EVT_LEAVE_WINDOW that FogleBird mentioned with a wx.Timer. Then whenever it the frame or dialog is inactive for x seconds, you would just call its Hide() method.",0.0,False,2,431 2010-02-16 04:06:23.740,Subscription web/desktop app [PYTHON],"Firstly pardon me if i've yet again failed to title my question correctly. I am required to build an app to manage magazine subscriptions. The client wants to enter subscriber data and then receive alerts at pre-set intervals such as when the subscription of a subscriber is about to expire and also the option to view all subscriber records at any time. Also needed is the facility to send an SMS/e-mail to particular subscribers reminding them for subscription renewal. I am very familiar with python but this will be my first real project. I have decided to build it as a web app using django, allowing the admin user the ability to view/add/modify all records and others to subscribe. What options do I have for integrating an online payment service? Also how do I manage the SMS alert functionality? Any other pointers/suggestions would be welcome. @@ -5252,10 +5252,10 @@ So, which would be better for this app, Java or Python? (In case it comes up, I don't want to make it browser-based at all. I've dealt with individual computers' browser settings breaking programs, and that goes against part 2 of my top priority - maximum compatibility.) Thank you. Update: It will need a gui, and I'd like to be able to do a little bit of customization on it (or use a non-standard, or maybe a non-built-in one) to make it pop a little. -Update 2: Truthfully, I really am only concerned with Windows computers. I am considering Java only for its reliability as a platform.","The largest issue I can think of is the need to install an interpreter. -With Java, a lot of people will already have that interpreter installed, although you won't necessarily know which version. It may be wise to include the installer for Java with the program. -With Python, you're going to have to install the interpreter on each computer, too. -One commenter mentioned .NET. .NET 2.0 has a fairly high likelyhood of being installed than either Java or Python on Windows machines. The catch is that you can't (easily) install it on OSX or Linux.",0.0814518047658113,False,2,434 +Update 2: Truthfully, I really am only concerned with Windows computers. I am considering Java only for its reliability as a platform.","If you're going to install only (or mostly) on Windows, I'd go with .Net. +If you have experience with C++, then C# would be natural to you, but if you're comfortable with VBA, you can try VB.NET, but if you prefer Python, then there is IronPython or can give a try to IronRuby, but the best of all is you can mix them all as they apply to different parts of your project. +In the database area you'll have excellent integration with SQL Server Express, and in the GUI area, Swing can't beat the ease of use of WinForms nor the sophistication of WPF/Silverlight. +As an added bonus, you can have your application automatically updated with ClickOnce.",1.2,True,2,434 2010-02-17 16:20:52.410,Help for novice choosing between Java and Python for app with sql db,"I'm going to write my first non-Access project, and I need advice on choosing the platform. I will be installing it on multiple friends' and family's computers, so (since I'm sure many, many platforms would suffice just fine for my app), my highest priority has two parts: 1) ease of install for the non-technical user and, 2) minimizing compatibility problems. I want to be able to fix bugs and make changes and roll them out without having to troubleshoot OS and program conflicts on their computers (or at least keeping those things to the absolute minimum-this is why these concerns are my highest priority in choosing a platform.) I have narrowed it down to Python or Java. I like Java's use of the JVM, which seems like would serve to protect against incompatibilities on individual computers nicely. And I've heard a lot of good things about Python, but I don't know how much more prone to incompatibilities it is vs Java. In case it is important, I know the app will definitely use some flavor of a free server-enabled SQL db (server-enabled because I want to be able to run the app from multiple computers), but I don't know which to use yet. I thought I could decide that next. My experience level: I've taken a C++ (console app only) class and done some VBA in Access, but mostly I'm going to have to jump in and learn as I go. So of course I don't know much about all of this. I'm not in the computer field, this is just a hobby. @@ -5263,10 +5263,10 @@ So, which would be better for this app, Java or Python? (In case it comes up, I don't want to make it browser-based at all. I've dealt with individual computers' browser settings breaking programs, and that goes against part 2 of my top priority - maximum compatibility.) Thank you. Update: It will need a gui, and I'd like to be able to do a little bit of customization on it (or use a non-standard, or maybe a non-built-in one) to make it pop a little. -Update 2: Truthfully, I really am only concerned with Windows computers. I am considering Java only for its reliability as a platform.","If you're going to install only (or mostly) on Windows, I'd go with .Net. -If you have experience with C++, then C# would be natural to you, but if you're comfortable with VBA, you can try VB.NET, but if you prefer Python, then there is IronPython or can give a try to IronRuby, but the best of all is you can mix them all as they apply to different parts of your project. -In the database area you'll have excellent integration with SQL Server Express, and in the GUI area, Swing can't beat the ease of use of WinForms nor the sophistication of WPF/Silverlight. -As an added bonus, you can have your application automatically updated with ClickOnce.",1.2,True,2,434 +Update 2: Truthfully, I really am only concerned with Windows computers. I am considering Java only for its reliability as a platform.","The largest issue I can think of is the need to install an interpreter. +With Java, a lot of people will already have that interpreter installed, although you won't necessarily know which version. It may be wise to include the installer for Java with the program. +With Python, you're going to have to install the interpreter on each computer, too. +One commenter mentioned .NET. .NET 2.0 has a fairly high likelyhood of being installed than either Java or Python on Windows machines. The catch is that you can't (easily) install it on OSX or Linux.",0.0814518047658113,False,2,434 2010-02-19 08:41:25.437,How to open a Pyqt 3.3 ui file with QtDesigner 4?,"I've a PyQt 4 installed (I can't find PyQt 3 for Windows) and I would like to open a QtDesigner ui file which has been created with QtDesigner 3.3. When I open this file I've the following message: Please use uic3 -convert to convert to Qt4 @@ -5276,9 +5276,14 @@ Additional quastion: Where to download PyQy3 binaries for Windows? Thanks in advance","Try finding pyuic3 or rather pyuic4. Since you are using PyQt all your qt tools have py in front (like pyrcc4 or pyuicc4). I am not sure, that there are pyqt3 binaries for windows. Are you sure that Phil Thompson did PyQt3 also for windows at the time? If so, they would be on riverbank site, I guess, but I can't find them there. Tried compiling the source yourself?",0.2012947653214861,False,1,435 2010-02-19 13:28:51.633,how to have global variables among different modules in Python,"I investigated that scope of global variables in python is limited to the module. But I need the scope to be global among different modules. Is there such a thing? I played around __builtin__ but no luck. -thanks in advance!","Scopes beyond the local must be written to via a reference to the scope, or after a global or nonlocal (3.x+) directive.",0.0,False,2,436 -2010-02-19 13:28:51.633,how to have global variables among different modules in Python,"I investigated that scope of global variables in python is limited to the module. But I need the scope to be global among different modules. Is there such a thing? I played around __builtin__ but no luck. thanks in advance!","Python does not support globals shared between several modules: this is a feature. Code that implicitly modifies variables used far away is confusing and unmaintainable. The real solution is to encapsulate all state within a class and pass its instance to anything that has to modify it. This can make code clearer, more maintainable, more testable, more modular, and more expendable.",0.3869120172231254,False,2,436 +2010-02-19 13:28:51.633,how to have global variables among different modules in Python,"I investigated that scope of global variables in python is limited to the module. But I need the scope to be global among different modules. Is there such a thing? I played around __builtin__ but no luck. +thanks in advance!","Scopes beyond the local must be written to via a reference to the scope, or after a global or nonlocal (3.x+) directive.",0.0,False,2,436 +2010-02-19 16:31:00.477,Scripting language for trading strategy development,"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. +I'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.","Existing languages are ""a little ""low level"" for my target users."" +Yet, all you need is ""a minimum of support for looping, simple arithmatic, logical expression evaluation"" +I 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? +What's the disconnect? Feel free to update your question to expand on what the problem is.",0.0,False,5,437 2010-02-19 16:31:00.477,Scripting language for trading strategy development,"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. I'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.","Define the language first -- if possible, use the pseudo-language called EBN, it's very simple (see the Wikipedia entry). Then 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. @@ -5286,11 +5291,6 @@ Once you start working on it, you may find that you go back to your definition a 2010-02-19 16:31:00.477,Scripting language for trading strategy development,"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. I'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.","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.",0.0,False,5,437 2010-02-19 16:31:00.477,Scripting language for trading strategy development,"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. -I'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.","Existing languages are ""a little ""low level"" for my target users."" -Yet, all you need is ""a minimum of support for looping, simple arithmatic, logical expression evaluation"" -I 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? -What's the disconnect? Feel free to update your question to expand on what the problem is.",0.0,False,5,437 -2010-02-19 16:31:00.477,Scripting language for trading strategy development,"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. I'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.","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.",0.0,False,5,437 2010-02-19 16:31:00.477,Scripting language for trading strategy development,"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. I'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.","Custom-made modules are going to be needed, no matter what you choose, that define your firm's high level constructs. @@ -5386,11 +5386,8 @@ My issue is not pure presentation that can be done with templates, but also that Similarly you can use a context processor to put the current group into the context for every view, and then put conditionals in the templates to select which numbers to show. The other option is to have two separate sets of views for the two different groups. Then use decorators on the views to make sure the groups only go to the views that are for them.",0.0,False,1,443 2010-02-22 13:49:20.610,How do I store a dict/list in a database?,"If I have a dictionary full of nested stuff, how do I store that in a database, as a string? and then, convert it back to a dictionary when I'm ready to parse? -Edit: I just want to convert it to a string...and then back to a dictionary.","Options: -1) Pickling -2) XML -3) JSON -others I am sure. It has a lot to do on how much portability means to you.",0.3153999413393242,False,3,444 +Edit: I just want to convert it to a string...and then back to a dictionary.","There are any number of serialization methods out there, JSON is readable, reasonably compact, supported natively, and portable. I prefer it over pickle, since the latter can execute arbitrary code and potentially introduce security holes, and because of its portability. +Depending on your data's layout, you may also be able to use your ORM to directly map the data into database constructs.",0.1618299653758019,False,3,444 2010-02-22 13:49:20.610,How do I store a dict/list in a database?,"If I have a dictionary full of nested stuff, how do I store that in a database, as a string? and then, convert it back to a dictionary when I'm ready to parse? Edit: I just want to convert it to a string...and then back to a dictionary.","You have two options @@ -5404,8 +5401,11 @@ use cPickle: pros: easy to use, fast and native python way to do serialization. cons: only python based apps can have access to the data.",0.0814518047658113,False,3,444 2010-02-22 13:49:20.610,How do I store a dict/list in a database?,"If I have a dictionary full of nested stuff, how do I store that in a database, as a string? and then, convert it back to a dictionary when I'm ready to parse? -Edit: I just want to convert it to a string...and then back to a dictionary.","There are any number of serialization methods out there, JSON is readable, reasonably compact, supported natively, and portable. I prefer it over pickle, since the latter can execute arbitrary code and potentially introduce security holes, and because of its portability. -Depending on your data's layout, you may also be able to use your ORM to directly map the data into database constructs.",0.1618299653758019,False,3,444 +Edit: I just want to convert it to a string...and then back to a dictionary.","Options: +1) Pickling +2) XML +3) JSON +others I am sure. It has a lot to do on how much portability means to you.",0.3153999413393242,False,3,444 2010-02-22 18:17:39.080,Python: How to Access Linux Paths,"Using Python, how does one parse/access files with Linux-specific features, like ""~/.mozilla/firefox/*.default""? I've tried this, but it doesn't work. Thanks","It's important to remember: @@ -5419,8 +5419,8 @@ Look up logging.config on how to setup your handlers from code or json.",0.16182 2010-02-22 23:18:29.530,How do I find missing dates in a list of sorted dates?,In Python how do I find all the missing days in a sorted list of dates?,"Put the dates in a set and then iterate from the first date to the last using datetime.timedelta(), checking for containment in the set each time.",0.0453204071731508,False,1,447 2010-02-23 12:08:12.327,print_r functionality in iPython,"Is there a way to get PHP-like print_r(object) funcionality in iPython? I know I can use '?' to get info about an object, but how do I view the values of the object?",dir(object) will give you all its attribute names.,0.2012947653214861,False,1,448 -2010-02-24 00:34:30.633,How do I prevent my Python application from automatically closing once reaching the end of code?,"I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6.","Well, I guess you mean the terminal that Windows opens for you when you run a python file is closed too fast. You can add raw_input('Press Enter to exit') right before your program would exit. It tells Python to wait for input before exiting.",0.9974579674738372,False,3,449 2010-02-24 00:34:30.633,How do I prevent my Python application from automatically closing once reaching the end of code?,"I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6.","ask user to enter one more variable and print ""Press enter to exit...""",0.0,False,3,449 +2010-02-24 00:34:30.633,How do I prevent my Python application from automatically closing once reaching the end of code?,"I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6.","Well, I guess you mean the terminal that Windows opens for you when you run a python file is closed too fast. You can add raw_input('Press Enter to exit') right before your program would exit. It tells Python to wait for input before exiting.",0.9974579674738372,False,3,449 2010-02-24 00:34:30.633,How do I prevent my Python application from automatically closing once reaching the end of code?,"I'm new to programming, especially Python. I'm trying to make an application that converts Fahrenheit to Celsius, but I don't know how to make the program stay open. Whenever it reaches the end of the code, it automatically closes before the user can see his or her results. I'm using Python 2.6.","As the other people say, just ask for input to get it to hold. However, I would recommend running your Python scripts in a different manner in Windows. Using the IDLE IDE (should have come with your distribution), just open the script you want to run and press F5. Then, not only can you see the output for as long as you like, but you can also examine any variables that were assigned interactively. This is very handy especially when you are just starting to program in Python. You can also run scripts from the command line, but I would recommend use IDLE if you're just starting out.",0.3869120172231254,False,3,449 2010-02-24 02:59:35.487,django+flex: Debugging strategies,"I love django, and I like flex. Django for it's cool debugging system (those yellow pages helps a lot to find bugs in my code), and flex for it possibilities. @@ -5439,26 +5439,27 @@ I use a combination of these to debug my code.",1.2,True,1,450 Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? -Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","My boss's rule of thumb is any time there's a learning curve, it can triple the time to write the application. So, if Java would take you two weeks, then Python may take about 6.",0.1684471436049839,False,11,451 +Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","It always take longer than you think. +Try writing a small program doing just a bit of what you need. If you are to write a program with a GUI then make small program showing a frame with Hello World and an Ok-button and see how hard that is.",0.1352210990936997,False,11,451 2010-02-24 17:53:26.977,How much leeway do I have to leave myself to learn a new language?,"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? -Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","Python is like baby java, you'll pick it up in a breeze.",0.1016881243684853,False,11,451 +Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","Are you just programming or are you designing/architecting? +If you are coding according to a design that an experienced Python resource has layed-out then I'd give myself 3-4 times as long since you've described this as a small, fairly simple project. +If you are designing/architecting this yourself then you're taking on a big risk by trying to learn a new language at the same time. There's too much chance that you could design something at the onset that is core to your design, only to figure-out later that it doesn't work and you need to rewrite alot of stuff because of it. +That being said I would present the risks and such to your manager (showing your obvious enthusiasm for learning Python) and let him make the call.",0.0,False,11,451 2010-02-24 17:53:26.977,How much leeway do I have to leave myself to learn a new language?,"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? -Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","It always take longer than you think. -Try writing a small program doing just a bit of what you need. If you are to write a program with a GUI then make small program showing a frame with Hello World and an Ok-button and see how hard that is.",0.1352210990936997,False,11,451 +Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","You have roughly 5 weeks to complete the project. If you're confident the Java version would take 2 weeks, that leaves 3 weeks to flail around with the Python version until you have to give up. I say go for it. Python is relatively easy to pick up. I think three weeks of work is enough to time to know whether you can finish by the deadline. +IMHO, this is a great excuse for you to learn a new language. Keep updating your manager regularly with your progress. I think the right decision will become apparent as time goes on.",0.2336958171850616,False,11,451 2010-02-24 17:53:26.977,How much leeway do I have to leave myself to learn a new language?,"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? -Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","Are you just programming or are you designing/architecting? -If you are coding according to a design that an experienced Python resource has layed-out then I'd give myself 3-4 times as long since you've described this as a small, fairly simple project. -If you are designing/architecting this yourself then you're taking on a big risk by trying to learn a new language at the same time. There's too much chance that you could design something at the onset that is core to your design, only to figure-out later that it doesn't work and you need to rewrite alot of stuff because of it. -That being said I would present the risks and such to your manager (showing your obvious enthusiasm for learning Python) and let him make the call.",0.0,False,11,451 +Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","Python is like baby java, you'll pick it up in a breeze.",0.1016881243684853,False,11,451 2010-02-24 17:53:26.977,How much leeway do I have to leave myself to learn a new language?,"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? @@ -5469,8 +5470,8 @@ Keep learning Python and automate some of the routine activities you do using Py Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? -Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","You have roughly 5 weeks to complete the project. If you're confident the Java version would take 2 weeks, that leaves 3 weeks to flail around with the Python version until you have to give up. I say go for it. Python is relatively easy to pick up. I think three weeks of work is enough to time to know whether you can finish by the deadline. -IMHO, this is a great excuse for you to learn a new language. Keep updating your manager regularly with your progress. I think the right decision will become apparent as time goes on.",0.2336958171850616,False,11,451 +Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","My personal preference is to learn new languages on personal projects, and use tools I already understand on professional projects. So if it was me, I'd do the project in Java, and do a few little Python projects at home. +But of course, you learn a lot more a lot faster when you are using a new language ""for real"" forty hours a week, so if you have adequate support from management and co-workers, then take advantage of the opportunity.",0.0,False,11,451 2010-02-24 17:53:26.977,How much leeway do I have to leave myself to learn a new language?,"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? @@ -5482,11 +5483,6 @@ It mostly comes down to a question of whether you're comfortable with assuming t Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? -Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","I'd say if you want to avoid possible headaches, do it in Java and learn Python at home, by trying to re-create a similar application to the one you do at work, if you want something which feels real. It's likely that if you arent familiar with Python you arent going to take advantage of its capabilities anyway. Once I took a look at the first Python application I made, and it looked like I wrote an Object Pascal application in Python syntax",0.0340004944420038,False,11,451 -2010-02-24 17:53:26.977,How much leeway do I have to leave myself to learn a new language?,"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? -Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. -Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? -And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","Generally, if I'm not familiar with a language, I allow at least a month to get somewhat comfortable with it. Two or three months if it's outside my ""comfort zone"" of C-like languages. Having said that, I think Java and Python are similar enough that you might trim that a bit. Also, based on your own history, how good are your estimates when you're familiar with a language? If you think it will take two weeks to do it in Java, how well can you rely on that estimate? Personally, I'm sometimes way under, even when I think I'm being pessimistic, but maybe you're better at estimating than me. A part of me is tempted to say ""Go for Python"". That's at least partly because I'm a Python fan. However, as a new hire, you probably ought to make a good impression, and I think you'll do that better by delivering on time (or early) than by learning Python. @@ -5510,8 +5506,12 @@ Another thing, that I draw from experience: never believe that a project is done Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? -Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","My personal preference is to learn new languages on personal projects, and use tools I already understand on professional projects. So if it was me, I'd do the project in Java, and do a few little Python projects at home. -But of course, you learn a lot more a lot faster when you are using a new language ""for real"" forty hours a week, so if you have adequate support from management and co-workers, then take advantage of the opportunity.",0.0,False,11,451 +Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","My boss's rule of thumb is any time there's a learning curve, it can triple the time to write the application. So, if Java would take you two weeks, then Python may take about 6.",0.1684471436049839,False,11,451 +2010-02-24 17:53:26.977,How much leeway do I have to leave myself to learn a new language?,"I'm a relatively new hire, and I'm starting on a small, fairly simple project. The language that this project will be implemented in is still to be determined. The question basically boils down to - Java or Python? +Here's the dilemma: My manager would prefer it to be done in Python. I don't object to that, but I have no experience in Python. I'd really love to learn Python and think I could manage it fairly quickly (especially as it's a small project). BUT the project is due at the end of March and must be ready by then. So they'd rather have it in Java and on time than in Python and late, and they don't want to pressure me to do it in Python if I think I can't make it on time. +Sorry about the background - but my question basically is, how long does it take, on average, to adapt to a new language? I know this is subjective and personalized, and depends on how fast the particular programmer is... but talking about an average programmer, or even a somewhat fast one that picks up things quickly, what percentage of an increase does programming in a non-native language (but with similar concepts) cause? As in, if this project would take me about 2 weeks in Java or a .NET language, how much longer can it take me in Python? Can I assume that having double the amount of time (i.e. a new, unfamiliar language causes a 50% increase in programming time) is adequate? +And included in this question - from what I've heard, it seems to be pretty easy/intuitive to switch over from Java to Python. Is this true...? +Thanks everyone for all the answers! I didn't realize there are so many sides to this question... I will try to choose an answer soon - each response made me look at it a different way and it's hard to choose one answer.","I'd say if you want to avoid possible headaches, do it in Java and learn Python at home, by trying to re-create a similar application to the one you do at work, if you want something which feels real. It's likely that if you arent familiar with Python you arent going to take advantage of its capabilities anyway. Once I took a look at the first Python application I made, and it looked like I wrote an Object Pascal application in Python syntax",0.0340004944420038,False,11,451 2010-02-24 23:11:43.677,How to set the program title in python,"I have been building a large python program for a while, and would like to know how I would go about setting the title of the program? On a mac the title of program, which has focus, is shown in the top left corner of the screen, next the apple menu. Currently this only shows the word ""Python"", but I would of course like to my program's title there instead.","Since your program is interpreted by Python, then what actually is run is Python itself - the interpreter program. You would have to have your Python script merged with Python into a single executable and that would be able to have a separate name. For windows there is py2exe, that does that, but I have no idea if there is a similar tool for Mac OS (and if there is any need for that, there is some BSD under the hood right?).",0.5457054096481145,False,1,452 2010-02-25 01:00:55.273,"which is the best way to get the value of 'session_key','uid','expires'","i have a string ''' @@ -5522,30 +5522,30 @@ But of course, you learn a lot more a lot faster when you are using a new langua how to get the value . thanks","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.",0.0,False,1,453 2010-02-26 23:57:23.183,starting Python IDLE from command line to edit scripts,"I've tried many variations of this command: idle.py -e filepath, but it simply starts IDLE like normal, not opening any extra windows for editing, and not throwing any errors. -So how can I do the equivalent of opening IDLE, file>open>filepath via the command line (or perhaps even a Python module)?","Just add IDLE's path to your PATH environment variable. -For example I created an environment variable called IDLE_PATH and set the value to C:\Python27\Lib\idlelib -Then in my PATH variable I added ;%IDLE_PATH%; and open a new cmd prompt or in console2 just open a new tab and run idle to open the file, you will be able to do this from any directory. In IPython console add an ! before the command, for example !idle test.py. -Congrates, Now you're a python pimp!",0.0,False,2,454 -2010-02-26 23:57:23.183,starting Python IDLE from command line to edit scripts,"I've tried many variations of this command: idle.py -e filepath, but it simply starts IDLE like normal, not opening any extra windows for editing, and not throwing any errors. So how can I do the equivalent of opening IDLE, file>open>filepath via the command line (or perhaps even a Python module)?","first make sure you have location of idle in path I am using ""python3.5"".So mine looks like this: C:\Program Files\Python35\Lib\idlelib.Yours may differ. use this following command:idle -r file_name.py to run the file or just idle file_name.py to edit or start idle -r file_name.py ^&exit",0.1160922760327606,False,2,454 +2010-02-26 23:57:23.183,starting Python IDLE from command line to edit scripts,"I've tried many variations of this command: idle.py -e filepath, but it simply starts IDLE like normal, not opening any extra windows for editing, and not throwing any errors. +So how can I do the equivalent of opening IDLE, file>open>filepath via the command line (or perhaps even a Python module)?","Just add IDLE's path to your PATH environment variable. +For example I created an environment variable called IDLE_PATH and set the value to C:\Python27\Lib\idlelib +Then in my PATH variable I added ;%IDLE_PATH%; and open a new cmd prompt or in console2 just open a new tab and run idle to open the file, you will be able to do this from any directory. In IPython console add an ! before the command, for example !idle test.py. +Congrates, Now you're a python pimp!",0.0,False,2,454 2010-02-28 19:35:36.417,The difference between python dict and tr1::unordered_map in C++,"I have a question related to understanding of how python dictionaries work. I remember reading somewhere strings in python are immutable to allow hashing, and it is the same reason why one cannot directly use lists as keys, i.e. the lists are mutable (by supporting .append) and hence they cannot be used as dictionary keys. I wanted to know how does implementation of unordered_map in C++ handles these cases. (since strings in C++ are mutable)","Keys in all C++ map/set containers are const and thus immutable (after added to the container). Notice that C++ containers are not specific to string keys, you can use any objects, but the constness will prevent modifications after the key is copied to the container.",1.2,True,1,455 -2010-03-01 05:02:35.203,Automate Windows GUI operations with Python,"I want to make a Python script that automates the process of setting up a VPN server in Windows XP, but the only way I know how to do it is using the Windows GUI dialogs. How would I go about figuring out what those dialogs are doing to the system and designing a Python script to automate it?",Find out how to do what you want using commands (on the command line) and script these commands instead.,0.0679224682270276,False,2,456 2010-03-01 05:02:35.203,Automate Windows GUI operations with Python,"I want to make a Python script that automates the process of setting up a VPN server in Windows XP, but the only way I know how to do it is using the Windows GUI dialogs. How would I go about figuring out what those dialogs are doing to the system and designing a Python script to automate it?","PyAutoGUI can be installed with pip from PyPI. It's cross platform and can control the mouse & keyboard. It has the features of pywinauto and a few more on top. It can't identify windows or GUI controls, but it does have basic screenshot & image recognition features to click on particular buttons. And it's well-documented and maintained. pip install pyautogui",0.0,False,2,456 +2010-03-01 05:02:35.203,Automate Windows GUI operations with Python,"I want to make a Python script that automates the process of setting up a VPN server in Windows XP, but the only way I know how to do it is using the Windows GUI dialogs. How would I go about figuring out what those dialogs are doing to the system and designing a Python script to automate it?",Find out how to do what you want using commands (on the command line) and script these commands instead.,0.0679224682270276,False,2,456 +2010-03-01 23:49:13.073,Pure Python in Xcode?,"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. +Thanks in advance.","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.",0.0,False,2,457 2010-03-01 23:49:13.073,Pure Python in Xcode?,"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. Thanks in advance.","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. Pretty 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. Google will reveal all, including a native version of Emacs for Mac OS X.",0.0,False,2,457 -2010-03-01 23:49:13.073,Pure Python in Xcode?,"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. -Thanks in advance.","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.",0.0,False,2,457 2010-03-03 17:22:29.117,How do I run Javascript tests in Windmill when using test_windmill for Django?,"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. Does anyone know how to do this? Thanks @@ -5588,7 +5588,7 @@ list_of_fonts=os.popen(""xslfonts"").readlines() To render a string into an image using a font, I could use PIL (Python Imaging Library) and the ImageFont class. However, 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). -Does anyone has an idea on how I can do that? Thanks!","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.",0.2012947653214861,False,2,460 +Does anyone has an idea on how I can do that? Thanks!","You can do this using pango, through the pygtk package. Pango can list fonts and render them.",1.2,True,2,460 2010-03-03 21:30:43.127,Generate image for each font on a linux system using Python,"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: To list all fonts on a UNIX system, xlsfonts can do the trick: @@ -5597,7 +5597,7 @@ list_of_fonts=os.popen(""xslfonts"").readlines() To render a string into an image using a font, I could use PIL (Python Imaging Library) and the ImageFont class. However, 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). -Does anyone has an idea on how I can do that? Thanks!","You can do this using pango, through the pygtk package. Pango can list fonts and render them.",1.2,True,2,460 +Does anyone has an idea on how I can do that? Thanks!","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.",0.2012947653214861,False,2,460 2010-03-04 01:40:53.037,"Python and a ""time value of money"" problem","(I asked this question earlier today, but I did a poor job of explaining myself. Let me try again) I have a client who is an industrial maintenance company. They sell service agreements that are prepaid 20 hour blocks of a technician's time. Some of their larger customers might burn through that agreement in two weeks while customers with fewer problems might go eight months on that same contract. I would like to use Python to help model projected sales revenue and determine how many billable hours per month that they'll be on the hook for. If each customer only ever bought a single service contract (never renewed) it would be easy to figure sales as monthly_revenue = contract_value * qty_contracts_sold. Billable hours would also be easy: billable_hrs = hrs_per_contract * qty_contracts_sold. However, how do I account for renewals? Assuming that 90% (or some other arbitrary amount) of customers renew, then their monthly revenue ought to grow geometrically. Another important variable is how long the average customer burns through a contract. How do I determine what the revenue and billable hours will be 3, 6, or 12 months from now, based on various renewal and burn rates? @@ -5637,6 +5637,14 @@ These things are sort of omni-present in the application, so how to test them pr E.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). This 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 :-) ). Any thoughts on this are very welcome. I have currently 'solved' this issue by, well - not testing this at all. +Thanks.","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. +Generally, 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. +As 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?",0.1352210990936997,False,2,464 +2010-03-08 14:03:58.890,Unit testing aspect-oriented features,"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? +These things are sort of omni-present in the application, so how to test them properly? +E.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). +This 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 :-) ). +Any thoughts on this are very welcome. I have currently 'solved' this issue by, well - not testing this at all. Thanks.","Well... let's see. In my opinion you are testing three different things here (sorry for the ""Java AOP jargon""): the features implemented by the interceptors (i.e. the methods that implement the functions activated at the cutpoints) @@ -5644,14 +5652,6 @@ the coverage of the filters (i.e. whether the intended cutpoints are activated c the interaction between the cutpoints and the interceptors (with the side effects) You 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).",0.0,False,2,464 -2010-03-08 14:03:58.890,Unit testing aspect-oriented features,"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? -These things are sort of omni-present in the application, so how to test them properly? -E.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). -This 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 :-) ). -Any thoughts on this are very welcome. I have currently 'solved' this issue by, well - not testing this at all. -Thanks.","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. -Generally, 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. -As 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?",0.1352210990936997,False,2,464 2010-03-09 13:04:49.940,standalone application in python,"I wanted to know how can I make standalone application in python. Basically what I am doing right now is I have a template.tex file and my script generate the pdf by giving some input values. So I have to make exe file for windows and same for linux. @@ -5675,22 +5675,22 @@ I would like to know how I can get my stream resize dynamically depending on the I don't want to use Glade or any GUI builder. Thanks in advance for any help, and please excuse my poor english.",You need to tell mplayer to zoom video according to window size. This can be done either in command line (-zoom) or in the configuration file (zoom = 1).,0.2012947653214861,False,1,467 2010-03-10 19:11:28.147,How to get one value at a time from a generator function in Python?,"Very basic question - how to get one value from a generator in Python? -So far I found I can get one by writing gen.next(). I just want to make sure this is the right way?","To get the value associated with a generator object in python 3 and above use next(). -subsequent calls to next() produces successive object values in the queue.",0.3275988531455109,False,4,468 -2010-03-10 19:11:28.147,How to get one value at a time from a generator function in Python?,"Very basic question - how to get one value from a generator in Python? So far I found I can get one by writing gen.next(). I just want to make sure this is the right way?","In python 3 you don't have gen.next(), but you still can use next(gen). A bit bizarre if you ask me but that's how it is.",0.0679224682270276,False,4,468 2010-03-10 19:11:28.147,How to get one value at a time from a generator function in Python?,"Very basic question - how to get one value from a generator in Python? +So far I found I can get one by writing gen.next(). I just want to make sure this is the right way?","Yes, or next(gen) in 2.6+.",1.2,True,4,468 +2010-03-10 19:11:28.147,How to get one value at a time from a generator function in Python?,"Very basic question - how to get one value from a generator in Python? So far I found I can get one by writing gen.next(). I just want to make sure this is the right way?","In Python <= 2.5, use gen.next(). This will work for all Python 2.x versions, but not Python 3.x In Python >= 2.6, use next(gen). This is a built in function, and is clearer. It will also work in Python 3. Both of these end up calling a specially named function, next(), which can be overridden by subclassing. In Python 3, however, this function has been renamed to __next__(), to be consistent with other special functions.",0.9999999999800976,False,4,468 2010-03-10 19:11:28.147,How to get one value at a time from a generator function in Python?,"Very basic question - how to get one value from a generator in Python? -So far I found I can get one by writing gen.next(). I just want to make sure this is the right way?","Yes, or next(gen) in 2.6+.",1.2,True,4,468 -2010-03-10 20:11:32.920,How does OS handle a python dict that's larger than memory?,"I have a python program that is going to eat a lot of memory, primarily in a dict. This dict will be responsible for assigning a unique integer value to a very large set of keys. As I am working with large matrices, I need a key-to-index correspondence that can also be recovered from (i.e., once matrix computations are complete, I need to map the values back to the original keys). -I believe this amount will eventually surpass available memory. I am wondering how this will be handled with regards to swap space. Perhaps there is a better data structure for this purpose.","You need a database, if the data will exceed memory. The indexing of dictionaries isn't designed for good performance when a dictionary is bigger than memory.",0.4701041941942874,False,2,469 +So far I found I can get one by writing gen.next(). I just want to make sure this is the right way?","To get the value associated with a generator object in python 3 and above use next(). +subsequent calls to next() produces successive object values in the queue.",0.3275988531455109,False,4,468 2010-03-10 20:11:32.920,How does OS handle a python dict that's larger than memory?,"I have a python program that is going to eat a lot of memory, primarily in a dict. This dict will be responsible for assigning a unique integer value to a very large set of keys. As I am working with large matrices, I need a key-to-index correspondence that can also be recovered from (i.e., once matrix computations are complete, I need to map the values back to the original keys). I believe this amount will eventually surpass available memory. I am wondering how this will be handled with regards to swap space. Perhaps there is a better data structure for this purpose.","It will just end up in swap trashing, because a hash table has very much randomized memory access patterns. If you know that the map exceeds the size of the physical memory, you could consider using a data structure on the disk in the first place. This especially if you don't need the data structure during the computation. When the hash table triggers swapping, it creates problems also outside the hash table itself.",1.2,True,2,469 +2010-03-10 20:11:32.920,How does OS handle a python dict that's larger than memory?,"I have a python program that is going to eat a lot of memory, primarily in a dict. This dict will be responsible for assigning a unique integer value to a very large set of keys. As I am working with large matrices, I need a key-to-index correspondence that can also be recovered from (i.e., once matrix computations are complete, I need to map the values back to the original keys). +I believe this amount will eventually surpass available memory. I am wondering how this will be handled with regards to swap space. Perhaps there is a better data structure for this purpose.","You need a database, if the data will exceed memory. The indexing of dictionaries isn't designed for good performance when a dictionary is bigger than memory.",0.4701041941942874,False,2,469 2010-03-12 19:32:49.630,Database: storing data from user registration form,"Let's say I have an user registration form. In this form, I have the option for the user to upload a photo. I have an User table and Photo table. My User table has a ""PathToPhoto"" column. My question is how do I fill in the ""PathToPhoto"" column if the photo is uploaded and inserted into Photo table before the user is created? Another way to phrase my question is how to get the newly uploaded photo to be associated to the user that may or may not be created next. I'm using python and postgresql.","To make sure we're on the same page, is the following correct? @@ -5703,15 +5703,15 @@ If so, you should be able to store the ""path to photo"" information in a Python 2010-03-13 23:53:07.370,Compiler options wrong with python setup.py,"I'm trying to install matplotlib on my mac setup. I find that setup.py has inaccurate flags, in particular the isysroot points to an earlier SDK. Where does setup.py get its info and how can i fix it? I'm on MacOS 10.5.8, XCode 3.1.2 and Python 2.6 (default config was 2.5)","I'm guessing you've installed 2.6 on 10.5 using the python.org OS X installer. In that case, the flags are accurate and you should not try to change them. The python.org installers are built using the so-called 10.4u SDK and with a deployment target of 10.3, allowing one installer image to work on Mac OS X systems from 10.3.9 up through 10.6 (and possibly beyond). The most recent releases of Python 2.6 have been fixed to ensure that extension module building on OS X forces the C compiler options to match those of the underlying Python so you'll need to make sure you install the 10.4u SDK (or whatever) if necessary from the Xcode package (on the OS X release CD/DVD or downloaded from the Apple Developer Connection website). It will also make sure you are using gcc-4.0, which is also the default on 10.5.",1.2,True,1,472 +2010-03-15 05:04:45.647,How does Python differentiate between the different data types?,"Sorry if this is quite noobish to you, but I'm just starting out to learn Python after learning C++ & Java, and I am wondering how in the world I could just declare variables like id = 0 and name = 'John' without any int's or string's in front! I figured out that perhaps it's because there are no ''s in a number, but how would Python figure that out in something like def increase(first, second) instead of something like int increase(int first, int second) in C++?!","Python is dynamically typed: all variables can refer to an object of any type. id and name can be anything, but the actual objects are of types like int and str. 0 is a literal that is parsed to make an int object, and 'John' a literal that makes a str object. Many object types do not have literals and are returned by a callable (like frozenset—there's no way to make a literal frozenset, you must call frozenset.) +Consequently, there is no such thing as declaration of variables, since you aren't defining anything about the variable. id = 0 and name = 'John' are just assignment. +increase returns an int because that's what you return in it; nothing in Python forces it not to be any other object. first and second are only ints if you make them so. +Objects, to a certain extent, share a common interface. You can use the same operators and functions on them all, and if they support that particular operation, it works. It is a common, recommended technique to use different types that behave similarly interchangably; this is called duck typing. For example, if something takes a file object you can instead pass a cStringIO.StringIO object, which supports the same method as a file (like read and write) but is a completely different type. This is sort of like Java interfaces, but does not require any formal usage, you just define the appropriate methods.",0.5164076551851798,False,3,473 2010-03-15 05:04:45.647,How does Python differentiate between the different data types?,"Sorry if this is quite noobish to you, but I'm just starting out to learn Python after learning C++ & Java, and I am wondering how in the world I could just declare variables like id = 0 and name = 'John' without any int's or string's in front! I figured out that perhaps it's because there are no ''s in a number, but how would Python figure that out in something like def increase(first, second) instead of something like int increase(int first, int second) in C++?!","When it comes to assigning literal values to variables, the type of the literal value can be inferred at the time of lexical analysis. For example, anything matching the regular expression (-)?[1-9][0-9]* can be inferred to be an integer literal. If you want to convert it to a float, there needs to be an explicit cast. Similarly, a string literal is any sequence of characters enclosed in single or double quotes. In a method call, the parameters are not type-checked. You only need to pass in the correct number of them to be able to call the method. So long as the body of the method does not cause any errors with respect to the arguments, you can call the same method with lots of different types of arguments.",0.3153999413393242,False,3,473 2010-03-15 05:04:45.647,How does Python differentiate between the different data types?,"Sorry if this is quite noobish to you, but I'm just starting out to learn Python after learning C++ & Java, and I am wondering how in the world I could just declare variables like id = 0 and name = 'John' without any int's or string's in front! I figured out that perhaps it's because there are no ''s in a number, but how would Python figure that out in something like def increase(first, second) instead of something like int increase(int first, int second) in C++?!","The literal objects you mention carry (pointers to;-) their own types with them of course, so when a name's bound to that object the problem of type doesn't arise -- the object always has a type, the name doesn't -- just delegates that to the object it's bound to. There's no ""figuring out"" in def increase(first, second): -- name increase gets bound to a function object, names first and second are recorded as parameters-names and will get bound (quite possibly to objects of different types at various points) as increase gets called. So say the body is return first + second -- a call to increase('foo', 'bar') will then happily return 'foobar' (delegating the addition to the objects, which in this case are strings), and maybe later a call to increase(23, 45) will just as happily return 68 -- again by delegating the addition to the objects bound to those names at the point of call, which in this case are ints. And if you call with incompatible types you'll get an exception as the delegated addition operation can't make sense of the situation -- no big deal!",1.2,True,3,473 -2010-03-15 05:04:45.647,How does Python differentiate between the different data types?,"Sorry if this is quite noobish to you, but I'm just starting out to learn Python after learning C++ & Java, and I am wondering how in the world I could just declare variables like id = 0 and name = 'John' without any int's or string's in front! I figured out that perhaps it's because there are no ''s in a number, but how would Python figure that out in something like def increase(first, second) instead of something like int increase(int first, int second) in C++?!","Python is dynamically typed: all variables can refer to an object of any type. id and name can be anything, but the actual objects are of types like int and str. 0 is a literal that is parsed to make an int object, and 'John' a literal that makes a str object. Many object types do not have literals and are returned by a callable (like frozenset—there's no way to make a literal frozenset, you must call frozenset.) -Consequently, there is no such thing as declaration of variables, since you aren't defining anything about the variable. id = 0 and name = 'John' are just assignment. -increase returns an int because that's what you return in it; nothing in Python forces it not to be any other object. first and second are only ints if you make them so. -Objects, to a certain extent, share a common interface. You can use the same operators and functions on them all, and if they support that particular operation, it works. It is a common, recommended technique to use different types that behave similarly interchangably; this is called duck typing. For example, if something takes a file object you can instead pass a cStringIO.StringIO object, which supports the same method as a file (like read and write) but is a completely different type. This is sort of like Java interfaces, but does not require any formal usage, you just define the appropriate methods.",0.5164076551851798,False,3,473 2010-03-15 12:45:02.973,Programming in Python vs. programming in Java,"I've been writing Java for the last couple of years , and now I've started to write in python (in addition). The problem is that when I look at my Python code it looks like someone tried to hammer Java code into a python format , and it comes out crappy because - well , python ain't Java. Any tips on how to escape this pattern of ""Writing Java in Python""? @@ -5796,17 +5796,17 @@ HTH",0.0,False,1,476 2010-03-17 07:04:19.987,How to stop Python program execution in IDLE,"I have a python script that uses plt.show() as it's last instruction. When it runs, IDLE just hangs after the last instruction. I get the image but I don't get the prompt back. On other scripts I typically use ctrl-c to break the program (sometimes doesn't work immediately) but how do I get the prompt back with the plt.show()? Ctrl-c doesn't work... Are there other ways to stop the program? -This is IDLE on Windows, if it makes any difference.","I have seen this problem with IDLE and matplotlib when using them on Windows. I don't know the exact cause, but Ctrl-c a couple times has typically worked for me. If that doesn't work for you, you can use the normal interpreter instead of write your plot directly to a file instead of the screen. -This is one of those (plentiful) times when IDLE doesn't behave like a normal Python script or interpreter session. Because of this, I usually avoid IDLE.",1.2,True,3,477 -2010-03-17 07:04:19.987,How to stop Python program execution in IDLE,"I have a python script that uses plt.show() as it's last instruction. When it runs, IDLE just hangs after the last instruction. I get the image but I don't get the prompt back. -On other scripts I typically use ctrl-c to break the program (sometimes doesn't work immediately) but how do I get the prompt back with the plt.show()? Ctrl-c doesn't work... -Are there other ways to stop the program? This is IDLE on Windows, if it makes any difference.","Ctrl+F6 (Restart shell) or Shell->Restart Shell",0.6133572603953825,False,3,477 2010-03-17 07:04:19.987,How to stop Python program execution in IDLE,"I have a python script that uses plt.show() as it's last instruction. When it runs, IDLE just hangs after the last instruction. I get the image but I don't get the prompt back. On other scripts I typically use ctrl-c to break the program (sometimes doesn't work immediately) but how do I get the prompt back with the plt.show()? Ctrl-c doesn't work... Are there other ways to stop the program? +This is IDLE on Windows, if it makes any difference.","I have seen this problem with IDLE and matplotlib when using them on Windows. I don't know the exact cause, but Ctrl-c a couple times has typically worked for me. If that doesn't work for you, you can use the normal interpreter instead of write your plot directly to a file instead of the screen. +This is one of those (plentiful) times when IDLE doesn't behave like a normal Python script or interpreter session. Because of this, I usually avoid IDLE.",1.2,True,3,477 +2010-03-17 07:04:19.987,How to stop Python program execution in IDLE,"I have a python script that uses plt.show() as it's last instruction. When it runs, IDLE just hangs after the last instruction. I get the image but I don't get the prompt back. +On other scripts I typically use ctrl-c to break the program (sometimes doesn't work immediately) but how do I get the prompt back with the plt.show()? Ctrl-c doesn't work... +Are there other ways to stop the program? This is IDLE on Windows, if it makes any difference.","I had same issue in Canopy Python Editor, and I was able to interrupt python session with CTRL+. (""dot"" button). Hope that helps, or they probably do things in a similar ways",0.2012947653214861,False,3,477 2010-03-17 07:28:03.357,"In Python, if I have a unix timestamp, how do I insert that into a MySQL datetime field?","I am using Python MySQLDB, and I want to insert this into DATETIME field in Mysql . How do I do that with cursor.execute?","Solved. I just did this: @@ -5838,15 +5838,17 @@ And then in the constructor for ProcessorThread, I do this: When the thread finishes it's task (whether successfully or not), the lock_object is released which allows for another process to begin. HTH",0.2012947653214861,False,1,479 2010-03-17 18:59:49.100,Artificial Intelligence in online game using Google App Engine,"I am currently in the planning stages of a game for google app engine, but cannot wrap my head around how I am going to handle AI. I intend to have persistant NPCs that will move about the map, but short of writing a program that generates the same XML requests I use to control player actions, than run it on another server I am stuck on how to do it. I have looked at the Task Queue feature, but due to long running processes not being an option on the App engine, I am a little stuck. +I intend to run multiple server instances with 200+ persistant NPC entities that I will need to update. Most action is slowly roaming around based on player movements/concentrations, and attacking close range players...(you can probably guess the type of game im developing)",If the game is turn based then it would probably be best to avoid the Cron task and just update the NPCs every time the player moves. I'm not sure how big of a map you are planning on but you may consider even having the player object find the NPCs that are close to it and call their AI routine. That way NPCs that are out of range of a player wouldn't move at all which may save on resources. Not sure if that matter though.,0.2655860252697744,False,3,480 +2010-03-17 18:59:49.100,Artificial Intelligence in online game using Google App Engine,"I am currently in the planning stages of a game for google app engine, but cannot wrap my head around how I am going to handle AI. I intend to have persistant NPCs that will move about the map, but short of writing a program that generates the same XML requests I use to control player actions, than run it on another server I am stuck on how to do it. I have looked at the Task Queue feature, but due to long running processes not being an option on the App engine, I am a little stuck. I intend to run multiple server instances with 200+ persistant NPC entities that I will need to update. Most action is slowly roaming around based on player movements/concentrations, and attacking close range players...(you can probably guess the type of game im developing)","Will your game be turn based or real time? Either way, I think you have 2 options to look into. One is to use the Cron feature so you can schedule NPC updates at regular intervals, the other is to stick a ""update NPCs"" task into the Task Queue every time a human player moves.",1.2,True,3,480 2010-03-17 18:59:49.100,Artificial Intelligence in online game using Google App Engine,"I am currently in the planning stages of a game for google app engine, but cannot wrap my head around how I am going to handle AI. I intend to have persistant NPCs that will move about the map, but short of writing a program that generates the same XML requests I use to control player actions, than run it on another server I am stuck on how to do it. I have looked at the Task Queue feature, but due to long running processes not being an option on the App engine, I am a little stuck. -I intend to run multiple server instances with 200+ persistant NPC entities that I will need to update. Most action is slowly roaming around based on player movements/concentrations, and attacking close range players...(you can probably guess the type of game im developing)",If the game is turn based then it would probably be best to avoid the Cron task and just update the NPCs every time the player moves. I'm not sure how big of a map you are planning on but you may consider even having the player object find the NPCs that are close to it and call their AI routine. That way NPCs that are out of range of a player wouldn't move at all which may save on resources. Not sure if that matter though.,0.2655860252697744,False,3,480 -2010-03-17 18:59:49.100,Artificial Intelligence in online game using Google App Engine,"I am currently in the planning stages of a game for google app engine, but cannot wrap my head around how I am going to handle AI. I intend to have persistant NPCs that will move about the map, but short of writing a program that generates the same XML requests I use to control player actions, than run it on another server I am stuck on how to do it. I have looked at the Task Queue feature, but due to long running processes not being an option on the App engine, I am a little stuck. I intend to run multiple server instances with 200+ persistant NPC entities that I will need to update. Most action is slowly roaming around based on player movements/concentrations, and attacking close range players...(you can probably guess the type of game im developing)","Bear in mind that you can also break up your updates into multiple requests (internally): do a bit of work, redirect to the same handler but different state; do more work; etc. (I'm failing somehow to comment on Peter Recore's answer, which is where this really belongs.) I see that the free service only allows 100k task queue calls/day, so 1 task/NPC would probably use up your resources way too fast. Cron job to do some work/create task queues to update NPCs in appropriately-sized groups? Anyway, just some thoughts; good luck.",0.2655860252697744,False,3,480 2010-03-18 04:55:28.853,Using wget via Python,"How would I download files (video) with Python using wget and save them locally? There will be a bunch of files, so how do I know that one file is downloaded so as to automatically start downloding another one? +Thanks.",No reason to use python. Avoid writing a shell script in Python and go with something like bash or an equivalent.,-0.3869120172231254,False,2,481 +2010-03-18 04:55:28.853,Using wget via Python,"How would I download files (video) with Python using wget and save them locally? There will be a bunch of files, so how do I know that one file is downloaded so as to automatically start downloding another one? Thanks.","No reason to use os.system. Avoid writing a shell script in Python and go with something like urllib.urlretrieve or an equivalent. Edit... to answer the second part of your question, you can set up a thread pool using the standard library Queue class. Since you're doing a lot of downloading, the GIL shouldn't be a problem. Generate a list of the URLs you wish to download and feed them to your work queue. It will handle pushing requests to worker threads. I'm waiting for a database update to complete, so I put this together real quick. @@ -5893,8 +5895,6 @@ if __name__ == '__main__': print ""Finishing current downloads"" for i in xrange(5): queue.put((None, None))",0.5457054096481145,False,2,481 -2010-03-18 04:55:28.853,Using wget via Python,"How would I download files (video) with Python using wget and save them locally? There will be a bunch of files, so how do I know that one file is downloaded so as to automatically start downloding another one? -Thanks.",No reason to use python. Avoid writing a shell script in Python and go with something like bash or an equivalent.,-0.3869120172231254,False,2,481 2010-03-18 12:45:02.663,Configuring Pydev Interpreter in Eclipse to use Enthought Python Distribution,"I downloaded Pydev plugin for Eclipse (3.5.2) today on Mac OSX 10.5.8. To be able to use Pydev, I need to configure the interpreter in Eclipse. I am not clear what exactly I need to do here, or what this step does. I want to make sure that when I run programs from Eclipse using Pydev, it uses the Enthought Python Distribution (EPD) I have installed, and can use all the packages that come with EPD. Can someone please tell me simple steps that I need to follow. If I click on autoconfig, it shows a bunch of folders with the path /System/Library/Frameworks/Python.Framework/Versions/2.5/... @@ -5985,12 +5985,12 @@ Since the log information is disjoint from your application data (it's meta-data Text pickle data is difficult for humans to read, binary pickle data even more so; log in an easily parsed format and the data can be imported into analysis software easily.",0.1352210990936997,False,1,491 2010-03-28 02:44:31.217,Key word extraction in Python,"I'm building a website in django that needs to extract key words from short (twitter-like) messages. I've looked at packages like topia.textextract and nltk - but both seem to be overkill for what I need to do. All I need to do is filter words like ""and"", ""or"", ""not"" while keeping nouns and verbs that aren't conjunctives or other parts of speech. Are there any ""simpler"" packages out there that can do this? -EDIT: This needs to be done in near real-time on a production website, so using a keyword extraction service seems out of the question, based on their response times and request throttling.","Abbreviations like NO for navigation officer or OR for operations room need a little care lest you cause a SNAFU ;-) One suspects that better results could be obtained from ""Find the NO and send her to the OR"" by tagging the words with parts of speech using the context ... hint 1: ""the OR"" should result in ""the [noun]"" not ""the [conjunction]"". Hint 2: if in doubt about a word, keep it as a keyword.",0.2012947653214861,False,2,492 -2010-03-28 02:44:31.217,Key word extraction in Python,"I'm building a website in django that needs to extract key words from short (twitter-like) messages. -I've looked at packages like topia.textextract and nltk - but both seem to be overkill for what I need to do. All I need to do is filter words like ""and"", ""or"", ""not"" while keeping nouns and verbs that aren't conjunctives or other parts of speech. Are there any ""simpler"" packages out there that can do this? EDIT: This needs to be done in near real-time on a production website, so using a keyword extraction service seems out of the question, based on their response times and request throttling.","You can make a set sw of the ""stop words"" you want to eliminate (maybe copy it once and for all from the stop words corpus of NLTK, depending how familiar you are with the various natural languages you need to support), then apply it very simply. E.g., if you have a list of words sent that make up the sentence (shorn of punctuation and lowercased, for simplicity), [word for word in sent if word not in sw] is all you need to make a list of non-stopwords -- could hardly be easier, right? To get the sent list in the first place, using the re module from the standard library, re.findall(r'\w+', sentstring) might suffice if sentstring is the string with the sentence you're dealing with -- it doesn't lowercase, but you can change the list comprehension I suggest above to [word for word in sent if word.lower() not in sw] to compensate for that and (btw) keep the word's original case, which may be useful.",1.2,True,2,492 +2010-03-28 02:44:31.217,Key word extraction in Python,"I'm building a website in django that needs to extract key words from short (twitter-like) messages. +I've looked at packages like topia.textextract and nltk - but both seem to be overkill for what I need to do. All I need to do is filter words like ""and"", ""or"", ""not"" while keeping nouns and verbs that aren't conjunctives or other parts of speech. Are there any ""simpler"" packages out there that can do this? +EDIT: This needs to be done in near real-time on a production website, so using a keyword extraction service seems out of the question, based on their response times and request throttling.","Abbreviations like NO for navigation officer or OR for operations room need a little care lest you cause a SNAFU ;-) One suspects that better results could be obtained from ""Find the NO and send her to the OR"" by tagging the words with parts of speech using the context ... hint 1: ""the OR"" should result in ""the [noun]"" not ""the [conjunction]"". Hint 2: if in doubt about a word, keep it as a keyword.",0.2012947653214861,False,2,492 2010-03-29 10:02:00.843,Tornado or Django works with CGI?,"Tornado is a webserver + framework like Django but for real-time features. On my server I don't have a python module or wsgi module so I thought CGI. @@ -6001,7 +6001,7 @@ Running Tornado as CGI application negates the very reason it exists, because ru Python would be preferred but I'm also willing to look at other languages e.g. C/C++ or other means e.g. SQL From what I have read, all of the methods e.g. Python COM access, pyodbc rely on having Lotus Notes server software installed. The problem I am trying to solve is to read the content and look for references (URL's back to a web site that is undergoing maintenance and the addresses in the web site will change) As a start, I want to get a list of references and hope to be able to replace them with the new references to the modified web site. -Any ideas on how best to do this welcome :)","The short answer is, unfortunately you will need the Notes client installed. There are a few ways to access data from an NSF such as NotesSQL, COM, C/C++, but all rely on the Lotus C API at the core, and you'll need a notes client and a notes ID file to gain access via that API.",0.3869120172231254,False,3,494 +Any ideas on how best to do this welcome :)","If this is a one-time need, you may be able to find sites that will do some simple Domino/Notes hosting for free. If you could put the NSF up to a service like that, you could then use Domino URL's (REST) to extract the data and search for links, etc.",0.1352210990936997,False,3,494 2010-03-29 22:34:20.433,Access to content of Lotus Notes database without Lotus Notes software installed,"I am looking for a programatic way to access content in a Lotus Notes database (.nsf file) without having Lotus Notes software installed. Python would be preferred but I'm also willing to look at other languages e.g. C/C++ or other means e.g. SQL From what I have read, all of the methods e.g. Python COM access, pyodbc rely on having Lotus Notes server software installed. @@ -6013,7 +6013,7 @@ Not the answer you're looking for I guess, but always good to have choices!",0.0 Python would be preferred but I'm also willing to look at other languages e.g. C/C++ or other means e.g. SQL From what I have read, all of the methods e.g. Python COM access, pyodbc rely on having Lotus Notes server software installed. The problem I am trying to solve is to read the content and look for references (URL's back to a web site that is undergoing maintenance and the addresses in the web site will change) As a start, I want to get a list of references and hope to be able to replace them with the new references to the modified web site. -Any ideas on how best to do this welcome :)","If this is a one-time need, you may be able to find sites that will do some simple Domino/Notes hosting for free. If you could put the NSF up to a service like that, you could then use Domino URL's (REST) to extract the data and search for links, etc.",0.1352210990936997,False,3,494 +Any ideas on how best to do this welcome :)","The short answer is, unfortunately you will need the Notes client installed. There are a few ways to access data from an NSF such as NotesSQL, COM, C/C++, but all rely on the Lotus C API at the core, and you'll need a notes client and a notes ID file to gain access via that API.",0.3869120172231254,False,3,494 2010-03-31 03:25:08.987,how to write re-usable views in django?,"These are the techniques that I use regularly to make my views reusable: take the template_name as an argument with a default @@ -6030,7 +6030,10 @@ First, should I add anything to my list? Should I remove anything from my list? The items accommodates a large number of cases. However, whenever an app extends a model of another in some way (e.g. adding a field or changing the behavior in some way) I end up writing my own views and only reusing the model. Is this normal? Edit/answering my own question partially: -signals: the view should emit a signal when it starts and one before it returns the response",I would think that doing all of those puts a large burden on your urlconf to get everything right. Perhaps making a function that takes all that and hardcoding your views to be a glorified wrapper around said function would be better.,0.0,False,2,495 +signals: the view should emit a signal when it starts and one before it returns the response","whenever the view needs a particular object from the ORM, it attempts to fetch it using any ""id"" parameter in several ways (e.g. as a slug, as a database id) (this may be a bad practice...) + +So... why not just expect a model instance to be passed in as a parameter? Or a QuerySet from which you will take element 0? Then you can combine it with the QuerySet case, and maybe roll it into get_object_or_404. +My suggestion is to look at how Django's generic views are written. They're solving the same general class of problems you are. You seem most of the way there, except for the last part.",0.0,False,2,495 2010-03-31 03:25:08.987,how to write re-usable views in django?,"These are the techniques that I use regularly to make my views reusable: take the template_name as an argument with a default @@ -6047,10 +6050,7 @@ First, should I add anything to my list? Should I remove anything from my list? The items accommodates a large number of cases. However, whenever an app extends a model of another in some way (e.g. adding a field or changing the behavior in some way) I end up writing my own views and only reusing the model. Is this normal? Edit/answering my own question partially: -signals: the view should emit a signal when it starts and one before it returns the response","whenever the view needs a particular object from the ORM, it attempts to fetch it using any ""id"" parameter in several ways (e.g. as a slug, as a database id) (this may be a bad practice...) - -So... why not just expect a model instance to be passed in as a parameter? Or a QuerySet from which you will take element 0? Then you can combine it with the QuerySet case, and maybe roll it into get_object_or_404. -My suggestion is to look at how Django's generic views are written. They're solving the same general class of problems you are. You seem most of the way there, except for the last part.",0.0,False,2,495 +signals: the view should emit a signal when it starts and one before it returns the response",I would think that doing all of those puts a large burden on your urlconf to get everything right. Perhaps making a function that takes all that and hardcoding your views to be a glorified wrapper around said function would be better.,0.0,False,2,495 2010-03-31 03:45:21.323,Any way to add my C# project as a reference in IronPython / IronRuby?,"I know how to reference an existing .dll to IronPython, but is there any way to add my project as a reference like I can between Visual Studio projects? Or is it best practice to create a separate class library?","You can't add reference to a project since it's a Visual Studio thing. I suggest that during the development process, call import (IronPython) or require (IronRuby) with the full path of your project assembly like c:\dev\MyProject\bin\Debug\MyProject.dll.",1.2,True,1,496 @@ -6155,7 +6155,8 @@ Come back to such and such basics or move further to... (you get the point :) I 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. -EDIT: Thanks to your great input, I'm back on the Python improvement track! I really appreciate!","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.",0.06435775498645,False,5,503 +EDIT: Thanks to your great input, I'm back on the Python improvement track! I really appreciate!","Not precisely what you're asking for, but I think it's good advice. +Learn 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.",0.0429381369005077,False,5,503 2010-04-04 00:28:33.830,Python progression path - From apprentice to guru,"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. What 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. Let me sum up what I do NOT want to ask first ;) @@ -6179,11 +6180,8 @@ Come back to such and such basics or move further to... (you get the point :) I 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. -EDIT: Thanks to your great input, I'm back on the Python improvement track! I really appreciate!","I'll give you the simplest and most effective piece of advice I think anybody could give you: code. -You 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. -Got 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. -When 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! -This 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.",0.7068065412722319,False,5,503 +EDIT: Thanks to your great input, I'm back on the Python improvement track! I really appreciate!","Thoroughly Understand All Data Types and Structures +For 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!",0.252224781600294,False,5,503 2010-04-04 00:28:33.830,Python progression path - From apprentice to guru,"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. What 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. Let me sum up what I do NOT want to ask first ;) @@ -6241,8 +6239,7 @@ Come back to such and such basics or move further to... (you get the point :) I 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. -EDIT: Thanks to your great input, I'm back on the Python improvement track! I really appreciate!","Not precisely what you're asking for, but I think it's good advice. -Learn 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.",0.0429381369005077,False,5,503 +EDIT: Thanks to your great input, I'm back on the Python improvement track! I really appreciate!","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.",0.06435775498645,False,5,503 2010-04-04 00:28:33.830,Python progression path - From apprentice to guru,"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. What 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. Let me sum up what I do NOT want to ask first ;) @@ -6266,8 +6263,11 @@ Come back to such and such basics or move further to... (you get the point :) I 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. -EDIT: Thanks to your great input, I'm back on the Python improvement track! I really appreciate!","Thoroughly Understand All Data Types and Structures -For 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!",0.252224781600294,False,5,503 +EDIT: Thanks to your great input, I'm back on the Python improvement track! I really appreciate!","I'll give you the simplest and most effective piece of advice I think anybody could give you: code. +You 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. +Got 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. +When 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! +This 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.",0.7068065412722319,False,5,503 2010-04-04 10:55:44.530,how to create multiple selections in text edit box in qt4?,"Qt3.3 used to allow for multiple selections in the QTextEdit widget by calling the setSelection() function and specifying a different selection id (selNum) as the last argument in that function. In Qt4, to create a selection, I do it by creating a QTextCursor object and call the setPosition() or movePosition() methods. I have no problems being able to create a single selection of text. I am, however, unable to find a way to create multiple selections. The methods in Qt4 do not have an argument which allows you to set a selection id, nor can i find any other function in the QTextCursor or QTextEdit which looks like it might allow me to do so. Has this feature been completely removed from Qt4? or has is there a new and different way of doing it? @@ -6281,23 +6281,23 @@ Ronny","The solution, i realise now is actually quite simple. To graphically visualise all the various selections (separate QTextCursor objects), instead of calling the setTextCursor() method for the QTextEdit widget for each of the selections, i change the background color of each of those sections of text by calling the setCharFormat() method for each of those QTextCursor objects.",1.2,True,2,504 2010-04-05 13:18:44.587,"PHP Frameworks (CodeIgniter, Yii, CakePHP) vs. Django","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. Thanks, -niting","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. -This choice was made partly because of my dislike for PHP though, so take the recommendation with a pinch of salt.",0.9991388858373508,False,5,505 +niting",Codeigniter it's fast and very documented also has a large community to and finaly friendly with the programmer.,0.2012947653214861,False,5,505 2010-04-05 13:18:44.587,"PHP Frameworks (CodeIgniter, Yii, CakePHP) vs. Django","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. Thanks, -niting","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. -So, 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.",1.2,True,5,505 +niting","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. +I had the impression (from watching a tutorial) that Django has it.",0.0,False,5,505 2010-04-05 13:18:44.587,"PHP Frameworks (CodeIgniter, Yii, CakePHP) vs. Django","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. Thanks, niting","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. But languages other than PHP appear to be more sexy.",0.0,False,5,505 2010-04-05 13:18:44.587,"PHP Frameworks (CodeIgniter, Yii, CakePHP) vs. Django","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. Thanks, -niting","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. -I had the impression (from watching a tutorial) that Django has it.",0.0,False,5,505 +niting","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. +So, 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.",1.2,True,5,505 2010-04-05 13:18:44.587,"PHP Frameworks (CodeIgniter, Yii, CakePHP) vs. Django","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. Thanks, -niting",Codeigniter it's fast and very documented also has a large community to and finaly friendly with the programmer.,0.2012947653214861,False,5,505 +niting","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. +This choice was made partly because of my dislike for PHP though, so take the recommendation with a pinch of salt.",0.9991388858373508,False,5,505 2010-04-05 20:23:48.887,Disable autocomplete on textfield in Django?,"Does anyone know how you can turn off autocompletion on a textfield in Django? For example, a form that I generate from my model has an input field for a credit card number. It is bad practice to leave autocompletion on. When making the form by hand, I'd add a autocomplete=""off"" statement, but how do you do it in Django and still retain the form validation?","Add the autocomplete=""off"" to the form tag, so you don't have to change the django.form instance.
@@ -6317,12 +6317,12 @@ You can also C-x r y (yank-rectangle), but that's only rarely useful.",0.4701041 It's in PostgreSQL with django apps for the frontend and JSON api, plus a few supporting python command-line tools for management. the items in question are mostly books and artist prints, some of which are self-published. What is nice about using ISBNs as primary keys is that in on top of relational integrity, you get lots of handy utilities for validating ISBNs, automatically looking up missing or additional information on the book items, etcetera, many of which I've taken advantage. some such tools are off-the-shelf (PyISBN, PyAWS etc) and some are hand-rolled -- I tried to keep all of these parts nice and decoupled, but you know how things can get. I couldn't find anything online about 'private ISBNs' or 'self-assigned ISBNs' but that's the sort of thing I was interested in doing. I doubt that's what I'll settle on, since there is already an apparent run on ISBN numbers. -should I retool everything for EAN numbers, or migrate off ISBNs as primary keys in general? if anyone has any experience with working with these systems, I'd love to hear about it, your advice is most welcome.",I don't know postgres but normally ISBM would be a unique index key but not the primary. It's better to have an integer as primary/foreign key. That way you only need to add a new field EAN/ISSN as nullable.,0.296905446847765,False,2,509 +should I retool everything for EAN numbers, or migrate off ISBNs as primary keys in general? if anyone has any experience with working with these systems, I'd love to hear about it, your advice is most welcome.","A simple solution (although arguably whether good) would be to use (isbn,title) or (isbn,author) which should pretty much guarantee uniqueness. Ideology is great but practicality also serves a purpose.",0.1016881243684853,False,2,509 2010-04-09 18:45:51.457,"ISBNs are used as primary key, now I want to add non-book things to the DB - should I migrate to EAN?","I built an inventory database where ISBN numbers are the primary keys for the items. This worked great for a while as the items were books. Now I want to add non-books. some of the non-books have EANs or ISSNs, some do not. It's in PostgreSQL with django apps for the frontend and JSON api, plus a few supporting python command-line tools for management. the items in question are mostly books and artist prints, some of which are self-published. What is nice about using ISBNs as primary keys is that in on top of relational integrity, you get lots of handy utilities for validating ISBNs, automatically looking up missing or additional information on the book items, etcetera, many of which I've taken advantage. some such tools are off-the-shelf (PyISBN, PyAWS etc) and some are hand-rolled -- I tried to keep all of these parts nice and decoupled, but you know how things can get. I couldn't find anything online about 'private ISBNs' or 'self-assigned ISBNs' but that's the sort of thing I was interested in doing. I doubt that's what I'll settle on, since there is already an apparent run on ISBN numbers. -should I retool everything for EAN numbers, or migrate off ISBNs as primary keys in general? if anyone has any experience with working with these systems, I'd love to hear about it, your advice is most welcome.","A simple solution (although arguably whether good) would be to use (isbn,title) or (isbn,author) which should pretty much guarantee uniqueness. Ideology is great but practicality also serves a purpose.",0.1016881243684853,False,2,509 +should I retool everything for EAN numbers, or migrate off ISBNs as primary keys in general? if anyone has any experience with working with these systems, I'd love to hear about it, your advice is most welcome.",I don't know postgres but normally ISBM would be a unique index key but not the primary. It's better to have an integer as primary/foreign key. That way you only need to add a new field EAN/ISSN as nullable.,0.296905446847765,False,2,509 2010-04-09 19:44:57.647,How to create make .so files from code written in C or C++ that are usable from Python,"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"". From 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.","You can write python extensions in many ways, including Cython, SWIG, boost.python ... You can also write a shared library and use the ""ctypes"" library to access it.",0.0,False,1,510 @@ -6395,11 +6395,11 @@ to mind.",1.2,True,2,511 2010-04-11 03:15:41.097,How can I learn to set up a build process?,"What I was taught at school is all about programming languages, software design, but hardly anything about how to automatically build a software, probably with something like unit testing integrated. Please tell me how do one start learning to set up a build process for his project. If this is too abstract to make any sense, I would add that I use Python and do web programming with Django. -Thanks in advance.","While this is certainly not a complete answer to your question, I would like to recommend very highly the learning of the tool 'make'. I find myself using it on a VERY regular basis, for a wide variety of tasks, including (but by no means limited to) building, testing, and deploying software.",0.0,False,2,512 +Thanks in advance.","For Python projects you should use setuptools. Setuptools has all the stuff to pack things up into .eggs, compile C modules, run unit tests, etc... If you've ever done ""python setup.py [build|install|test]"" then you've used setuptools.",0.0814518047658113,False,2,512 2010-04-11 03:15:41.097,How can I learn to set up a build process?,"What I was taught at school is all about programming languages, software design, but hardly anything about how to automatically build a software, probably with something like unit testing integrated. Please tell me how do one start learning to set up a build process for his project. If this is too abstract to make any sense, I would add that I use Python and do web programming with Django. -Thanks in advance.","For Python projects you should use setuptools. Setuptools has all the stuff to pack things up into .eggs, compile C modules, run unit tests, etc... If you've ever done ""python setup.py [build|install|test]"" then you've used setuptools.",0.0814518047658113,False,2,512 +Thanks in advance.","While this is certainly not a complete answer to your question, I would like to recommend very highly the learning of the tool 'make'. I find myself using it on a VERY regular basis, for a wide variety of tasks, including (but by no means limited to) building, testing, and deploying software.",0.0,False,2,512 2010-04-11 03:42:56.387,Installing virtualenvwrapper on Windows,I've installed virtualenv and virtualenvwrapper on Windows using easy_install. But mkvirtualenv is missing. I tried to search on my machine but I couldn't find it. I don't know how to solve it. Do you have any idea?,"mkvirtualenv is a bash script so you need to run bash shell to make use of it. mkvirtualenv is a bash function in the mkvirtualenv_bashrc script You will need to run this from cygwin under Windows. (You can call a native python from this and not need a cygwin python)",1.2,True,2,513 @@ -6429,6 +6429,10 @@ Binary protocol If it does, how do I use those features within Django? I couldn't find any documentation.","Looking at the _get_server method on python-memcached v1.45, it seems it doesn't use consistent hashing, but a simple hash % len(buckets). Same goes for binary protocol, python-memcache uses, as far as I can see in the source, only text commands.",1.2,True,1,515 2010-04-13 07:41:56.143,How do I start learn Python for web,"I have been learning Python for a while, and now I'd like to learn Python for the web; using Python as a back-end of a website. Where and how do I start learning this? +Example usages are: connecting to databases, and retrieving and storing information from forms.","there are numerous options for learning python for web. I learned python to access web data from courser.org, and the tutorial was very interesting. If you want to learn python for web then I suggest you to learn python to access web data in courser.org +you can also learn python for everybody which is a specialization course with 5 courses in which each and every thing about python is given. +The fun part of courser.org is that they provide assignments with due dates which means you have to complete an assessment of each week in that week itself. They also provide quiz. You have to pass all the assignments and quizzes to get the certificate which is very easy, you can easily complete the assessment and quizzes.",0.0,False,2,516 +2010-04-13 07:41:56.143,How do I start learn Python for web,"I have been learning Python for a while, and now I'd like to learn Python for the web; using Python as a back-end of a website. Where and how do I start learning this? Example usages are: connecting to databases, and retrieving and storing information from forms.","There are numerous frameworks for making websites in Python. Once you are familiar with Python and the general nature of websites which would include the knowledge of HTTP, HTML you can proceed by using any of the following to make websites using Python: Webapp2 - A simple framework to get you started with making websites and using this framework you can easily make websites and cloud services and host them on the Google App Engine service. Follow these links for more information on use and hosting: Welcome to webapp2!, Google App Engine @@ -6441,10 +6445,6 @@ Python Wiki - Digi Developer Karrigell 3.1.1 If you are making extensive applications/websites the above two frameworks will pose major problems in doing simple tasks.",0.0,False,2,516 -2010-04-13 07:41:56.143,How do I start learn Python for web,"I have been learning Python for a while, and now I'd like to learn Python for the web; using Python as a back-end of a website. Where and how do I start learning this? -Example usages are: connecting to databases, and retrieving and storing information from forms.","there are numerous options for learning python for web. I learned python to access web data from courser.org, and the tutorial was very interesting. If you want to learn python for web then I suggest you to learn python to access web data in courser.org -you can also learn python for everybody which is a specialization course with 5 courses in which each and every thing about python is given. -The fun part of courser.org is that they provide assignments with due dates which means you have to complete an assessment of each week in that week itself. They also provide quiz. You have to pass all the assignments and quizzes to get the certificate which is very easy, you can easily complete the assessment and quizzes.",0.0,False,2,516 2010-04-13 20:38:43.150,How to get a Device Specific UID using Python in ASE on Android?,"I am working on am Android Scripting Environment (ASE) script in Python to replicate an iPhone app. I 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. What can I do to create a UID in Python in ASE?",The newer versions of ASE now include a function call to create these identifiers.,1.2,True,1,517 @@ -6475,9 +6475,9 @@ Thanks in advance.","I suspect you may be optimising prematurely here. Most modern systems will cache files in memory for a significant period of time before they flush them to disk, so if you write the data to a temporary file, read it back in, then close and delete the file you may find that there's no significant disc traffic (unless it really is 100MB). You might want to look at using tempfile.TemporaryFile() which creates a temporary file that is automatically deleted when closed, or else tempfile.SpooledTemporaryFile() which explicitly holds it all in memory until it exceeds a particular size.",0.1352210990936997,False,1,522 2010-04-16 16:11:58.573,access variables of other functions,"in python, how can i access the variables of one function into another function, is it possible, i tried the global variable method but that doesn't work for me. -can someone help me, how to access the variables from one function to another function.",If you want to share data between functions then create a class and turn the functions into methods on the class.,1.2,True,2,523 -2010-04-16 16:11:58.573,access variables of other functions,"in python, how can i access the variables of one function into another function, is it possible, i tried the global variable method but that doesn't work for me. can someone help me, how to access the variables from one function to another function.","Don't try to do this. Explicit is better than implicit - if your function needs access to certain variables, pass them in. If it needs to change a value in the calling function, return the new value.",0.0,False,2,523 +2010-04-16 16:11:58.573,access variables of other functions,"in python, how can i access the variables of one function into another function, is it possible, i tried the global variable method but that doesn't work for me. +can someone help me, how to access the variables from one function to another function.",If you want to share data between functions then create a class and turn the functions into methods on the class.,1.2,True,2,523 2010-04-16 16:43:19.367,Django - how to write users and profiles handling in best way?,"I am writing simple site that requires users and profiles to be handled. The first initial thought is to use django's build in user handling, but then the user model is too narrow and does not contain fields that I need. The documentation mentions user profiles, but user profiles section has been removed from djangobook covering django 1.0 (ideally, the solution should work with django 1.2), and the Internet is full of different solutions, not making the choice easier (like user model inheritance, user profiles and django signals, and so on). I would like to know, how to write this in good, modern, fast and secure way. Should I try to extend django builtin user model, or maybe should I create my own user model wide enough to keep all the information I need? Below you may find some specifications and expectations from the working solution: @@ -6495,14 +6495,14 @@ This is a cheap way. I'd recommend that you do your output using the logging mod 2010-04-17 22:24:51.723,"In python, how do I drag and drop 1 or more files onto my script as arguments with absolute path? (for windows, linux, and mac)","I am writing a simple Python script with no GUI. I want to be able to drag and drop multiple files onto my python script and have access to their absolute paths inside of the script. How do I do this in Mac, Linux, and windows? For times sake, just Mac will be fine for now. I've googled this question and only found one related one but it was too confusing. I am currently running Mac OS X Snow Leopard. Any help is much appreciated. -Thanks!","Usually when you drag a file onto a script/executable, the OS passes the path to that file as a command-line argument. Check sys.argv",0.1352210990936997,False,2,526 +Thanks!",This really is independent of python. It depends entirely on which file browser you're using and how it supports drag and drop.,0.1352210990936997,False,2,526 2010-04-17 22:24:51.723,"In python, how do I drag and drop 1 or more files onto my script as arguments with absolute path? (for windows, linux, and mac)","I am writing a simple Python script with no GUI. I want to be able to drag and drop multiple files onto my python script and have access to their absolute paths inside of the script. How do I do this in Mac, Linux, and windows? For times sake, just Mac will be fine for now. I've googled this question and only found one related one but it was too confusing. I am currently running Mac OS X Snow Leopard. Any help is much appreciated. -Thanks!",This really is independent of python. It depends entirely on which file browser you're using and how it supports drag and drop.,0.1352210990936997,False,2,526 -2010-04-18 03:56:23.810,pexpect install problem,"i have installed pexpect with the following command ""python setup.py install"" but when i try to run a program it says ""AttributeError: 'module' object has no attribute 'spawn'"". how to settle the matter?","It looks like pexpect wasn't ported yet to python 3 (quite a late answer, but still usable for people googling here)",0.2655860252697744,False,2,527 +Thanks!","Usually when you drag a file onto a script/executable, the OS passes the path to that file as a command-line argument. Check sys.argv",0.1352210990936997,False,2,526 2010-04-18 03:56:23.810,pexpect install problem,"i have installed pexpect with the following command ""python setup.py install"" but when i try to run a program it says ""AttributeError: 'module' object has no attribute 'spawn'"". how to settle the matter?","Pexpect has not been ported to python3, and apparently the author has no plans on doing so. I tried converting it with the python 2to3 program, but could not get it to work.",0.1352210990936997,False,2,527 +2010-04-18 03:56:23.810,pexpect install problem,"i have installed pexpect with the following command ""python setup.py install"" but when i try to run a program it says ""AttributeError: 'module' object has no attribute 'spawn'"". how to settle the matter?","It looks like pexpect wasn't ported yet to python 3 (quite a late answer, but still usable for people googling here)",0.2655860252697744,False,2,527 2010-04-19 05:01:31.697,"In SqlAlchemy, how to ignore m2m relationship attributes when merge?","There is a m2m relation in my models, User and Role. I want to merge a role, but i DO NOT want this merge has any effect on user and role relation-ship. Unfortunately, for some complicate reason, role.users if not empty. I tried to set role.users = None, but SA complains None is not a list. @@ -6571,10 +6571,10 @@ write back to the new file As I don't see you having any code yet, I hope that this would be a good start",0.2655860252697744,False,1,530 2010-04-23 10:08:06.833,Automating Excel macro using python,"I am using python in Linux to automate an excel. I have finished writing data into excel by using pyexcelerator package. Now comes the real challenge. I have to add another tab to the existing sheet and that tab should contain the macro run in the first tab. All these things should be automated. I Googled a lot and found win32come to do a job in macro, but that was only for windows. -Anyone have any idea of how to do this, or can you guide me with few suggestions.","Excel Macros are per sheets, so, I am afraid, you need to copy the macros explicitly if you created new sheet, instead of copying existing sheet to new one.",0.0,False,2,531 +Anyone have any idea of how to do this, or can you guide me with few suggestions.",Maybe manipulating your .xls with Openoffice and pyUno is a better way. Way more powerful.,0.0,False,2,531 2010-04-23 10:08:06.833,Automating Excel macro using python,"I am using python in Linux to automate an excel. I have finished writing data into excel by using pyexcelerator package. Now comes the real challenge. I have to add another tab to the existing sheet and that tab should contain the macro run in the first tab. All these things should be automated. I Googled a lot and found win32come to do a job in macro, but that was only for windows. -Anyone have any idea of how to do this, or can you guide me with few suggestions.",Maybe manipulating your .xls with Openoffice and pyUno is a better way. Way more powerful.,0.0,False,2,531 +Anyone have any idea of how to do this, or can you guide me with few suggestions.","Excel Macros are per sheets, so, I am afraid, you need to copy the macros explicitly if you created new sheet, instead of copying existing sheet to new one.",0.0,False,2,531 2010-04-23 12:43:50.543,Gtk: How can I get a part of a file in a textview with scrollbars relating to the full file,"I'm trying to make a very large file editor (where the editor only stores a part of the buffer in memory at a time), but I'm stuck while building my textview object. Basically- I know that I have to be able to update the text view buffer dynamically, and I don't know hot to get the scrollbars to relate to the full file while the textview contains only a small buffer of the file. I've played with Gtk.Adjustment on a Gtk.ScrolledWindow and ScrollBars, but though I can extend the range of the scrollbars, they still apply to the range of the buffer and not the filesize (which I try to set via Gtk.Adjustment parameters) when I load into textview. I need to have a widget that ""knows"" that it is looking at a part of a file, and can load/unload buffers as necessary to view different parts of the file. So far, I believe I'll respond to the ""change_view"" to calculate when I'm off, or about to be off the current buffer and need to load the next, but I don't know how to get the scrollbars to have the top relate to the beginning of the file, and the bottom relate to the end of the file, rather than to the loaded buffer in textview. Any help would be greatly appreciated, thanks!","You probably should create your own Gtk.TextBuffer implementation, as the default one relies on storing whole buffer in memory.",0.2012947653214861,False,1,532 @@ -6585,13 +6585,13 @@ EDIT: When importing a part of a module that calls another def within the module, how do you call that def if it isn't imported? lib/toolset.py => def add(){ toolset.show(""I'm Add""); } def show(text){print text}; if that file is called from main.py => import lib.toolset then, the show method wouldn't be loaded, or main.py => from lib.toolset import show wouldn't work. -Can an import toolset be put at the top of toolset.py?","I think this is the key statement in your question. +Can an import toolset be put at the top of toolset.py?","I'm not really sure what your problem is, is it that you just want to type less? -I don't really want to add the module name in front of every call to the class +get a decent source editor with autocomplete! +you can do import longmodulename as ln and use ln.something instead of longmodulename.something +you can do from longmodulename import ( something, otherthing ) and use something directly -My response: I hear what you're saying, but this is standard practice in Python. -Any Python programmer reading code like ""result = match(blah)"" will presume you're calling a local function inside your own module. If you're actually talking about the function match() in the re module they'll expect to see ""result = re.match(blah)"". That's just how it is. -If it helps, I didn't like this style either when I came to Python first, but now I appreciate that it removes any ambiguity over exactly which of the many functions called ""match"" I am calling, especially when I come back to read code that I wrote six months ago.",1.2,True,2,533 +import * is never a good idea, it messes with coding tools, breaks silently, makes readers wonder stuff was defined and so on ...",0.3869120172231254,False,2,533 2010-04-23 15:52:34.600,Importing Classes Within a Module,"Currently, I have a parser with multiple classes that work together. For Instance: TreeParser creates multiple Product and Reactant modules which in turn create multiple Element classes. The TreeParser is called by a render method within the same module, which is called from the importer. Finally, if the package has dependencies (such as re and another another module within the same folder), where is the best place to require those modules? Within the __init__.py file or within the module itself? @@ -6599,13 +6599,13 @@ EDIT: When importing a part of a module that calls another def within the module, how do you call that def if it isn't imported? lib/toolset.py => def add(){ toolset.show(""I'm Add""); } def show(text){print text}; if that file is called from main.py => import lib.toolset then, the show method wouldn't be loaded, or main.py => from lib.toolset import show wouldn't work. -Can an import toolset be put at the top of toolset.py?","I'm not really sure what your problem is, is it that you just want to type less? +Can an import toolset be put at the top of toolset.py?","I think this is the key statement in your question. -get a decent source editor with autocomplete! -you can do import longmodulename as ln and use ln.something instead of longmodulename.something -you can do from longmodulename import ( something, otherthing ) and use something directly +I don't really want to add the module name in front of every call to the class -import * is never a good idea, it messes with coding tools, breaks silently, makes readers wonder stuff was defined and so on ...",0.3869120172231254,False,2,533 +My response: I hear what you're saying, but this is standard practice in Python. +Any Python programmer reading code like ""result = match(blah)"" will presume you're calling a local function inside your own module. If you're actually talking about the function match() in the re module they'll expect to see ""result = re.match(blah)"". That's just how it is. +If it helps, I didn't like this style either when I came to Python first, but now I appreciate that it removes any ambiguity over exactly which of the many functions called ""match"" I am calling, especially when I come back to read code that I wrote six months ago.",1.2,True,2,533 2010-04-25 20:55:44.383,How to make an executable file in Python?,"I want to make an executable file (.exe) of my Python application. I want to know how to do it but have this in mind: I use a C++ DLL! Do I have to put the DLL along side with the .exe or is there some other way?","I've built exe files from Python 2.7 code using each of these tools: @@ -6674,12 +6674,12 @@ Editing from here.. Language is not important, but I would prefer it in C. I am more interested in getting the dataset.","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.",0.0,False,2,536 2010-04-28 15:37:49.327,Finding all points common to two circles,"In Python, how would one find all integer points common to two circles? For example, imagine a Venn diagram-like intersection of two (equally sized) circles, with center-points (x1,y1) and (x2,y2) and radii r1=r2. Additionally, we already know the two points of intersection of the circles are (xi1,yi1) and (xi2,yi2). -How would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?","You're almost there. -Iterating over the points in the box should be fairly good, but you can do better if for the second coordinate you iterate directly between the limits. -Say you iterate along the x axis first, then for the y axis, instead of iterating between bounding box coords figure out where each circle intersects the x line, more specifically you are interested in the y coordinate of the intersection points, and iterate between those (pay attention to rounding) -When you do this, because you already know you are inside the circles you can skip the checks entirely. -If you have a lot of points then you skip a lot of checks and you might get some performance improvements. -As an additional improvement you can pick the x axis or the y axis to minimize the number of times you need to compute intersection points.",0.0679224682270276,False,4,537 +How would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?","So you want to find the lattice points that are inside both circles? +The method you suggested of drawing a box and iterating through all the points in the box seems the simplest to me. It will probably be efficient, as long as the number of points in the box is comparable to the number of points in the intersection. +And even if it isn't as efficient as possible, you shouldn't try to optimize it until you have a good reason to believe it's a real bottleneck.",0.0,False,4,537 +2010-04-28 15:37:49.327,Finding all points common to two circles,"In Python, how would one find all integer points common to two circles? +For example, imagine a Venn diagram-like intersection of two (equally sized) circles, with center-points (x1,y1) and (x2,y2) and radii r1=r2. Additionally, we already know the two points of intersection of the circles are (xi1,yi1) and (xi2,yi2). +How would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?",You may also want to look into the various clipping algorithms used in graphics development. I have used clipping algorithms to solve alot of problems similar to what you are asking here.,0.0679224682270276,False,4,537 2010-04-28 15:37:49.327,Finding all points common to two circles,"In Python, how would one find all integer points common to two circles? For example, imagine a Venn diagram-like intersection of two (equally sized) circles, with center-points (x1,y1) and (x2,y2) and radii r1=r2. Additionally, we already know the two points of intersection of the circles are (xi1,yi1) and (xi2,yi2). How would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?","If the locations and radii of your circles can vary with a granularity less than your grid, then you'll be checking a bunch of points anyway. @@ -6689,12 +6689,12 @@ with D being the separation of the two centers. Note that this rectangle in gen Actually, you'd only need to check half of these points. If the radii are the same, you'd only need to check a quarter of them. The symmetry of the problem helps you there.",0.0679224682270276,False,4,537 2010-04-28 15:37:49.327,Finding all points common to two circles,"In Python, how would one find all integer points common to two circles? For example, imagine a Venn diagram-like intersection of two (equally sized) circles, with center-points (x1,y1) and (x2,y2) and radii r1=r2. Additionally, we already know the two points of intersection of the circles are (xi1,yi1) and (xi2,yi2). -How would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?",You may also want to look into the various clipping algorithms used in graphics development. I have used clipping algorithms to solve alot of problems similar to what you are asking here.,0.0679224682270276,False,4,537 -2010-04-28 15:37:49.327,Finding all points common to two circles,"In Python, how would one find all integer points common to two circles? -For example, imagine a Venn diagram-like intersection of two (equally sized) circles, with center-points (x1,y1) and (x2,y2) and radii r1=r2. Additionally, we already know the two points of intersection of the circles are (xi1,yi1) and (xi2,yi2). -How would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?","So you want to find the lattice points that are inside both circles? -The method you suggested of drawing a box and iterating through all the points in the box seems the simplest to me. It will probably be efficient, as long as the number of points in the box is comparable to the number of points in the intersection. -And even if it isn't as efficient as possible, you shouldn't try to optimize it until you have a good reason to believe it's a real bottleneck.",0.0,False,4,537 +How would one generate a list of all points (x,y) contained in both circles in an efficient manner? That is, it would be simple to draw a box containing the intersections and iterate through it, checking if a given point is within both circles, but is there a better way?","You're almost there. +Iterating over the points in the box should be fairly good, but you can do better if for the second coordinate you iterate directly between the limits. +Say you iterate along the x axis first, then for the y axis, instead of iterating between bounding box coords figure out where each circle intersects the x line, more specifically you are interested in the y coordinate of the intersection points, and iterate between those (pay attention to rounding) +When you do this, because you already know you are inside the circles you can skip the checks entirely. +If you have a lot of points then you skip a lot of checks and you might get some performance improvements. +As an additional improvement you can pick the x axis or the y axis to minimize the number of times you need to compute intersection points.",0.0679224682270276,False,4,537 2010-04-28 19:06:45.113,Timed email reminder in python,"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. However, 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? I am using a shared hosting provided, so cant have a continously running script. @@ -6731,22 +6731,25 @@ in Somehow I need to tell the sqlite driver not to try to decode the text as UTF-8 (at least not using the standard algorithm, but it needs to use my fail-safe variant).",Incompatible Django version. Check Django version for solving this error first. I was running on Django==3.0.8 and it was producing an error. Than I ran virtualenv where I have Django==3.1.2 and the error was removed.,0.0,False,1,540 2010-04-30 19:13:05.883,Running CPython Applications With Visual Studio?,"I would like to know how to use Visual Studio with CPython (the official python.org python interpreter, not IronPython). In particular, I am interested in getting ""build"" and ""run"" commands in Visual Studio working. Other features such as color highlighting and auto-complete, I am less concerned about. -Also, can the ""build"" command be made to run py2exe or similar exe packagers?",Eclipse and PyDev already provide an excellent development environment for Python. Is there any reason you cannot use them?,0.1016881243684853,False,3,541 -2010-04-30 19:13:05.883,Running CPython Applications With Visual Studio?,"I would like to know how to use Visual Studio with CPython (the official python.org python interpreter, not IronPython). -In particular, I am interested in getting ""build"" and ""run"" commands in Visual Studio working. Other features such as color highlighting and auto-complete, I am less concerned about. Also, can the ""build"" command be made to run py2exe or similar exe packagers?","You can create custom project that will execute a bat file when building. I remember that I used this method to generate a Inoosetup installer so that you should work to run the py2exe script. I have no idea for the rest of the features. The syntax highlighting and the auto-complete should be much more challenging. I would recommend to give a try to Komodo Edit or Eclipse/Pydev. It works out of the box",0.0,False,3,541 2010-04-30 19:13:05.883,Running CPython Applications With Visual Studio?,"I would like to know how to use Visual Studio with CPython (the official python.org python interpreter, not IronPython). In particular, I am interested in getting ""build"" and ""run"" commands in Visual Studio working. Other features such as color highlighting and auto-complete, I am less concerned about. +Also, can the ""build"" command be made to run py2exe or similar exe packagers?",Eclipse and PyDev already provide an excellent development environment for Python. Is there any reason you cannot use them?,0.1016881243684853,False,3,541 +2010-04-30 19:13:05.883,Running CPython Applications With Visual Studio?,"I would like to know how to use Visual Studio with CPython (the official python.org python interpreter, not IronPython). +In particular, I am interested in getting ""build"" and ""run"" commands in Visual Studio working. Other features such as color highlighting and auto-complete, I am less concerned about. Also, can the ""build"" command be made to run py2exe or similar exe packagers?","Are you trying to build CPython itself? Doesn't it come with project files suitable for use with Visual Studio? (I seem to remember that it did.) If you mean that you want to use CPython but not build it, then just type c:\pythonxx\python.exe into the debugging executable and in the arguments put your script's full path name. Create a makefile project and you can do whatever you want with the build rules to get ""build"" to function.",0.1016881243684853,False,3,541 2010-04-30 22:37:23.463,MUD (game) design concept question about timed events,"I'm trying my hand at building a MUD (multiplayer interactive-fiction game) I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. -Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?","A basic approach would be to have a data structure representing the evil monster's instance of its spell, with a cooldown timer on it. When the power is used, the cooldown is set (presumably to a number of seconds defined by the master definition of the spell); an attempt to use it again will fail just like with the player ability. This can be integrated with an event queue by having the queue check cooldown, and if it hasn't expired, to wait for it to expire, or abort the action, or reschedule the action, as appropriate.",0.0,False,5,542 +Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?","MUDs actions are usually performed on 'ticks' rather than immediately - this allows for limited affect of latency and for monster's commands to be inserted in the queue and processed fairly. +Personally, I don't like this approach, but pretty much 99% of MUDs use it. You need to design a robust command queue & event queue which can handle both AI and user commands. You can then add ""virtual latency"" to AI commands which may be predefined or an average of all users latency, or whatever you like.",0.229096917477335,False,5,542 2010-04-30 22:37:23.463,MUD (game) design concept question about timed events,"I'm trying my hand at building a MUD (multiplayer interactive-fiction game) I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. -Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?","You could use threads to handle specific types of Mobs, and put all the instances into an array of some sort. Then, the thread simply goes through the list repeatedly applying logic. DelayTimeStart and Delay could be attributes of the parent Mob class, and when the thread goes through the loop, it can put off processing any instances of the Mob in which there is time remaining in the delay.",0.1160922760327606,False,5,542 +Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?","AI's are clients. +They're ""part of the server"" only in the most distant view. They're actually outside the main game engine. They're specialized clients with no human being. +An AI client has the same interface with the server that a human's client would.",0.1731644579931097,False,5,542 2010-04-30 22:37:23.463,MUD (game) design concept question about timed events,"I'm trying my hand at building a MUD (multiplayer interactive-fiction game) I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?","I'll provide you an answer from an LPMud/LDMud point of view. @@ -6754,13 +6757,10 @@ Every player in the MUD is an instance of player.c. Player.c inherits from livi The wonderful news that applies to your question is that monsters also inherit from living.c. This means that if you had actions that can only be performed periodically this can all be managed within the heartbeat based on the number of ticks that have occurred.",0.0,False,5,542 2010-04-30 22:37:23.463,MUD (game) design concept question about timed events,"I'm trying my hand at building a MUD (multiplayer interactive-fiction game) I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. -Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?","MUDs actions are usually performed on 'ticks' rather than immediately - this allows for limited affect of latency and for monster's commands to be inserted in the queue and processed fairly. -Personally, I don't like this approach, but pretty much 99% of MUDs use it. You need to design a robust command queue & event queue which can handle both AI and user commands. You can then add ""virtual latency"" to AI commands which may be predefined or an average of all users latency, or whatever you like.",0.229096917477335,False,5,542 +Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?","You could use threads to handle specific types of Mobs, and put all the instances into an array of some sort. Then, the thread simply goes through the list repeatedly applying logic. DelayTimeStart and Delay could be attributes of the parent Mob class, and when the thread goes through the loop, it can put off processing any instances of the Mob in which there is time remaining in the delay.",0.1160922760327606,False,5,542 2010-04-30 22:37:23.463,MUD (game) design concept question about timed events,"I'm trying my hand at building a MUD (multiplayer interactive-fiction game) I'm in the design/conceptualizing phase and I've run into a problem that I can't come up with a solution for. I'm hoping some more experienced programmers will have some advice. -Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?","AI's are clients. -They're ""part of the server"" only in the most distant view. They're actually outside the main game engine. They're specialized clients with no human being. -An AI client has the same interface with the server that a human's client would.",0.1731644579931097,False,5,542 +Here's the problem as best I can explain it. When the player decides to perform an action he sends a command to the server. the server then processes the command, determines whether or not the action can be performed, and either does it or responds with a reason as to why it could not be done. One reason that an action might fail is that the player is busy doing something else. For instance, if a player is mid-fight and has just swung a massive broadsword, it might take 3 seconds before he can repeat this action. If the player attempts to swing again to soon, the game will respond indicating that he must wait x seconds before doing that. Now, this I can probably design without much trouble. The problem I'm having is how I can replicate this behavior from AI creatures. All of the events that are being performed by the server ON ITS OWN, aka not as an immediate reaction to something a player has done, will have to be time sensitive. Some evil monster has cast a spell on you but must wait 30 seconds before doing it again... I think I'll probably be adding all these events to some kind of event queue, but how can I make that event queue time sensitive?","A basic approach would be to have a data structure representing the evil monster's instance of its spell, with a cooldown timer on it. When the power is used, the cooldown is set (presumably to a number of seconds defined by the master definition of the spell); an attempt to use it again will fail just like with the player ability. This can be integrated with an event queue by having the queue check cooldown, and if it hasn't expired, to wait for it to expire, or abort the action, or reschedule the action, as appropriate.",0.0,False,5,542 2010-05-01 04:57:23.553,What are some strategies for maintaining a common database schema with a team of developers and no DBA?,"I'm curious about how others have approached the problem of maintaining and synchronizing database changes across many (10+) developers without a DBA? What I mean, basically, is that if someone wants to make a change to the database, what are some strategies to doing that? (i.e. I've created a 'Car' model and now I want to apply the appropriate DDL to the database, etc..) We're primarily a Python shop and our ORM is SQLAlchemy. Previously, we had written our models in such a way to create the models using our ORM, but we recently ditched this because: @@ -6845,6 +6845,17 @@ long version: over the years, I've used several versions of python, and what is Nowadays I'm using a mac (OSX 10.6 on x86-64) and it's a dependency nightmare each time I want to revive script older than a few months. Python itself already comes in three different flavours in /usr/bin (2.5, 2.6, 3.1), but I had to install 2.4 from macports for pygame, something else (cannot remember what) forced me to install all three others from macports as well, so at the end of the day I'm the happy owner of seven (!) instances of python on my system. But that's not the problem, the problem is, none of them has the right (i.e. same set of) libraries installed, some of them are 32bits, some 64bits, and now I'm pretty much lost. For example right now I'm trying to run a three-year-old script (not written by me) which used to use matplotlib/numpy to draw a real-time plot within a rectangle of a wxwidgets window. But I'm failing miserably: py26-wxpython from macports won't install, stock python has wxwidgets included but also has some conflict between 32 bits and 64 bits, and it doesn't have numpy... what a mess ! +Obviously, I'm doing things the wrong way. How do you usally cope with all that chaos ?","install the python versions you need, better if from sources +when you write a script, include the full python version into it (such as #!/usr/local/bin/python2.6) + +I can't see what could go wrong. +If something does, it's probably macports fault anyway, not yours (one of the reasons I don't use macports anymore). +I know I'm probably missing something and this will get downvoted, but please leave at least a little comment in that case, thanks :)",0.0509761841073563,False,4,550 +2010-05-03 16:41:14.363,How to maintain long-lived python projects w.r.t. dependencies and python versions?,"short version: how can I get rid of the multiple-versions-of-python nightmare ? +long version: over the years, I've used several versions of python, and what is worse, several extensions to python (e.g. pygame, pylab, wxPython...). Each time it was on a different setup, with different OSes, sometimes different architectures (like my old PowerPC mac). +Nowadays I'm using a mac (OSX 10.6 on x86-64) and it's a dependency nightmare each time I want to revive script older than a few months. Python itself already comes in three different flavours in /usr/bin (2.5, 2.6, 3.1), but I had to install 2.4 from macports for pygame, something else (cannot remember what) forced me to install all three others from macports as well, so at the end of the day I'm the happy owner of seven (!) instances of python on my system. +But that's not the problem, the problem is, none of them has the right (i.e. same set of) libraries installed, some of them are 32bits, some 64bits, and now I'm pretty much lost. +For example right now I'm trying to run a three-year-old script (not written by me) which used to use matplotlib/numpy to draw a real-time plot within a rectangle of a wxwidgets window. But I'm failing miserably: py26-wxpython from macports won't install, stock python has wxwidgets included but also has some conflict between 32 bits and 64 bits, and it doesn't have numpy... what a mess ! Obviously, I'm doing things the wrong way. How do you usally cope with all that chaos ?","What I usually do is trying to (progressively) keep up with the Python versions as they come along (and once all of the external dependencies have correct versions available). Most of the time the Python code itself can be transferred as-is with only minor needed modifications. My biggest Python project @ work (15.000+ LOC) is now on Python 2.6 a few months (upgrading everything from Python 2.5 did take most of a day due to installing / checking 10+ dependencies...) @@ -6854,6 +6865,14 @@ long version: over the years, I've used several versions of python, and what is Nowadays I'm using a mac (OSX 10.6 on x86-64) and it's a dependency nightmare each time I want to revive script older than a few months. Python itself already comes in three different flavours in /usr/bin (2.5, 2.6, 3.1), but I had to install 2.4 from macports for pygame, something else (cannot remember what) forced me to install all three others from macports as well, so at the end of the day I'm the happy owner of seven (!) instances of python on my system. But that's not the problem, the problem is, none of them has the right (i.e. same set of) libraries installed, some of them are 32bits, some 64bits, and now I'm pretty much lost. For example right now I'm trying to run a three-year-old script (not written by me) which used to use matplotlib/numpy to draw a real-time plot within a rectangle of a wxwidgets window. But I'm failing miserably: py26-wxpython from macports won't install, stock python has wxwidgets included but also has some conflict between 32 bits and 64 bits, and it doesn't have numpy... what a mess ! +Obviously, I'm doing things the wrong way. How do you usally cope with all that chaos ?","At least under Linux, multiple pythons can co-exist fairly happily. I use Python 2.6 on a CentOS system that needs Python 2.4 to be the default for various system things. I simply compiled and installed python 2.6 into a separate directory tree (and added the appropriate bin directory to my path) which was fairly painless. It's then invoked by typing ""python2.6"". +Once you have separate pythons up and running, installing libraries for a specific version is straightforward. If you invoke the setup.py script with the python you want, it will be installed in directories appropriate to that python, and scripts will be installed in the same directory as the python executable itself and will automagically use the correct python when invoked. +I also try to avoid using too many libraries. When I only need one or two functions from a library (eg scipy), I'll often see if I can just copy them to my own project.",0.0,False,4,550 +2010-05-03 16:41:14.363,How to maintain long-lived python projects w.r.t. dependencies and python versions?,"short version: how can I get rid of the multiple-versions-of-python nightmare ? +long version: over the years, I've used several versions of python, and what is worse, several extensions to python (e.g. pygame, pylab, wxPython...). Each time it was on a different setup, with different OSes, sometimes different architectures (like my old PowerPC mac). +Nowadays I'm using a mac (OSX 10.6 on x86-64) and it's a dependency nightmare each time I want to revive script older than a few months. Python itself already comes in three different flavours in /usr/bin (2.5, 2.6, 3.1), but I had to install 2.4 from macports for pygame, something else (cannot remember what) forced me to install all three others from macports as well, so at the end of the day I'm the happy owner of seven (!) instances of python on my system. +But that's not the problem, the problem is, none of them has the right (i.e. same set of) libraries installed, some of them are 32bits, some 64bits, and now I'm pretty much lost. +For example right now I'm trying to run a three-year-old script (not written by me) which used to use matplotlib/numpy to draw a real-time plot within a rectangle of a wxwidgets window. But I'm failing miserably: py26-wxpython from macports won't install, stock python has wxwidgets included but also has some conflict between 32 bits and 64 bits, and it doesn't have numpy... what a mess ! Obviously, I'm doing things the wrong way. How do you usally cope with all that chaos ?","Some tips: on Mac OS X, use only the python installation in /Library/Frameworks/Python.framework. @@ -6861,34 +6880,9 @@ whenever you use numpy/scipy/matplotlib, install the enthought python distributi use virtualenv and virtualenvwrapper to keep those ""system"" installations pristine; ideally use one virtual environment per project, so each project's dependencies are fulfilled. And, yes, that means potentially a lot of code will be replicated in the various virtual envs. That seems like a bigger mess indeed, but at least things work that way. Basically, if one of the projects works in a virtualenv, it will keep working no matter what upgrades you perform, since you never change the ""system"" installs.",1.2,True,4,550 -2010-05-03 16:41:14.363,How to maintain long-lived python projects w.r.t. dependencies and python versions?,"short version: how can I get rid of the multiple-versions-of-python nightmare ? -long version: over the years, I've used several versions of python, and what is worse, several extensions to python (e.g. pygame, pylab, wxPython...). Each time it was on a different setup, with different OSes, sometimes different architectures (like my old PowerPC mac). -Nowadays I'm using a mac (OSX 10.6 on x86-64) and it's a dependency nightmare each time I want to revive script older than a few months. Python itself already comes in three different flavours in /usr/bin (2.5, 2.6, 3.1), but I had to install 2.4 from macports for pygame, something else (cannot remember what) forced me to install all three others from macports as well, so at the end of the day I'm the happy owner of seven (!) instances of python on my system. -But that's not the problem, the problem is, none of them has the right (i.e. same set of) libraries installed, some of them are 32bits, some 64bits, and now I'm pretty much lost. -For example right now I'm trying to run a three-year-old script (not written by me) which used to use matplotlib/numpy to draw a real-time plot within a rectangle of a wxwidgets window. But I'm failing miserably: py26-wxpython from macports won't install, stock python has wxwidgets included but also has some conflict between 32 bits and 64 bits, and it doesn't have numpy... what a mess ! -Obviously, I'm doing things the wrong way. How do you usally cope with all that chaos ?","install the python versions you need, better if from sources -when you write a script, include the full python version into it (such as #!/usr/local/bin/python2.6) - -I can't see what could go wrong. -If something does, it's probably macports fault anyway, not yours (one of the reasons I don't use macports anymore). -I know I'm probably missing something and this will get downvoted, but please leave at least a little comment in that case, thanks :)",0.0509761841073563,False,4,550 -2010-05-03 16:41:14.363,How to maintain long-lived python projects w.r.t. dependencies and python versions?,"short version: how can I get rid of the multiple-versions-of-python nightmare ? -long version: over the years, I've used several versions of python, and what is worse, several extensions to python (e.g. pygame, pylab, wxPython...). Each time it was on a different setup, with different OSes, sometimes different architectures (like my old PowerPC mac). -Nowadays I'm using a mac (OSX 10.6 on x86-64) and it's a dependency nightmare each time I want to revive script older than a few months. Python itself already comes in three different flavours in /usr/bin (2.5, 2.6, 3.1), but I had to install 2.4 from macports for pygame, something else (cannot remember what) forced me to install all three others from macports as well, so at the end of the day I'm the happy owner of seven (!) instances of python on my system. -But that's not the problem, the problem is, none of them has the right (i.e. same set of) libraries installed, some of them are 32bits, some 64bits, and now I'm pretty much lost. -For example right now I'm trying to run a three-year-old script (not written by me) which used to use matplotlib/numpy to draw a real-time plot within a rectangle of a wxwidgets window. But I'm failing miserably: py26-wxpython from macports won't install, stock python has wxwidgets included but also has some conflict between 32 bits and 64 bits, and it doesn't have numpy... what a mess ! -Obviously, I'm doing things the wrong way. How do you usally cope with all that chaos ?","At least under Linux, multiple pythons can co-exist fairly happily. I use Python 2.6 on a CentOS system that needs Python 2.4 to be the default for various system things. I simply compiled and installed python 2.6 into a separate directory tree (and added the appropriate bin directory to my path) which was fairly painless. It's then invoked by typing ""python2.6"". -Once you have separate pythons up and running, installing libraries for a specific version is straightforward. If you invoke the setup.py script with the python you want, it will be installed in directories appropriate to that python, and scripts will be installed in the same directory as the python executable itself and will automagically use the correct python when invoked. -I also try to avoid using too many libraries. When I only need one or two functions from a library (eg scipy), I'll often see if I can just copy them to my own project.",0.0,False,4,550 2010-05-04 07:26:42.727,I am using Python on Windows. How do I delete my script after it is run?,"I have written a Python script and compiled it into a MS Windows EXE file. I can modify the code, but how do I make it remove itself after running?",I think the easiest solution is make an external .bat file that executes your exe file and deletes it when finished.,1.2,True,1,551 2010-05-04 18:14:01.250,Lua parser in python,"I'm looking into using Lua in a web project. I can't seem to find any way of directly parsing in pure python and running Lua code in Python. Does anyone know how to do this? -Joe","From your comments, it appears you a interested in a secure way of executing untrusted code. -Redifining python builtins, as you suggested in a comment, is a horrible way to secure code. -What you want is sandboxing, there are solutions for python, but I wouldn't recommend them. You would be much better of using Jython or IronPython, because the JVM and .NET clr, were designed with sandboxing in mind. -I personally believe that in most cases, if you need to execute untrusted code, then you are putting too much or not enough trust in your users.",0.2655860252697744,False,2,552 -2010-05-04 18:14:01.250,Lua parser in python,"I'm looking into using Lua in a web project. I can't seem to find any way of directly parsing in pure python and running Lua code in Python. -Does anyone know how to do this? Joe","@the_drow From Lua's web site: @@ -6902,20 +6896,26 @@ Lua is a fast language engine with small footprint that you can embed @Joe Simpson Check out Lunatic Python, it might have what you want. I know it's an old question, but other people might be looking for this answer, as well. It's a good question that deserves a good answer.",0.1352210990936997,False,2,552 +2010-05-04 18:14:01.250,Lua parser in python,"I'm looking into using Lua in a web project. I can't seem to find any way of directly parsing in pure python and running Lua code in Python. +Does anyone know how to do this? +Joe","From your comments, it appears you a interested in a secure way of executing untrusted code. +Redifining python builtins, as you suggested in a comment, is a horrible way to secure code. +What you want is sandboxing, there are solutions for python, but I wouldn't recommend them. You would be much better of using Jython or IronPython, because the JVM and .NET clr, were designed with sandboxing in mind. +I personally believe that in most cases, if you need to execute untrusted code, then you are putting too much or not enough trust in your users.",0.2655860252697744,False,2,552 +2010-05-06 01:41:56.053,Embed FCKeditor in python app,"I have a python application which need a gui HTML editor, I know FCKeditor is nice, so how to embed the FCKeditor in a python desktop app?","To embed FCKeditor (or maybe better the current CKeditor?), you basically need to embed a full-fledged browser (with Javascript) -- I believe wxPython may currently be the best bet for that, as I hear it has wxIE for Windows and wxWebKitCtrl for the Mac (I don't know if old summer-of-code ideas about making something suitable for Linux ever panned out, though). Most ""HTML viewer"" widgets, in most GUIs, don't support Javascript, and that's a must for (F?)CKeditor.",1.2,True,2,553 2010-05-06 01:41:56.053,Embed FCKeditor in python app,"I have a python application which need a gui HTML editor, I know FCKeditor is nice, so how to embed the FCKeditor in a python desktop app?","In order of difficulty: If you just need to support Windows, you can embed IE in wx - see the docs and demos. wxWebKit is looking a bit more mature, but it's still in development. You could just use the web-browser using webbrowser.open(url). Things will be very crude, and interaction will be a pain. A fourth option - you could try out pyjamas for your whole GUI, then run it all in a web-browser.",0.0,False,2,553 -2010-05-06 01:41:56.053,Embed FCKeditor in python app,"I have a python application which need a gui HTML editor, I know FCKeditor is nice, so how to embed the FCKeditor in a python desktop app?","To embed FCKeditor (or maybe better the current CKeditor?), you basically need to embed a full-fledged browser (with Javascript) -- I believe wxPython may currently be the best bet for that, as I hear it has wxIE for Windows and wxWebKitCtrl for the Mac (I don't know if old summer-of-code ideas about making something suitable for Linux ever panned out, though). Most ""HTML viewer"" widgets, in most GUIs, don't support Javascript, and that's a must for (F?)CKeditor.",1.2,True,2,553 2010-05-06 10:43:07.383,why in python giving to str func a unicode string will throw an exception?,"for example the following: str(u'לשום') will throw an error. -how can i prevent these?","Calling str() on a unicode is the same as calling .encode(sys.getdefaultencoding()) on it. If the unicode contains characters that can't be encoded in the default encoding then it will throw a UnicodeEncodeError. The fix is to explicitly encode the unicode in a useful encoding, such as 'utf-8'.",0.9981778976111988,False,2,554 +how can i prevent these?","If you're running on Python 3, the u'' notation is a syntax error. Is this your problem? Because in Python <3, your code is absolutely correct, and since 'test' is plain ASCII there are no decoding issues.",0.0,False,2,554 2010-05-06 10:43:07.383,why in python giving to str func a unicode string will throw an exception?,"for example the following: str(u'לשום') will throw an error. -how can i prevent these?","If you're running on Python 3, the u'' notation is a syntax error. Is this your problem? Because in Python <3, your code is absolutely correct, and since 'test' is plain ASCII there are no decoding issues.",0.0,False,2,554 +how can i prevent these?","Calling str() on a unicode is the same as calling .encode(sys.getdefaultencoding()) on it. If the unicode contains characters that can't be encoded in the default encoding then it will throw a UnicodeEncodeError. The fix is to explicitly encode the unicode in a useful encoding, such as 'utf-8'.",0.9981778976111988,False,2,554 2010-05-06 12:03:24.113,django authentication .htaccess static,"In my app users can upload files for other users. To make the uploaded files accesible only for the addresse I need some kind of static files authentication system. My idea, is to create the apache hosted directory for each user and to limit access to this derectory using .htaccess. @@ -6985,12 +6985,12 @@ Often, you'll want to use Object-Relational mapping rather than write your own S Also, 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.",1.2,True,1,561 2010-05-15 16:54:55.100,If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?,"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?","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. Also consider learning a bit about MacRuby for GUI development ;)",0.0814518047658113,False,4,562 -2010-05-15 16:54:55.100,If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?,"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?","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. -C 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.",0.3153999413393242,False,4,562 +2010-05-15 16:54:55.100,If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?,"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?",Yes. Learn how to program in C.,0.0,False,4,562 2010-05-15 16:54:55.100,If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?,"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?","Learning C will definitely be of help, as Objective C inherits its many properties and adds to it. You 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. For 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.",0.0,False,4,562 -2010-05-15 16:54:55.100,If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?,"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?",Yes. Learn how to program in C.,0.0,False,4,562 +2010-05-15 16:54:55.100,If I start learning C on Ubuntu will it give me an edge when I start learning Objective-C later this summer?,"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?","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. +C 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.",0.3153999413393242,False,4,562 2010-05-17 02:14:40.500,Python: How do I create a reference to a reference?,"I am traditionally a Perl and C++ programmer, so apologies in advance if I am misunderstanding something trivial about Python! I would like to create a reference to a reference. Huh? Ok. All objects in Python are actually references to the real object. @@ -7155,7 +7155,7 @@ I realize I could probably work out a file-based approach (e.g. instance #1 watc More details: I'm trying to do this because our servers are using a monitoring tool which supports running python scripts to collect monitoring data (e.g. results of a database query or web service call) which the monitoring tool then indexes for later use. Some of these scripts are very expensive to start up but cheap to run after startup (e.g. making a DB connection vs. running a query). So we've chosen to keep them running in an infinite loop until the parent process kills them. This works great, but on larger servers 100 instances of the same script may be running, even if they're only gathering data every 20 minutes each. This wreaks havoc with RAM, DB connection limits, etc. We want to switch from 100 processes with 1 thread to one process with 100 threads, each executing the work that, previously, one script was doing. But changing how the scripts are invoked by the monitoring tool is not possible. We need to keep invocation the same (launch a process with different command-line parameters) but but change the scripts to recognize that another one is active, and have the ""new"" script send its work instructions (from the command line params) over to the ""old"" script. -BTW, this is not something I want to do on a one-script basis. Instead, I want to package this behavior into a library which many script authors can leverage-- my goal is to enable script authors to write simple, single-threaded scripts which are unaware of multi-instance issues, and to handle the multi-threading and single-instancing under the covers.",Perhaps try using sockets for communication?,0.1016881243684853,False,2,583 +BTW, this is not something I want to do on a one-script basis. Instead, I want to package this behavior into a library which many script authors can leverage-- my goal is to enable script authors to write simple, single-threaded scripts which are unaware of multi-instance issues, and to handle the multi-threading and single-instancing under the covers.",Sounds like your best bet is sticking with a pid file but have it not only contain the process Id - have it also include the port number that the prior instance is listening on. So when starting up check for the pid file and if present see if a process with that Id is running - if so send your data to it and quit otherwise overwrite the pid file with the current process's info.,0.0,False,2,583 2010-05-29 16:46:00.447,can a python script know that another instance of the same script is running... and then talk to it?,"I'd like to prevent multiple instances of the same long-running python command-line script from running at the same time, and I'd like the new instance to be able to send data to the original instance before the new instance commits suicide. How can I do this in a cross-platform way? Specifically, I'd like to enable the following behavior: @@ -7171,7 +7171,7 @@ I realize I could probably work out a file-based approach (e.g. instance #1 watc More details: I'm trying to do this because our servers are using a monitoring tool which supports running python scripts to collect monitoring data (e.g. results of a database query or web service call) which the monitoring tool then indexes for later use. Some of these scripts are very expensive to start up but cheap to run after startup (e.g. making a DB connection vs. running a query). So we've chosen to keep them running in an infinite loop until the parent process kills them. This works great, but on larger servers 100 instances of the same script may be running, even if they're only gathering data every 20 minutes each. This wreaks havoc with RAM, DB connection limits, etc. We want to switch from 100 processes with 1 thread to one process with 100 threads, each executing the work that, previously, one script was doing. But changing how the scripts are invoked by the monitoring tool is not possible. We need to keep invocation the same (launch a process with different command-line parameters) but but change the scripts to recognize that another one is active, and have the ""new"" script send its work instructions (from the command line params) over to the ""old"" script. -BTW, this is not something I want to do on a one-script basis. Instead, I want to package this behavior into a library which many script authors can leverage-- my goal is to enable script authors to write simple, single-threaded scripts which are unaware of multi-instance issues, and to handle the multi-threading and single-instancing under the covers.",Sounds like your best bet is sticking with a pid file but have it not only contain the process Id - have it also include the port number that the prior instance is listening on. So when starting up check for the pid file and if present see if a process with that Id is running - if so send your data to it and quit otherwise overwrite the pid file with the current process's info.,0.0,False,2,583 +BTW, this is not something I want to do on a one-script basis. Instead, I want to package this behavior into a library which many script authors can leverage-- my goal is to enable script authors to write simple, single-threaded scripts which are unaware of multi-instance issues, and to handle the multi-threading and single-instancing under the covers.",Perhaps try using sockets for communication?,0.1016881243684853,False,2,583 2010-05-30 05:06:28.333,large amount of data in many text files - how to process?,"I have large amounts of data (a few terabytes) and accumulating... They are contained in many tab-delimited flat text files (each about 30MB). Most of the task involves reading the data and aggregating (summing/averaging + additional transformations) over observations/rows based on a series of predicate statements, and then saving the output as text, HDF5, or SQLite files, etc. I normally use R for such tasks but I fear this may be a bit large. Some candidate solutions are to write the whole thing in C (or @@ -7184,8 +7184,9 @@ amenable for pure SQL solutions) write the whole thing in Python Would (3) be a bad idea? I know you can wrap C routines in Python but in this case since there isn't anything computationally prohibitive (e.g., optimization routines that require many iterative calculations), I think I/O may be as much of a bottleneck as the computation itself. Do you have any recommendations on further considerations or suggestions? Thanks -Edit Thanks for your responses. There seems to be conflicting opinions about Hadoop, but in any case I don't have access to a cluster (though I can use several unnetworked machines)...","With terabytes, you will want to parallelize your reads over many disks anyway; so might as well go straight into Hadoop. -Use Pig or Hive to query the data; both have extensive support for user-defined transformations, so you should be able to implement what you need to do using custom code.",0.2012947653214861,False,4,584 +Edit Thanks for your responses. There seems to be conflicting opinions about Hadoop, but in any case I don't have access to a cluster (though I can use several unnetworked machines)...","Yes. You are right! I/O would cost most of your processing time. I don't suggest you to use distributed systems, like hadoop, for this task. +Your task could be done in a modest workstation. I am not an Python expert, I think it has support for asynchronous programming. In F#/.Net, the platform has well support for that. I was once doing an image processing job, loading 20K images on disk and transform them into feature vectors only costs several minutes in parallel. +all in all, load and process your data in parallel and save the result in memory (if small), in database (if big).",0.0509761841073563,False,4,584 2010-05-30 05:06:28.333,large amount of data in many text files - how to process?,"I have large amounts of data (a few terabytes) and accumulating... They are contained in many tab-delimited flat text files (each about 30MB). Most of the task involves reading the data and aggregating (summing/averaging + additional transformations) over observations/rows based on a series of predicate statements, and then saving the output as text, HDF5, or SQLite files, etc. I normally use R for such tasks but I fear this may be a bit large. Some candidate solutions are to write the whole thing in C (or @@ -7198,10 +7199,7 @@ amenable for pure SQL solutions) write the whole thing in Python Would (3) be a bad idea? I know you can wrap C routines in Python but in this case since there isn't anything computationally prohibitive (e.g., optimization routines that require many iterative calculations), I think I/O may be as much of a bottleneck as the computation itself. Do you have any recommendations on further considerations or suggestions? Thanks -Edit Thanks for your responses. There seems to be conflicting opinions about Hadoop, but in any case I don't have access to a cluster (though I can use several unnetworked machines)...","When you say ""accumulating"" then solution (2) looks most suitable to problem. -After initial load up to database you only update database with new files (daily, weekly? depends how often you need this). -In cases (1) and (3) you need to process files each time (what was stated earlier as most time/resources-consuming), unless you find a way to stored results and update them with new files. -You could use R to process files from csv to, for example, SQLite database.",0.1016881243684853,False,4,584 +Edit Thanks for your responses. There seems to be conflicting opinions about Hadoop, but in any case I don't have access to a cluster (though I can use several unnetworked machines)...","(3) is not necessarily a bad idea -- Python makes it easy to process ""CSV"" file (and despite the C standing for Comma, tab as a separator is just as easy to handle) and of course gets just about as much bandwidth in I/O ops as any other language. As for other recommendations, numpy, besides fast computation (which you may not need as per your statements) provides very handy, flexible multi-dimensional arrays, which may be quite handy for your tasks; and the standard library module multiprocessing lets you exploit multiple cores for any task that's easy to parallelize (important since just about every machine these days has multi-cores;-).",1.2,True,4,584 2010-05-30 05:06:28.333,large amount of data in many text files - how to process?,"I have large amounts of data (a few terabytes) and accumulating... They are contained in many tab-delimited flat text files (each about 30MB). Most of the task involves reading the data and aggregating (summing/averaging + additional transformations) over observations/rows based on a series of predicate statements, and then saving the output as text, HDF5, or SQLite files, etc. I normally use R for such tasks but I fear this may be a bit large. Some candidate solutions are to write the whole thing in C (or @@ -7214,7 +7212,10 @@ amenable for pure SQL solutions) write the whole thing in Python Would (3) be a bad idea? I know you can wrap C routines in Python but in this case since there isn't anything computationally prohibitive (e.g., optimization routines that require many iterative calculations), I think I/O may be as much of a bottleneck as the computation itself. Do you have any recommendations on further considerations or suggestions? Thanks -Edit Thanks for your responses. There seems to be conflicting opinions about Hadoop, but in any case I don't have access to a cluster (though I can use several unnetworked machines)...","(3) is not necessarily a bad idea -- Python makes it easy to process ""CSV"" file (and despite the C standing for Comma, tab as a separator is just as easy to handle) and of course gets just about as much bandwidth in I/O ops as any other language. As for other recommendations, numpy, besides fast computation (which you may not need as per your statements) provides very handy, flexible multi-dimensional arrays, which may be quite handy for your tasks; and the standard library module multiprocessing lets you exploit multiple cores for any task that's easy to parallelize (important since just about every machine these days has multi-cores;-).",1.2,True,4,584 +Edit Thanks for your responses. There seems to be conflicting opinions about Hadoop, but in any case I don't have access to a cluster (though I can use several unnetworked machines)...","When you say ""accumulating"" then solution (2) looks most suitable to problem. +After initial load up to database you only update database with new files (daily, weekly? depends how often you need this). +In cases (1) and (3) you need to process files each time (what was stated earlier as most time/resources-consuming), unless you find a way to stored results and update them with new files. +You could use R to process files from csv to, for example, SQLite database.",0.1016881243684853,False,4,584 2010-05-30 05:06:28.333,large amount of data in many text files - how to process?,"I have large amounts of data (a few terabytes) and accumulating... They are contained in many tab-delimited flat text files (each about 30MB). Most of the task involves reading the data and aggregating (summing/averaging + additional transformations) over observations/rows based on a series of predicate statements, and then saving the output as text, HDF5, or SQLite files, etc. I normally use R for such tasks but I fear this may be a bit large. Some candidate solutions are to write the whole thing in C (or @@ -7227,9 +7228,8 @@ amenable for pure SQL solutions) write the whole thing in Python Would (3) be a bad idea? I know you can wrap C routines in Python but in this case since there isn't anything computationally prohibitive (e.g., optimization routines that require many iterative calculations), I think I/O may be as much of a bottleneck as the computation itself. Do you have any recommendations on further considerations or suggestions? Thanks -Edit Thanks for your responses. There seems to be conflicting opinions about Hadoop, but in any case I don't have access to a cluster (though I can use several unnetworked machines)...","Yes. You are right! I/O would cost most of your processing time. I don't suggest you to use distributed systems, like hadoop, for this task. -Your task could be done in a modest workstation. I am not an Python expert, I think it has support for asynchronous programming. In F#/.Net, the platform has well support for that. I was once doing an image processing job, loading 20K images on disk and transform them into feature vectors only costs several minutes in parallel. -all in all, load and process your data in parallel and save the result in memory (if small), in database (if big).",0.0509761841073563,False,4,584 +Edit Thanks for your responses. There seems to be conflicting opinions about Hadoop, but in any case I don't have access to a cluster (though I can use several unnetworked machines)...","With terabytes, you will want to parallelize your reads over many disks anyway; so might as well go straight into Hadoop. +Use Pig or Hive to query the data; both have extensive support for user-defined transformations, so you should be able to implement what you need to do using custom code.",0.2012947653214861,False,4,584 2010-05-31 08:47:26.927,python dictionary with constant value-type,"I bumped into a case where I need a big (=huge) python dictionary, which turned to be quite memory-consuming. However, since all of the values are of a single type (long) - as well as the keys, I figured I can use python (or numpy, doesn't really matter) array for the values ; and wrap the needed interface (in: x ; out: d[x]) with an object which actually uses these arrays for the keys and values storage. I can use a index-conversion object (input --> index, of 1..n, where n is the different-values counter), and return array[index]. I can elaborate on some techniques of how to implement such an indexing-methods with reasonable memory requirement, it works and even pretty good. @@ -7248,40 +7248,6 @@ Why I want to learn Python Django? I gave in, based on many searches on SO and reading over some of the answers, Python is a great, clean, and structured language to learn. And with the framework Django, it's easier to write codes that are shorter than with PHP Questions -Can i do everything in Django as in PHP? -Is Django a ""big"" hit in web development as PHP? I know Python is a -great general-purpose language but I'm -focused on web development and would -like to know how Django ranks in terms -of web development. -With PHP, PHP and Mysql are VERY closely related, is there a close relation between Django and Mysql? -In PHP, you can easily switch between HTML, CSS, PHP all in one script. Does Python offer this type of ease between other languages? Or how do I incorporate HTML, CSS, javascript along with Python?","Can i do everything in Django as in PHP? - -Always - -Is Django a ""big"" hit in web development as PHP? - -Only time will tell. - -With PHP, PHP and Mysql are VERY closely related, is there a close relation between Django and Mysql? - -Django supports several RDBMS interfaces. MySQL is popular, so is SQLite and Postgres. - -In PHP, you can easily switch between HTML, CSS, PHP all in one script. - -That doesn't really apply at all to Django. - -Or how do I incorporate HTML, CSS, javascript along with Python? - -Actually do the Django tutorial. You'll see how the presentation (via HTML created by templates) and the processing (via Python view functions) fit together. It's not like PHP.",1.2,True,2,588 -2010-06-02 20:36:22.790,How to transition from PHP to Python Django?,"Here's my background: -Decent experience with PHP/MySql. -Beginner's experience with OOP - -Why I want to learn Python Django? -I gave in, based on many searches on SO and reading over some of the answers, Python is a great, clean, and structured language to learn. And with the framework Django, it's easier to write codes that are shorter than with PHP -Questions - Can i do everything in Django as in PHP? Is Django a ""big"" hit in web development as PHP? I know Python is a great general-purpose language but I'm @@ -7296,16 +7262,50 @@ NO! Python would never give you the right to mix up everything in one file and m Django is a Model-Template-View framework, great for any applications, from small to huge. PHP works fine only with small apps. Yeah, PHP == Personal Home Page, lol. P.S. Also you can minify your CSS and JS. And compile to one single file (one js, one css). All with django-assets. And yeah, there's a lot more reusable Django apps (for registration, twi/facebook/openid auth, oembed, other stuff). Just search Bitbucket and Github for ""django"". No need to reinvent a bicycle, like you do with PHP.",0.1016881243684853,False,2,588 -2010-06-03 00:28:13.580,Is PyOpenGL a good place to start learning opengl programming?,"I want to start learning OpenGL but I don't really want to have to learn another language to do it. I already am pretty proficient in python and enjoy the language. I just want to know how close it is to the regular api? Will I be able to pretty easily follow tutorials and books without too much trouble? -I know C++ gives better performance, but for just learning can I go wrong with PyOpenGL?","With the caveat that I have done very little OpenGL programming myself, I believe that for the purposes of learning, PyOpenGL is a good choice. The main reason is that PyOpenGL, like most other OpenGL wrappers, is just that: a thin wrapper around the OpenGL API. -One large benefit of PyOpenGL is that while in C you have to worry about calling the proper glVertex3{dfiX} command, Python allows you to just write glVertex3(x,y,z) without worrying about telling Python what type of argument you passed in. That might not sound like a big deal, but it's often much simpler to use Python's duck-typing instead of being overly concerned with static typing. -The OpenGL methods are almost completely all wrapped into Python methods, so while you'll be writing in Python, the algorithms and method calls you'll use are identical to writing OpenGL in any other language. But since you're writing in Python, you'll have many fewer opportunities to make ""silly"" mistakes with proper pointer usage, memory management, etc. that would just eat up your time if you were to study the API in C or C++, for instance.",1.2,True,2,589 +2010-06-02 20:36:22.790,How to transition from PHP to Python Django?,"Here's my background: +Decent experience with PHP/MySql. +Beginner's experience with OOP + +Why I want to learn Python Django? +I gave in, based on many searches on SO and reading over some of the answers, Python is a great, clean, and structured language to learn. And with the framework Django, it's easier to write codes that are shorter than with PHP +Questions + +Can i do everything in Django as in PHP? +Is Django a ""big"" hit in web development as PHP? I know Python is a +great general-purpose language but I'm +focused on web development and would +like to know how Django ranks in terms +of web development. +With PHP, PHP and Mysql are VERY closely related, is there a close relation between Django and Mysql? +In PHP, you can easily switch between HTML, CSS, PHP all in one script. Does Python offer this type of ease between other languages? Or how do I incorporate HTML, CSS, javascript along with Python?","Can i do everything in Django as in PHP? + +Always + +Is Django a ""big"" hit in web development as PHP? + +Only time will tell. + +With PHP, PHP and Mysql are VERY closely related, is there a close relation between Django and Mysql? + +Django supports several RDBMS interfaces. MySQL is popular, so is SQLite and Postgres. + +In PHP, you can easily switch between HTML, CSS, PHP all in one script. + +That doesn't really apply at all to Django. + +Or how do I incorporate HTML, CSS, javascript along with Python? + +Actually do the Django tutorial. You'll see how the presentation (via HTML created by templates) and the processing (via Python view functions) fit together. It's not like PHP.",1.2,True,2,588 2010-06-03 00:28:13.580,Is PyOpenGL a good place to start learning opengl programming?,"I want to start learning OpenGL but I don't really want to have to learn another language to do it. I already am pretty proficient in python and enjoy the language. I just want to know how close it is to the regular api? Will I be able to pretty easily follow tutorials and books without too much trouble? I know C++ gives better performance, but for just learning can I go wrong with PyOpenGL?","PyOpenGL I don't think it is a good choice. In my opinon in C/C++ it is easier to play around around with your OpenGL code - start with simple app, then add shader, then add some geometry functions, make a texture/geometry generator, build scene via CSG, etc. You know - to have fun, play around with code, experiment and learn something in process. I honestly just don't see myself doing this in python. Surely it is possible to do OpenGL programming in Python, but I see no reason to actually do it. Plus several OpenGL functions take memory pointers as arguments, and although there probably a class (or dozen of alternatives) for that case, I don't see a reason to use them when a traditional way of doing things is available in C/C++, especially when I think about amount of wrappers python code uses to pass vector or array of those into OpenGL function. It just looks like making things more complicated without a real reason to do that. Plus there is a noticeable performance drop, especially when you use ""RAW"" OpenGL. Besides, if you're going to make games, it is very likely that you'll have to use C++ or some other ""non-python"" language. P.S. I've done enough OpenGL programming, a lot of DirectX programming, but I specialize on C++, and use python only for certain algorithmic tests, tools and scripts.",0.0,False,2,589 +2010-06-03 00:28:13.580,Is PyOpenGL a good place to start learning opengl programming?,"I want to start learning OpenGL but I don't really want to have to learn another language to do it. I already am pretty proficient in python and enjoy the language. I just want to know how close it is to the regular api? Will I be able to pretty easily follow tutorials and books without too much trouble? +I know C++ gives better performance, but for just learning can I go wrong with PyOpenGL?","With the caveat that I have done very little OpenGL programming myself, I believe that for the purposes of learning, PyOpenGL is a good choice. The main reason is that PyOpenGL, like most other OpenGL wrappers, is just that: a thin wrapper around the OpenGL API. +One large benefit of PyOpenGL is that while in C you have to worry about calling the proper glVertex3{dfiX} command, Python allows you to just write glVertex3(x,y,z) without worrying about telling Python what type of argument you passed in. That might not sound like a big deal, but it's often much simpler to use Python's duck-typing instead of being overly concerned with static typing. +The OpenGL methods are almost completely all wrapped into Python methods, so while you'll be writing in Python, the algorithms and method calls you'll use are identical to writing OpenGL in any other language. But since you're writing in Python, you'll have many fewer opportunities to make ""silly"" mistakes with proper pointer usage, memory management, etc. that would just eat up your time if you were to study the API in C or C++, for instance.",1.2,True,2,589 2010-06-03 13:57:43.117,C++ code generation with Python,"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.","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"". As 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. It 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.",0.0509761841073563,False,1,590 @@ -7339,14 +7339,11 @@ To answer your second question: The syntax print ""any string"" is acceptable in 2010-06-04 21:01:38.043,add xml node to xml file with python,"I wonder if it is better add an element by opening file, search 'good place' and add string which contains xml code. Or use some library... i have no idea. I know how can i get nodes and properties from xml through for example lxml but what's the simpliest and the best way to add?","The safest way to add nodes to an XML document is to load it into a DOM, add the nodes programmatically and write it out again. There are several Python XML libraries. I have used minidom, but I have no reason to recommend it specifically over the others.",0.2012947653214861,False,1,593 2010-06-05 08:31:20.853,Coloring close points,"I have a dense set of points in the plane. I want them colored so that points that are close to each other have the same color, and a different color if they're far away. For simplicity assume that there are, say, 5 different colors to choose from. Turns out I've not the slightest idea how to do that .. -I'm using Tkinter with Python, by the way","I'd start with identifying the concentrations of the spots in the plane. Find the centers of those agglomerations and assign them each unique color. Then for other spots you could simply calculate the color using the linear principle. For example, if one center is red and the other is yellow, a point somewhere in the middle would become orange. -I'd probably use some exponential function instead of a linear principle. This will keep the point groups more or less of the same color only giving a noticeable color change to far away points, or, to be more exact, to far away and somewhere in between points.",0.0,False,2,594 -2010-06-05 08:31:20.853,Coloring close points,"I have a dense set of points in the plane. I want them colored so that points that are close to each other have the same color, and a different color if they're far away. For simplicity assume that there are, say, 5 different colors to choose from. Turns out I've not the slightest idea how to do that .. I'm using Tkinter with Python, by the way","One approach is to go through your points and partition them into sets with a ""center"". Since you have 5 colours, you'll have 5 sets. You compare the distance of the new point from each of the centers and then put it in the same group as the closest one. Each set corresponds to a different colour so you can just plot it after this partitioning is done.",0.0,False,2,594 -2010-06-06 19:53:26.243,Adding percentage in python - xlwt / pyexcelerator,"just a quick question, how to add percent sign to numbers without modifying number. I have tried format percent with myStyleFont.num_format_str = '0.00%' but it multiplies with 100 but I need just to append percent. -Ty in advance. -Regards.","The 00.0% number format expects percentages, so multiplying by 100 to display it is the correct behavior. To get the results you want, you could either put the data in the cell as a string in whatever format you choose or you could divide by 100.0 before you store the value in the cell.",0.1016881243684853,False,2,595 +2010-06-05 08:31:20.853,Coloring close points,"I have a dense set of points in the plane. I want them colored so that points that are close to each other have the same color, and a different color if they're far away. For simplicity assume that there are, say, 5 different colors to choose from. Turns out I've not the slightest idea how to do that .. +I'm using Tkinter with Python, by the way","I'd start with identifying the concentrations of the spots in the plane. Find the centers of those agglomerations and assign them each unique color. Then for other spots you could simply calculate the color using the linear principle. For example, if one center is red and the other is yellow, a point somewhere in the middle would become orange. +I'd probably use some exponential function instead of a linear principle. This will keep the point groups more or less of the same color only giving a noticeable color change to far away points, or, to be more exact, to far away and somewhere in between points.",0.0,False,2,594 2010-06-06 19:53:26.243,Adding percentage in python - xlwt / pyexcelerator,"just a quick question, how to add percent sign to numbers without modifying number. I have tried format percent with myStyleFont.num_format_str = '0.00%' but it multiplies with 100 but I need just to append percent. Ty in advance. Regards.","Note carefully: ""modifying"" and ""multiplies with 100"" affect the displayed result, they affect neither the value stored in the file nor the value used in formula calculations. @@ -7357,6 +7354,9 @@ The above is a property of Excel, not restricted to Python or xlwt etc. You can Note that unless you have a restricted set of users who will read and understand the documentation that you will write [unlikely * 3], you shouldn't do that; it will be rather confusing -- the normal Excel user on seeing 5.00% assumes that the underlying number is 0.05. To see this, in Excel etc type these into A1, A2, A3: 5% then .05 then =A1=A2 ... you will see TRUE in A3. pyExcelerator is abandonware; why do you mention it??? About myStyleFont.num_format_str = '0.00%' (1) ""font"" and ""num_format_str"" are quite independent components of a style aka XF; your variable name ""myStyleFont"" is confused/confusing. (2) Setting up XFs by poking attributes into objects is old hat in xlwt; use easyxf instead.",1.2,True,2,595 +2010-06-06 19:53:26.243,Adding percentage in python - xlwt / pyexcelerator,"just a quick question, how to add percent sign to numbers without modifying number. I have tried format percent with myStyleFont.num_format_str = '0.00%' but it multiplies with 100 but I need just to append percent. +Ty in advance. +Regards.","The 00.0% number format expects percentages, so multiplying by 100 to display it is the correct behavior. To get the results you want, you could either put the data in the cell as a string in whatever format you choose or you could divide by 100.0 before you store the value in the cell.",0.1016881243684853,False,2,595 2010-06-07 02:24:39.973,"what should i do after openid (or twitter ,facebook) user login my site ,on gae","how to integration local user and openid(or facebook twitter) user , did you know some framework have already done this , updated @@ -7383,11 +7383,6 @@ Do not resort to a polling loop.",1.2,True,1,599 I approximatily need to call this method about 10,000 times.which is making my program very slow? any 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? I 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... -thanks in advance","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?",0.1618299653758019,False,4,600 -2010-06-09 14:28:39.490,how to speed up the code?,"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. -I approximatily need to call this method about 10,000 times.which is making my program very slow? -any 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? -I 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... thanks in advance","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. If you are modifying the data, the alternative might be a database like SQLite, or embedded MS SQL Server (and there are others, too!). It'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. @@ -7396,6 +7391,11 @@ Without more information about the files (how big are they?) and the data (how i I approximatily need to call this method about 10,000 times.which is making my program very slow? any 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? I 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... +thanks in advance","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?",0.1618299653758019,False,4,600 +2010-06-09 14:28:39.490,how to speed up the code?,"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. +I approximatily need to call this method about 10,000 times.which is making my program very slow? +any 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? +I 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... thanks in advance",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,0.0,False,4,600 2010-06-09 14:28:39.490,how to speed up the code?,"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. I approximatily need to call this method about 10,000 times.which is making my program very slow? @@ -7410,15 +7410,15 @@ If that is the case, my mantra is ""do less."" Save off results and keep them a On 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.",0.2012947653214861,False,1,601 2010-06-10 08:07:48.540,"how to make a chat room on gae ,has any audio python-framework to do this?","i want to make a chat room on gae ,(audio chat) has any framework to do this ? -thanks","App Engine doesn't directly support audio chat of any sort, and since it's based around a request-response system with (primarily) HTTP requests, you can't implement it yourself.",1.2,True,3,602 -2010-06-10 08:07:48.540,"how to make a chat room on gae ,has any audio python-framework to do this?","i want to make a chat room on gae ,(audio chat) -has any framework to do this ? thanks","You'll need two things: A browser plugin to get audio. You could build this on top of eg. http://code.google.com/p/libjingle/'>libjingle which has the advantage of being cross-platform and allowing P2P communication, not to mention being able to talk to arbitrary other XMPP endoints. Or you could use Flash to grab the audio and bounce the stream off a server you build (I think trying to do STUN in Flash for P2P would be impossible), but this would be very tricky to do in App Engine because you'd need it to be long-running. A way to get signaling messages between your clients. You'll have to poll until the Channel API is released (soon). This is a big hairy problem, to put it mildly, but it would be awesome if you did it.",0.0,False,3,602 2010-06-10 08:07:48.540,"how to make a chat room on gae ,has any audio python-framework to do this?","i want to make a chat room on gae ,(audio chat) has any framework to do this ? +thanks","App Engine doesn't directly support audio chat of any sort, and since it's based around a request-response system with (primarily) HTTP requests, you can't implement it yourself.",1.2,True,3,602 +2010-06-10 08:07:48.540,"how to make a chat room on gae ,has any audio python-framework to do this?","i want to make a chat room on gae ,(audio chat) +has any framework to do this ? thanks",Try Adobe Stratus (it works with p2p connections) and you could use Google App Engine only for exchanging peer ids.,0.1016881243684853,False,3,602 2010-06-10 09:21:55.470,Sequence and merge jpeg images using Python?,"im doing a project as part of academic programme.Im doing this in linux platform.here i wanted to create a application which retrieve some information from some pdf files .for eg i have pdfs of subject2,subject1,in both the whole pdf is divided in to 4 modules and i want to get the data of module 1 from pdf..for this purpose my tutor told me to use pdftohtml application and convert pdf files to html and jpeg images.now i want to create a Python script which will combine the pages(which have been coverted in to jpeg images) under module 1 and merge it into a single file and then i will convert it back to pdf . how can i do this?.if anyone can provide any such python script which have done any functions similar to this then it will be very helpful. .... @@ -7431,13 +7431,8 @@ I think it would be preferable to intercept the open socket request, rather than Can I do this with a shell script? Or perhaps I need to override the asyncore module at the Python level? Thanks in advance, - B","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.",0.0,False,1,604 -2010-06-10 15:31:25.473,Fast Esp Custom Stage Development,I am working on Enterprise Search and we are using Fast ESP and for now i have 4 projects but i have no information about stages and python. But i realize that i have learn custom stage development. Because we have a lot of difficulties about document processing. I want to know how can i develop custom stage and especially i wanna know about how i can find Attributefilter stage source code. I am waiting your answers,"The FAST documentation (ESP Document Processor Integration Guide) has a pretty good example of how to write a custom document processor. FAST does not provide the source code to any of it's software, but the AttributeFilter stage functionality should be very straightforward.",1.2,True,2,605 2010-06-10 15:31:25.473,Fast Esp Custom Stage Development,I am working on Enterprise Search and we are using Fast ESP and for now i have 4 projects but i have no information about stages and python. But i realize that i have learn custom stage development. Because we have a lot of difficulties about document processing. I want to know how can i develop custom stage and especially i wanna know about how i can find Attributefilter stage source code. I am waiting your answers,"I had worked with FAST ESP for document processing and we used to modify the python files. you can modify them but you need to restart the document processor each time you modify any file. You need to search for document processing in the admin UI, there you go to the pipelines, and you can create a custom pipeline based on standard pipelines included in FAST ESP. Once you create your pipeline, then you can select the stage (python program) that you want to modify and the UI shows you the path of each script. I highly recommend you to create your custom stages for each pipeline you modify.",0.0,False,2,605 -2010-06-11 04:53:39.087,how to make a python or perl script portable to both linux and windows?,"I was wondering how to make a python script portable to both linux and windows? -One problem I see is shebang. How to write the shebang so that the script can be run on both windows and linux? -Are there other problems besides shebang that I should know? -Is the solution same for perl script? -Thanks and regards!","The shebang line will be interpreted as a comment by Perl or Python. The only thing that assigns it a special meaning is the UNIX/Linux shell; it gets ignored on Windows. The way Windows knows which interpreter to use to run the file is through the file associations in the registry, a different mechanism altogether.",0.2012947653214861,False,2,606 +2010-06-10 15:31:25.473,Fast Esp Custom Stage Development,I am working on Enterprise Search and we are using Fast ESP and for now i have 4 projects but i have no information about stages and python. But i realize that i have learn custom stage development. Because we have a lot of difficulties about document processing. I want to know how can i develop custom stage and especially i wanna know about how i can find Attributefilter stage source code. I am waiting your answers,"The FAST documentation (ESP Document Processor Integration Guide) has a pretty good example of how to write a custom document processor. FAST does not provide the source code to any of it's software, but the AttributeFilter stage functionality should be very straightforward.",1.2,True,2,605 2010-06-11 04:53:39.087,how to make a python or perl script portable to both linux and windows?,"I was wondering how to make a python script portable to both linux and windows? One problem I see is shebang. How to write the shebang so that the script can be run on both windows and linux? Are there other problems besides shebang that I should know? @@ -7446,6 +7441,11 @@ Thanks and regards!","Windows will just ignore the shebang (which is, after all, There are many bits and pieces which are platform-specific (many only exist on Unix, msvcrt only on Windows) so if you want to be portable you should abstain from those; some are subtly different (such as the detailed precise behavior of subprocess.Popen or mmap) -- it's all pretty advanced stuff and the docs will guide you there. If you're executing (via subprocess or otherwise) external commands you'd better make sure they exist on both platforms, of course, or check what platform you're in and use different external commands in each case. Remember to always use /, not \, as path separator (forward slash works in both platforms, backwards slash is windows-only), and be meticulous as to whether each file you're opening is binary or text. I think that's about it...",1.2,True,2,606 +2010-06-11 04:53:39.087,how to make a python or perl script portable to both linux and windows?,"I was wondering how to make a python script portable to both linux and windows? +One problem I see is shebang. How to write the shebang so that the script can be run on both windows and linux? +Are there other problems besides shebang that I should know? +Is the solution same for perl script? +Thanks and regards!","The shebang line will be interpreted as a comment by Perl or Python. The only thing that assigns it a special meaning is the UNIX/Linux shell; it gets ignored on Windows. The way Windows knows which interpreter to use to run the file is through the file associations in the registry, a different mechanism altogether.",0.2012947653214861,False,2,606 2010-06-11 07:35:15.440,send xml file to http using python,how can i send an xml file on my system to an http server using python standard library??,You can achieve that through a standard http post request.,0.2012947653214861,False,1,607 2010-06-11 15:44:52.190,How to merge or copy anonymous session data into user data when user logs in?,"This is a general question, or perhaps a request for pointers to other open source projects to look at: I'm wondering how people merge an anonymous user's session data into the authenticated user data when a user logs in. For example, someone is browsing around your websites saving various items as favourites. He's not logged in, so they're saved to an anonymous user's data. Then he logs in, and we need to merge all that data into their (possibly existing) user data. @@ -7477,6 +7477,8 @@ then, variable = request.session['name'] will retrieve it. Remember though, its not a database, just a simple session store and shouldn't be relied on for anything critical",0.0,False,2,610 2010-06-13 13:29:14.863,Detecting and interacting with long running process,"I want a script to start and interact with a long running process. The process is started first time the script is executed, after that the script can be executed repeatedly, but will detect that the process is already running. The script should be able to interact with the process. I would like this to work on Unix and Windows. +I am unsure how I do this. Specifically how do I detect if the process is already running and open a pipe to it? Should I use sockets (e.g. registering the server process on a known port and then check if it responds) or should I use ""named pipes""? Or is there some easier way?","Sockets are easier to make portable between Windows and any other OS, so that's what I would recommend it over named pipes (that's why e.g. IDLE uses sockets rather than named pipes -- the latter require platform-dependent code on Windows, e.g. via ctypes [[or third-party win32all or cython &c]], while sockets just work).",1.2,True,2,611 +2010-06-13 13:29:14.863,Detecting and interacting with long running process,"I want a script to start and interact with a long running process. The process is started first time the script is executed, after that the script can be executed repeatedly, but will detect that the process is already running. The script should be able to interact with the process. I would like this to work on Unix and Windows. I am unsure how I do this. Specifically how do I detect if the process is already running and open a pipe to it? Should I use sockets (e.g. registering the server process on a known port and then check if it responds) or should I use ""named pipes""? Or is there some easier way?","Well here is an idea... place a status somewhere else, that @@ -7490,8 +7492,6 @@ value to the 'control set' and have the process look for those values whenever it gets to decision points in its runtime behavior.",0.0,False,2,611 -2010-06-13 13:29:14.863,Detecting and interacting with long running process,"I want a script to start and interact with a long running process. The process is started first time the script is executed, after that the script can be executed repeatedly, but will detect that the process is already running. The script should be able to interact with the process. I would like this to work on Unix and Windows. -I am unsure how I do this. Specifically how do I detect if the process is already running and open a pipe to it? Should I use sockets (e.g. registering the server process on a known port and then check if it responds) or should I use ""named pipes""? Or is there some easier way?","Sockets are easier to make portable between Windows and any other OS, so that's what I would recommend it over named pipes (that's why e.g. IDLE uses sockets rather than named pipes -- the latter require platform-dependent code on Windows, e.g. via ctypes [[or third-party win32all or cython &c]], while sockets just work).",1.2,True,2,611 2010-06-13 23:32:37.893,Removing python and then re-installing on Mac OSX,"I was wondering if anyone had tips on how to completely remove a python installation form Mac OSX (10.5.8) ... including virtual environments and its related binaries. Over the past few years I've completely messed up the installed site-packages, virtual-environments, etc. and the only way I can see to fix it is to just uninstall everything and re-install. I'd like to completely re-do everything and use virtualenv, pip, etc. from the beginning. On the other hand if anyone knows a way to do this without removing python and re-installing I'd be happy to here about it. @@ -7575,14 +7575,14 @@ Just make yours be wherever your python binary is located. As for args look at getopt or optparser And remember to chmod your file to make it executable.",0.0,False,1,623 2010-06-18 00:05:39.683,Reboot windows machines at a certain time of day and automatically login with Python,"I know how to reboot machines remotely, so that's the easy part. However, the complexity of the issue is trying to setup the following. I'd like to control machines on a network for after-hours use such that when users logoff and go home, or shutdown their computers, whatever, python or some combination of python + windows could restart their machines (for cleanliness) and automatically login, running a process for the night, then in the morning, stop said process and restart the machine so the user could easily login like normal. +I've looked around, haven't had too terribly much luck, though it looks like one could do it with a changing of the registry. That sounds like a rough idea though, modifying the registry on a per-day basis. Is there an easier way?","Thanks for the responses. To be more clear on what I'm doing, I have a program that automatically starts on bootup, so getting logged in would be preferred. I'm coding a manager for a render-farm for work which will take all the machines that our guys use during the day and turn them into render servers at night (or whenever they log off for a period of time, for example). +I'm not sure if I necessarily require a GUI app, but the computer would need to boot and login to launch a server application that does the rendering, and I'm not certain if that can be done without logging in. What i'm needing to run is Autodesk's Backburner Server.exe +Maybe that can be run without needing to be logged in specifically, but I'm unfamiliar with doing things of that nature.",0.0,False,2,624 +2010-06-18 00:05:39.683,Reboot windows machines at a certain time of day and automatically login with Python,"I know how to reboot machines remotely, so that's the easy part. However, the complexity of the issue is trying to setup the following. I'd like to control machines on a network for after-hours use such that when users logoff and go home, or shutdown their computers, whatever, python or some combination of python + windows could restart their machines (for cleanliness) and automatically login, running a process for the night, then in the morning, stop said process and restart the machine so the user could easily login like normal. I've looked around, haven't had too terribly much luck, though it looks like one could do it with a changing of the registry. That sounds like a rough idea though, modifying the registry on a per-day basis. Is there an easier way?","I can't think of any way to do strictly what you want off the top of my head other than the registry, at least not without even more drastic measures. But doing this registry modification isn't a big deal; just change the autologon username/password and reboot the computer. To have the computer reboot when the user logs off, give them a ""logoff"" option that actually reboots rather than logging off; I've seen other places do that. (edit)FYI: for registry edits, Windows has a REG command that will be useful if you decide to go with that route.(/edit) Also, what kind of process are you trying to run? If it's not a GUI app that needs your interaction, you don't have to go through any great pains; just run the app remotely. At my work, we use psexec to do it very simply, and I've also created C++ programs that run code remotely. It's not that difficult, the way I do it is to have C++ call the WinAPI function to remotely register a service on the remote PC and start it, the service then does whatever I want (itself, or as a staging point to launch other things), then unregisters itself. I have only used Python for simple webpage stuff, so I'm not sure what kind of support it has for accessing the DLLs required, but if it can do that, you can still use Python here. Or even better yet, if you don't need to do this remotely but just want it done every night, you can just use the Windows scheduler to run whatever application you want run during the night. You can even do this programmatically as there are a couple Windows commands for that: one is the ""at"" command, and I don't recall right now what the other is but just a little Googling should find it for you.",1.2,True,2,624 -2010-06-18 00:05:39.683,Reboot windows machines at a certain time of day and automatically login with Python,"I know how to reboot machines remotely, so that's the easy part. However, the complexity of the issue is trying to setup the following. I'd like to control machines on a network for after-hours use such that when users logoff and go home, or shutdown their computers, whatever, python or some combination of python + windows could restart their machines (for cleanliness) and automatically login, running a process for the night, then in the morning, stop said process and restart the machine so the user could easily login like normal. -I've looked around, haven't had too terribly much luck, though it looks like one could do it with a changing of the registry. That sounds like a rough idea though, modifying the registry on a per-day basis. Is there an easier way?","Thanks for the responses. To be more clear on what I'm doing, I have a program that automatically starts on bootup, so getting logged in would be preferred. I'm coding a manager for a render-farm for work which will take all the machines that our guys use during the day and turn them into render servers at night (or whenever they log off for a period of time, for example). -I'm not sure if I necessarily require a GUI app, but the computer would need to boot and login to launch a server application that does the rendering, and I'm not certain if that can be done without logging in. What i'm needing to run is Autodesk's Backburner Server.exe -Maybe that can be run without needing to be logged in specifically, but I'm unfamiliar with doing things of that nature.",0.0,False,2,624 2010-06-18 20:43:39.873,ZeroConf Chat with Python,"I am trying to set up a Bonjour (or Ahavi) chatbot for our helpdesk system that would answer basic questions based on a menu system. The basis of my question is how do I get python to create the bot so that it connects to the network as a chat client. Basically, anyone on my network with iChat or Empathy (or any chat program able to view users over the local network) should see the bot just as they see another user. The actual bot part would be quite simple to program, but I have no idea how to get it on the network. I have looked into ZeroConf, but I'm not exactly sure how it works, or how to get a chat service running with python. I have seen references to pybonjour, python bindings for avahi, and pyzeroconf, but again, I have no idea how to set them up. @@ -7591,6 +7591,12 @@ Kory","The easiest thing to do is to use Telepathy Salut or Pidgin/libpurple, an 2010-06-19 02:38:53.503,From the web to games,"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. Now, 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. I 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. +So, any hints, tips or sugestions to make?","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. +If 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 +Unity made me sick to my stomach, and so did Blender3D's game engine, so I personally say not to use those. It intimidated me.",0.0,False,4,626 +2010-06-19 02:38:53.503,From the web to games,"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. +Now, 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. +I 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. So, any hints, tips or sugestions to make?","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. another 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). Going 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. @@ -7600,17 +7606,11 @@ oh and a note.. stay away from Tkinter in python for anything more than a simple 2010-06-19 02:38:53.503,From the web to games,"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. Now, 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. I 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. -So, any hints, tips or sugestions to make?","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. -If 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 -Unity made me sick to my stomach, and so did Blender3D's game engine, so I personally say not to use those. It intimidated me.",0.0,False,4,626 +So, any hints, tips or sugestions to make?","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.",0.0,False,4,626 2010-06-19 02:38:53.503,From the web to games,"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. Now, 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. I 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. So, any hints, tips or sugestions to make?","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.",0.0,False,4,626 -2010-06-19 02:38:53.503,From the web to games,"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. -Now, 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. -I 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. -So, any hints, tips or sugestions to make?","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.",0.0,False,4,626 2010-06-19 20:38:22.590,"Does GQL automatically add an ""ID"" Property","I currently work with Google's AppEngine and I could not find out, whether a Google DataStorage Object Entry has an ID by default, and if not, how I add such a field and let it increase automatically? regards,","Yes, they have id's by default, and it is named ID as you mentioned.",1.2,True,2,627 2010-06-19 20:38:22.590,"Does GQL automatically add an ""ID"" Property","I currently work with Google's AppEngine and I could not find out, whether a Google DataStorage Object Entry has an ID by default, and if not, how I add such a field and let it increase automatically? @@ -7660,9 +7660,6 @@ thanks in advance.. didnt mention the file format as i felt it is not neccesary will mention if required..","A 4MB file is very small, it fits in memory for sure. The fastest approach would be to read it all and then iterate over each line searching for the pattern, writing out the line to the appropriate file depending on the pattern (your approach for small files.)",0.1352210990936997,False,1,632 2010-06-22 20:38:16.823,How to calculate the time interval between two time strings,"I have two times, a start and a stop time, in the format of 10:33:26 (HH:MM:SS). I need the difference between the two times. I've been looking through documentation for Python and searching online and I would imagine it would have something to do with the datetime and/or time modules. I can't get it to work properly and keep finding only how to do this when a date is involved. Ultimately, I need to calculate the averages of multiple time durations. I got the time differences to work and I'm storing them in a list. I now need to calculate the average. I'm using regular expressions to parse out the original times and then doing the differences. -For the averaging, should I convert to seconds and then average?","Take a look at the datetime module and the timedelta objects. You should end up constructing a datetime object for the start and stop times, and when you subtract them, you get a timedelta.",0.0509761841073563,False,2,633 -2010-06-22 20:38:16.823,How to calculate the time interval between two time strings,"I have two times, a start and a stop time, in the format of 10:33:26 (HH:MM:SS). I need the difference between the two times. I've been looking through documentation for Python and searching online and I would imagine it would have something to do with the datetime and/or time modules. I can't get it to work properly and keep finding only how to do this when a date is involved. -Ultimately, I need to calculate the averages of multiple time durations. I got the time differences to work and I'm storing them in a list. I now need to calculate the average. I'm using regular expressions to parse out the original times and then doing the differences. For the averaging, should I convert to seconds and then average?","you could try this: from datetime import datetime start = datetime.now() @@ -7671,6 +7668,9 @@ print(start) end = datetime.now() print(end) print(end - start)",0.0,False,2,633 +2010-06-22 20:38:16.823,How to calculate the time interval between two time strings,"I have two times, a start and a stop time, in the format of 10:33:26 (HH:MM:SS). I need the difference between the two times. I've been looking through documentation for Python and searching online and I would imagine it would have something to do with the datetime and/or time modules. I can't get it to work properly and keep finding only how to do this when a date is involved. +Ultimately, I need to calculate the averages of multiple time durations. I got the time differences to work and I'm storing them in a list. I now need to calculate the average. I'm using regular expressions to parse out the original times and then doing the differences. +For the averaging, should I convert to seconds and then average?","Take a look at the datetime module and the timedelta objects. You should end up constructing a datetime object for the start and stop times, and when you subtract them, you get a timedelta.",0.0509761841073563,False,2,633 2010-06-23 05:58:52.023,Changing the selected item colour in a GtkTreeview using python,"I have a dialog which contains a pygtk.treeview for listing tasks by priority. Each row has the background colour set based on that priority, so for example the highest priority has a light red background. The row selection color is not so easy to change. I can set it using treeview.modify_base(gtk.STATE_SELECTED, ""#C4C4C4""), but no colours work well with the colours used to enhance the concept of priority. I had the idea to change the selection colour to be a slightly darker version of the colour used as the normal row background, so in the example above, that would be a darker red. I tried calling the function above in response to the treeselection's changed signal, and it works, but with heavy flickering. @@ -7695,14 +7695,14 @@ Example in GTK C#: treeViewList.ModifyBase(StateType.Selected, treeViewList.Style.Base(StateType.Normal)); treeViewList.ModifyText(StateType.Selected, treeViewList.Style.Text(StateType.Normal));",0.0,False,2,634 2010-06-24 01:43:41.017,Any productive way to install a bunch of packages,"I had one machine with my commonly used python package installed. -and i would like to install the same package on another machine or same machine with different python version. I would like to know whether pip or easy-install or some other method can let me install those packages in a batch. When i use perl, it has something like a bundle package, how to do that in python?","I keep a requirements.txt file in one of my repositories that has all my basic python requirements and use PIP to install them on any new machine. -Each of my projects also has it's own requirements.txt file that contains all of it's dependencies for use w/virtualenv.",0.0,False,2,635 -2010-06-24 01:43:41.017,Any productive way to install a bunch of packages,"I had one machine with my commonly used python package installed. and i would like to install the same package on another machine or same machine with different python version. I would like to know whether pip or easy-install or some other method can let me install those packages in a batch. When i use perl, it has something like a bundle package, how to do that in python?","Pip has some great features for this. It lets you save all requirements from an environment in a file using pip freeze > reqs.txt You can then later do : pip install -r reqs.txt and you'll get the same exact environnement. You can also bundle several libraries into a .pybundle file with the command pip bundle MyApp.pybundle -r reqs.txt, and later install it with pip install MyApp.pybundle. I guess that's what you're looking for :)",0.9997532108480276,False,2,635 +2010-06-24 01:43:41.017,Any productive way to install a bunch of packages,"I had one machine with my commonly used python package installed. +and i would like to install the same package on another machine or same machine with different python version. I would like to know whether pip or easy-install or some other method can let me install those packages in a batch. When i use perl, it has something like a bundle package, how to do that in python?","I keep a requirements.txt file in one of my repositories that has all my basic python requirements and use PIP to install them on any new machine. +Each of my projects also has it's own requirements.txt file that contains all of it's dependencies for use w/virtualenv.",0.0,False,2,635 2010-06-24 08:25:55.350,"In Python script, how do I set PYTHONPATH?","I know how to set it in my /etc/profile and in my environment variables. But what if I want to set it during a script? Is it import os, sys? How do I do it?","you can set PYTHONPATH, by os.environ['PATHPYTHON']=/some/path, then you need to call os.system('python') to restart the python shell to make the newly added path effective.",-0.2655860252697744,False,1,636 @@ -7762,16 +7762,9 @@ I like the way things are clearly separated with this option. If a user somehow Option 2) Use the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever. This option feels less clean to me, but I also feel like it's more common. -Which would be preferred by Djangonauts? Or is there another option that's better than either of the above?","If you're writing a web 2.0 messaging app, you would be using AJAX calls and wouldn't be loading a new page at all. The process would proceed like so: - -User clicks [delete] for a message. This button has a javascript action bound to it. This action does the following: -i. Change the UI to indicate that something is happening (grey the message or put up an hourglass). -ii. Send a request to /messages/inbox/1234/delete. (where 1234 is some identifier that indicates which message) -iii. When the response from the server comes back, it should indicate success or failure. Reflect this status in the current UI. For example, on success, refresh the inbox view (or just remove the deleted item). - -On the server side, now you can create a URL handler for each desired action (i.e. /delete, /flag, etc.). -If want to use an even more RESTful approach, you would use the HTTP action itself to indicate the action to perform. So instead of including delete in your URL, it would be in the action. So instead of GET or POST, use DELETE /messages/inbox/1234. To set a flag for having been read, use SET /messages/inbox/1234?read=true. -I don't know how straightforward it is in Django to implement this latter recommendation, but in general, it's a good idea utilize the protocol (in this case HTTP), rather than work around it by encoding your actions into a URL or parameter.",0.1016881243684853,False,4,642 +Which would be preferred by Djangonauts? Or is there another option that's better than either of the above?","I agree that #2 is a better approach. +But take care with overloading the submit with different methods -- if a user is using it with keyboard input and hits enter, it won't necessarily submit the you're expecting. Either disable auto-submit-on-enter, or code things up so that if there is more than one thing that submit can do, there's another field that sets what the action should be (eg a 'delete' checkbox, which is tested during a request.POST) +If you went with #1 I'd say that a GET to a POST-only view should be met with a 405 (method not supported) - or, failing that, a 404.",0.0,False,4,642 2010-06-27 09:36:21.520,URLs and side effects (Django),"I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a user should be able to do a bunch of things like: Delete a message @@ -7785,7 +7778,16 @@ I like the way things are clearly separated with this option. If a user somehow Option 2) Use the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever. This option feels less clean to me, but I also feel like it's more common. -Which would be preferred by Djangonauts? Or is there another option that's better than either of the above?","I don't think there's anything wrong with either option, but #2 is potentially better from a performance standpoint. After the action is posted you can render the inbox without a redirect, so it cuts down on the HTTP traffic.",0.1016881243684853,False,4,642 +Which would be preferred by Djangonauts? Or is there another option that's better than either of the above?","If you're writing a web 2.0 messaging app, you would be using AJAX calls and wouldn't be loading a new page at all. The process would proceed like so: + +User clicks [delete] for a message. This button has a javascript action bound to it. This action does the following: +i. Change the UI to indicate that something is happening (grey the message or put up an hourglass). +ii. Send a request to /messages/inbox/1234/delete. (where 1234 is some identifier that indicates which message) +iii. When the response from the server comes back, it should indicate success or failure. Reflect this status in the current UI. For example, on success, refresh the inbox view (or just remove the deleted item). + +On the server side, now you can create a URL handler for each desired action (i.e. /delete, /flag, etc.). +If want to use an even more RESTful approach, you would use the HTTP action itself to indicate the action to perform. So instead of including delete in your URL, it would be in the action. So instead of GET or POST, use DELETE /messages/inbox/1234. To set a flag for having been read, use SET /messages/inbox/1234?read=true. +I don't know how straightforward it is in Django to implement this latter recommendation, but in general, it's a good idea utilize the protocol (in this case HTTP), rather than work around it by encoding your actions into a URL or parameter.",0.1016881243684853,False,4,642 2010-06-27 09:36:21.520,URLs and side effects (Django),"I'm wondering if it's considered okay (particularly, in Django) to have a URL that's only intended for actions with side effects, that's only intended to be accessed by POST, and that is basically invisible to the user. Let's say, for the sake of making this concrete, I have a little messaging system on my site, and from their inbox, a user should be able to do a bunch of things like: Delete a message @@ -7799,9 +7801,7 @@ I like the way things are clearly separated with this option. If a user somehow Option 2) Use the same URL and view for each action, and have a POST parameter that identifies the action. So I would have one rather long inbox view, which would have a bunch of if statements testing whether request.POST['action'] == 'delete', or request.POST['delete'] == 'true' or whatever. This option feels less clean to me, but I also feel like it's more common. -Which would be preferred by Djangonauts? Or is there another option that's better than either of the above?","I agree that #2 is a better approach. -But take care with overloading the submit with different methods -- if a user is using it with keyboard input and hits enter, it won't necessarily submit the you're expecting. Either disable auto-submit-on-enter, or code things up so that if there is more than one thing that submit can do, there's another field that sets what the action should be (eg a 'delete' checkbox, which is tested during a request.POST) -If you went with #1 I'd say that a GET to a POST-only view should be met with a 405 (method not supported) - or, failing that, a 404.",0.0,False,4,642 +Which would be preferred by Djangonauts? Or is there another option that's better than either of the above?","I don't think there's anything wrong with either option, but #2 is potentially better from a performance standpoint. After the action is posted you can render the inbox without a redirect, so it cuts down on the HTTP traffic.",0.1016881243684853,False,4,642 2010-06-27 16:07:43.173,Is it possible to run two versions of Python side-by-side?,"I've been learning Python for a couple of weeks, and although I've been successfully develop apps for Google App Engine with Python 2.6.5, it specifically requires Python 2.5. Being mindful of compatibility issues when uploading apps (it's a situation I'd rather avoid while learning Python), I wonder if it's possible to have 2.5 and 2.6.5 installed on the same machine. Ideally I'd like to use 2.6.5 as the default, and configure GAE to somehow use 2.5.","Absolutely. If you're on *nix, you'd usually just use make altinstall instead of make install, that way the ""python"" binary won't get installed/overwritten, but instead you'd have e.g. python2.5 or python2.6 installed. Using a separate --prefix with the configure script is also an option, of course. @@ -7861,15 +7861,15 @@ in your setup.py py2exe options.",1.2,True,1,648 2010-07-01 06:52:22.183,Is Django admin difficult to customize?,"I have been playing for a couple of days with Django Admin to explore it, but I am still clueless of how it can be customized in the way we need. Every time I look for any help for the customization in the admin panel, what I find is, a bunch of articles on various communities and forums, explaining how to customize the template, the lists items, the the column views etc. But that should not be called Django Customization. If I need to make even a small change in the User functionality or any modification to the auth module. It takes a lots of efforts even in figuring out how that can be done. -Is Django that difficult to customize or its just lack of the help available over internet for this or its me who is moving in the wrong direction ?","Personally, if you want a site to look like the admin, why not pull the templates and styles and use them, build your own views for what you need. Gobs of documentation and forum help is there for that. I like the idea of customizing the admin, but honestly, I have been doing it for awhile on a project and time and time again I think to myself, if this was built in the standard MVC (or MTV) manner with free templates online, copied admin ones, or some professionally made ones, and built with the plethora of addons and my code, it would be much easier!!! And, when you decide that request/response isn't cutting it, and you want to add lots of JavaScript, you'll be glad. I know. I have had to put all sorts of JavaScript on our Admin project. Mostly because it's impossible to make the admin do what we want, so we fix it with JavaScript once it is on screen. When you find yourself writing an Ajax based system, you'll wonder why you have the admin at all. -If I could start this project over, I might not even use Django, but I probably would. I most certainly won't used the Admin. -Now, if you are building an basic CRUD type site that doesn't have style-eyed users, then Django with grappelli, and some elbow grease will get the job done. Remember, Django is a collection of Python scripts. Just override everything you can, and you'll get there, if you aren't too ambitious.",0.296905446847765,False,2,649 -2010-07-01 06:52:22.183,Is Django admin difficult to customize?,"I have been playing for a couple of days with Django Admin to explore it, but I am still clueless of how it can be customized in the way we need. -Every time I look for any help for the customization in the admin panel, what I find is, a bunch of articles on various communities and forums, explaining how to customize the template, the lists items, the the column views etc. But that should not be called Django Customization. -If I need to make even a small change in the User functionality or any modification to the auth module. It takes a lots of efforts even in figuring out how that can be done. Is Django that difficult to customize or its just lack of the help available over internet for this or its me who is moving in the wrong direction ?","Django Admin is easy to customize if your requirements match what is customizable in Django. If you need fancy features that are not out-of-the-box functionality you either need to find a plugin that does it, or implement it yourself by subclassing the appropriate classes. Which can be difficult, and requires good understanding of the internals of Django. So in summary: it makes it easier to setup an admin, but if you need anything special that's not out of the box: you got a steep learning curve. Depending on your requirements you can choose to use django or not. Anything that requires a lot of functional speccing is better of implemented manually.",0.1016881243684853,False,2,649 +2010-07-01 06:52:22.183,Is Django admin difficult to customize?,"I have been playing for a couple of days with Django Admin to explore it, but I am still clueless of how it can be customized in the way we need. +Every time I look for any help for the customization in the admin panel, what I find is, a bunch of articles on various communities and forums, explaining how to customize the template, the lists items, the the column views etc. But that should not be called Django Customization. +If I need to make even a small change in the User functionality or any modification to the auth module. It takes a lots of efforts even in figuring out how that can be done. +Is Django that difficult to customize or its just lack of the help available over internet for this or its me who is moving in the wrong direction ?","Personally, if you want a site to look like the admin, why not pull the templates and styles and use them, build your own views for what you need. Gobs of documentation and forum help is there for that. I like the idea of customizing the admin, but honestly, I have been doing it for awhile on a project and time and time again I think to myself, if this was built in the standard MVC (or MTV) manner with free templates online, copied admin ones, or some professionally made ones, and built with the plethora of addons and my code, it would be much easier!!! And, when you decide that request/response isn't cutting it, and you want to add lots of JavaScript, you'll be glad. I know. I have had to put all sorts of JavaScript on our Admin project. Mostly because it's impossible to make the admin do what we want, so we fix it with JavaScript once it is on screen. When you find yourself writing an Ajax based system, you'll wonder why you have the admin at all. +If I could start this project over, I might not even use Django, but I probably would. I most certainly won't used the Admin. +Now, if you are building an basic CRUD type site that doesn't have style-eyed users, then Django with grappelli, and some elbow grease will get the job done. Remember, Django is a collection of Python scripts. Just override everything you can, and you'll get there, if you aren't too ambitious.",0.296905446847765,False,2,649 2010-07-01 12:45:13.863,Logging activity on Django's admin - Django,"I need to track/log activity on the Django admin. I know there are messages stored by admin somewhere, but I don't know how to access them in order to use them as a simple log. @@ -8113,9 +8113,9 @@ go back to eggs and to run. You should stop at break points in each file. (It works, I just tested it.)",1.2,True,1,679 2010-07-22 14:05:33.280,how to get final redirected url,"i am using google app engine for fetching the feed url bur few of the urls are 301 redirect i want to get the final url which returns me the result -i am usign the universal feed reader for parsing the url is there any way or any function which can give me the final url.","It is not possible to get the 'final' URL by parsing, in order to resolve it, you would need to at least perform an HTTP HEAD operation",0.3869120172231254,False,2,680 -2010-07-22 14:05:33.280,how to get final redirected url,"i am using google app engine for fetching the feed url bur few of the urls are 301 redirect i want to get the final url which returns me the result i am usign the universal feed reader for parsing the url is there any way or any function which can give me the final url.","You can do this by handling redirects manually. When calling fetch, pass in follow_redirects=False. If your response object's HTTP status is a redirect code, either 301 or 302, grab the Location response header and fetch again until the HTTP status is something else. Add a sanity check (perhaps 5 redirects max) to avoid redirect loops.",0.0,False,2,680 +2010-07-22 14:05:33.280,how to get final redirected url,"i am using google app engine for fetching the feed url bur few of the urls are 301 redirect i want to get the final url which returns me the result +i am usign the universal feed reader for parsing the url is there any way or any function which can give me the final url.","It is not possible to get the 'final' URL by parsing, in order to resolve it, you would need to at least perform an HTTP HEAD operation",0.3869120172231254,False,2,680 2010-07-22 18:13:57.290,django URL reverse: When URL reversig a username it fails when username has a '.' literal in it,"I didn't expect this to occur [since I didn't know when django changed to allow _ and . in usernames], but when I attempt {% url feed_user entry.username %} I will get a 500 error when the username contains a '.' @@ -8158,13 +8158,13 @@ I have Visual Studio 2008 installed as a compiler, I read that that is the only I have a Python web-application. Which 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? UPDATE: -Note, I'm not using a Python framework such as Django or Pylons.","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. -As 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.",0.2655860252697744,False,2,689 +Note, I'm not using a Python framework such as Django or Pylons.","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.",-0.0679224682270276,False,2,689 2010-07-26 16:21:34.060,Python/Web: What's the best way to run Python on a web server?,"I am leasing a dedicated web server. I have a Python web-application. Which 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? UPDATE: -Note, I'm not using a Python framework such as Django or Pylons.","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.",-0.0679224682270276,False,2,689 +Note, I'm not using a Python framework such as Django or Pylons.","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. +As 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.",0.2655860252697744,False,2,689 2010-07-26 21:50:43.673,Dynamically update wxPython staticText,"i was wondering how to update a StaticText dynamically in wxpython? I have a script that goes every five minutes and reads a status from a webpage, then prints using wxpython the status in a static input. How would i dynamically, every 5 minutes update the statictext to reflect the status? @@ -8189,12 +8189,12 @@ How did you measure your 700ms? Run a packet capture of a query and analyse the results. It should be possible to infer roughly round-trip-time, bandwidth constraints, whether it's the application layer of the server or even the name resolution of your client machine.",0.0,False,1,692 2010-07-27 12:54:16.533,Starting a GUI process from a Python Windows Service,"I am creating Windows service class in Python that will eventually display a Window when certain conditions are met. Since (as I understand it) services cannot have GUIs, I'm trying to start up a GUI in a seperate process (using subprocess.Popen) when the conditions are right. This isn't working, presumably because the child process has the same privileges as the service. So how do I start a process from a Python Windows Service that has the ability to display GUIs on the screen?",If you give your Service the Allow service to interact with desktop permission it will be able to create windows without the need to launch a subprocess.,1.2,True,1,693 +2010-07-27 16:32:21.153,Getting number of elements in an iterator in Python,"Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?","Regarding your original question, the answer is still that there is no way in general to know the length of an iterator in Python. +Given that you question is motivated by an application of the pysam library, I can give a more specific answer: I'm a contributer to PySAM and the definitive answer is that SAM/BAM files do not provide an exact count of aligned reads. Nor is this information easily available from a BAM index file. The best one can do is to estimate the approximate number of alignments by using the location of the file pointer after reading a number of alignments and extrapolating based on the total size of the file. This is enough to implement a progress bar, but not a method of counting alignments in constant time.",0.1701860115155538,False,5,694 2010-07-27 16:32:21.153,Getting number of elements in an iterator in Python,"Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?","This is against the very definition of an iterator, which is a pointer to an object, plus information about how to get to the next object. An iterator does not know how many more times it will be able to iterate until terminating. This could be infinite, so infinity might be your answer.",0.0,False,5,694 2010-07-27 16:32:21.153,Getting number of elements in an iterator in Python,"Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?","It's common practice to put this type of information in the file header, and for pysam to give you access to this. I don't know the format, but have you checked the API? As others have said, you can't know the length from the iterator.",0.0,False,5,694 -2010-07-27 16:32:21.153,Getting number of elements in an iterator in Python,"Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?","Regarding your original question, the answer is still that there is no way in general to know the length of an iterator in Python. -Given that you question is motivated by an application of the pysam library, I can give a more specific answer: I'm a contributer to PySAM and the definitive answer is that SAM/BAM files do not provide an exact count of aligned reads. Nor is this information easily available from a BAM index file. The best one can do is to estimate the approximate number of alignments by using the location of the file pointer after reading a number of alignments and extrapolating based on the total size of the file. This is enough to implement a progress bar, but not a method of counting alignments in constant time.",0.1701860115155538,False,5,694 2010-07-27 16:32:21.153,Getting number of elements in an iterator in Python,"Is there an efficient way to know how many elements are in an iterator in Python, in general, without iterating through each and counting?","There are two ways to get the length of ""something"" on a computer. The first way is to store a count - this requires anything that touches the file/data to modify it (or a class that only exposes interfaces -- but it boils down to the same thing). The other way is to iterate over it and count how big it is.",0.06435775498645,False,5,694 @@ -8234,11 +8234,11 @@ Is there any way to access websites that use Javascript by using urllib2 or some I'm also willing to learn Javascript, if that's what it takes.","I would actually suggest using Selenium. Its mainly designed for testing Web-Applications from a ""user perspective however it is basically a ""FireFox"" driver. I've actually used it for this purpose ... although I was scraping an dynamic AJAX webpage. As long as the Javascript form has a recognizable ""Anchor Text"" that Selenium can ""click"" everything should sort itself out. Hope that helps",0.3869120172231254,False,1,697 2010-07-29 13:47:31.353,E-mail traceback on errors in Bottle framework,"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?","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.",0.5457054096481145,False,1,698 -2010-07-30 00:37:59.267,Hide/Delete a StaticText in wxPython,I was wondering how to hide/delete a StaticText in wxPython?,"The widget's Hide/Show methods should work. If the widget is in a sizer, then you can use the sizer's Detach method to ""hide"" it but not destroy it. Otherwise, the sizer has a Remove method that will remove the widget and destroy it. And there's the widget's own Destroy method.",0.5916962662253621,False,3,699 +2010-07-30 00:37:59.267,Hide/Delete a StaticText in wxPython,I was wondering how to hide/delete a StaticText in wxPython?,Have you tried control.Hide() or control.Show(False)?,1.2,True,3,699 2010-07-30 00:37:59.267,Hide/Delete a StaticText in wxPython,I was wondering how to hide/delete a StaticText in wxPython?,"statictext.Show to show and statictext.Hide to hide",0.0,False,3,699 -2010-07-30 00:37:59.267,Hide/Delete a StaticText in wxPython,I was wondering how to hide/delete a StaticText in wxPython?,Have you tried control.Hide() or control.Show(False)?,1.2,True,3,699 +2010-07-30 00:37:59.267,Hide/Delete a StaticText in wxPython,I was wondering how to hide/delete a StaticText in wxPython?,"The widget's Hide/Show methods should work. If the widget is in a sizer, then you can use the sizer's Detach method to ""hide"" it but not destroy it. Otherwise, the sizer has a Remove method that will remove the widget and destroy it. And there's the widget's own Destroy method.",0.5916962662253621,False,3,699 2010-07-30 04:43:27.603,Zooming With Python Image Library,"I'm writing a simple application in Python which displays images.I need to implement Zoom In and Zoom Out by scaling the image. I think the Image.transform method will be able to do this, but I'm not sure how to use it, since it's asking for an affine matrix or something like that :P Here's the quote from the docs: @@ -8469,12 +8469,12 @@ How would I get easy_thumbnails to store the thumb it creates back on Amazon S3? Thanks!","easy_thumbnails will do S3-based image thumbnailing for you - you just need to set settings.THUMBNAIL_DEFAULT_STORAGE, so that easy_thumbnails knows which storage to use (in your case, you probably want to set it to the same storage you're using for your ImageFields).",0.999999917201249,False,1,714 2010-08-03 15:05:07.733,how can i verify all links on a page as a black-box tester,"I'm tryng to verify if all my page links are valid, and also something similar to me if all the pages have a specified link like contact. i use python unit testing and selenium IDE to record actions that need to be tested. So my question is can i verify the links in a loop or i need to try every link on my own? -i tried to do this with __iter__ but it didn't get any close ,there may be a reason that i'm poor at oop, but i still think that there must me another way of testing links than clicking them and recording one by one.","You could (as yet another alternative), use BeautifulSoup to parse the links on your page and try to retrieve them via urllib2.",0.0,False,2,715 -2010-08-03 15:05:07.733,how can i verify all links on a page as a black-box tester,"I'm tryng to verify if all my page links are valid, and also something similar to me if all the pages have a specified link like contact. i use python unit testing and selenium IDE to record actions that need to be tested. -So my question is can i verify the links in a loop or i need to try every link on my own? i tried to do this with __iter__ but it didn't get any close ,there may be a reason that i'm poor at oop, but i still think that there must me another way of testing links than clicking them and recording one by one.","What exactly is ""Testing links""? If it means they lead to non-4xx URIs, I'm afraid You must visit them. As for existence of given links (like ""Contact""), You may look for them using xpath.",0.0,False,2,715 +2010-08-03 15:05:07.733,how can i verify all links on a page as a black-box tester,"I'm tryng to verify if all my page links are valid, and also something similar to me if all the pages have a specified link like contact. i use python unit testing and selenium IDE to record actions that need to be tested. +So my question is can i verify the links in a loop or i need to try every link on my own? +i tried to do this with __iter__ but it didn't get any close ,there may be a reason that i'm poor at oop, but i still think that there must me another way of testing links than clicking them and recording one by one.","You could (as yet another alternative), use BeautifulSoup to parse the links on your page and try to retrieve them via urllib2.",0.0,False,2,715 2010-08-03 20:08:34.123,"Calling a python script from command line without typing ""python"" first","Question: In command line, how do I call a python script without having to type python in front of the script's name? Is this even possible? Info: @@ -8513,9 +8513,9 @@ all of the letters in well would be found in your dict of arbitrary letters so s however, the html page has a '&'. I can use cgi.escape to convert this into & but it also converts all my html <> tags into <> which makes parseString() unhappy. how do i go about this? i would rather not just hack it and straight replace the ""&""s thanks","You shouldn't use an XML parser to parse data that isn't XML. Find an HTML parser instead, you'll be happier in the long run. The standard library has a few (HTMLParser and htmllib), and BeautifulSoup is a well-loved third-party package.",0.0,False,1,718 +2010-08-04 19:41:55.633,How do you get Intellisense for Python in Eclipse/Aptana/Pydev?,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,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.,0.2655860252697744,False,3,719 2010-08-04 19:41:55.633,How do you get Intellisense for Python in Eclipse/Aptana/Pydev?,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,"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. Preferences --> PyDev --> Interpreter Python --> Libraries tab on the right.",0.0,False,3,719 -2010-08-04 19:41:55.633,How do you get Intellisense for Python in Eclipse/Aptana/Pydev?,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,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.,0.2655860252697744,False,3,719 2010-08-04 19:41:55.633,How do you get Intellisense for Python in Eclipse/Aptana/Pydev?,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,"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. And if you don't know their types, you can't do auto-complete on things like class members. Personally, 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. @@ -8532,12 +8532,28 @@ Lexo",manage.py imports settings.py from the current directory and pass settings I 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?","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.",0.0,False,2,721 2010-08-06 11:58:01.997,Comparing local file with remote file,"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? I 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?","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.",0.0,False,2,721 -2010-08-06 21:05:54.147,are there tutorials on how to name variables?,as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?,"It's not clear if your question relates to Python naming conventions. -If so, for starters I would try to follow just these simple rules: +2010-08-06 21:05:54.147,are there tutorials on how to name variables?,as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?,"Have you read Code Complete? He does a full treatise on this in the book. Definitely the best naming strategy I've seen in print... And it's easy to find like 1000 programmers at the drop of a hat who name this one of the top 5 resources for programmers and program design. +Just my $.05",0.0679224682270276,False,7,722 +2010-08-06 21:05:54.147,are there tutorials on how to name variables?,as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?,"There are many different views on the specifics of naming conventions, but the overall gist could be summed up as: -ClassName - upper case for class names -variable_name - lower case and underscore for variables (I try to keep them at two words maximum)",0.0340004944420038,False,7,722 -2010-08-06 21:05:54.147,are there tutorials on how to name variables?,as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?,"Can I make a shameless plug for the ""Names"" chapter in my book, ""A Sane Approach to Database Design"" ? I'm specifically talking about names for things in databases, but most of the same considerations apply to variables in programs.",0.0340004944420038,False,7,722 +Each variable name should be relevant + to whatever data is stored in the + variable. +Your naming scheme should be consistent. + +So a major no-no would be +single letter variables (some people +use i and j for indexing loops, which +is OK because every programmer knows +what they are. Nevertheless, I prefer +'idx' instead of 'i'). Also out are +names like 'method1', it means nothing +- it should indicate what the variable holds. +Another (less common) convention is the 'Hungarian' notation where the data type is prefixed to the variable name such as 'int i_idx'. This is quite useless in modern, object oriented programming languages. Not to mention a blatant violation of the DRY principle. +The second point, consistency, is just as important. camelCase, UpperCamelCase, whatever - just don't switch between them for no reason. +You'll find that naming conventions vary from language to language and often, a company will have their own rules on naming. +Its a worthwhile investment to properly name your variables because when you come to maintain your code much later on and you have forgotten what everything means, it will pay dividends.",0.1016881243684853,False,7,722 +2010-08-06 21:05:54.147,are there tutorials on how to name variables?,as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?,"I'd recommend purchasing a copy of ""Clean Code"" by Robert C. Martin. It is full of great suggstions ranging from naming conventions to how to write easy-to-understand functions and much more. Definitely worth a read. I know it influenced my coding style since reading it.",0.1016881243684853,False,7,722 2010-08-06 21:05:54.147,are there tutorials on how to name variables?,as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?,"All the answers here are quite valid. Most important: be consistent. That said, here are my rules (C#): @@ -8567,6 +8583,12 @@ type doesn't: it tells me adding rowItemsPerPage and colSelected is a meaningless operation, even though it compiles just fine.",1.2,True,7,722 +2010-08-06 21:05:54.147,are there tutorials on how to name variables?,as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?,"It's not clear if your question relates to Python naming conventions. +If so, for starters I would try to follow just these simple rules: + +ClassName - upper case for class names +variable_name - lower case and underscore for variables (I try to keep them at two words maximum)",0.0340004944420038,False,7,722 +2010-08-06 21:05:54.147,are there tutorials on how to name variables?,as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?,"Can I make a shameless plug for the ""Names"" chapter in my book, ""A Sane Approach to Database Design"" ? I'm specifically talking about names for things in databases, but most of the same considerations apply to variables in programs.",0.0340004944420038,False,7,722 2010-08-06 21:05:54.147,are there tutorials on how to name variables?,as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?,"A bad convention followed fully is better than a combination of different good ""conventions"" (which aren't conventions at all any more, if they aren't kept to). However, a convention that is making something less clear than if it had been ignored, should be ignored. @@ -8578,28 +8600,6 @@ Similarly, if you aren't sure how to spell a word that you are using as the whol Hungarian is bad (in many modern languages, though in some it has its place) but the principle is good. If you can tell a const, static, instance, local and parameter variable from each other in a split-second, that's good. If you can tell something of the intent immediately, that's good too. Related to that, _ before public variables makes them non CLR compiant. That's actually a good thing for private variables (if you make them public for a quick experiment, and forget to fix the visibility, the compiler will warn you). Remember Postel's Law, ""be conservative in what you do, be liberal in what you accept from others"". One example of this is to act as if you are using a case-sensitive langauge, even if you're using a case-insensitive one. A related one is to be more of a stickler in public names than private ones. Yet another is to pay more attention to following conventions well than to complaining about those who don't.",0.1684471436049839,False,7,722 -2010-08-06 21:05:54.147,are there tutorials on how to name variables?,as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?,"Have you read Code Complete? He does a full treatise on this in the book. Definitely the best naming strategy I've seen in print... And it's easy to find like 1000 programmers at the drop of a hat who name this one of the top 5 resources for programmers and program design. -Just my $.05",0.0679224682270276,False,7,722 -2010-08-06 21:05:54.147,are there tutorials on how to name variables?,as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?,"I'd recommend purchasing a copy of ""Clean Code"" by Robert C. Martin. It is full of great suggstions ranging from naming conventions to how to write easy-to-understand functions and much more. Definitely worth a read. I know it influenced my coding style since reading it.",0.1016881243684853,False,7,722 -2010-08-06 21:05:54.147,are there tutorials on how to name variables?,as you can probably tell from my previous posts i have horrific naming conventions. do you know of any tutorials dealing with how to name stuff?,"There are many different views on the specifics of naming conventions, but the overall gist could be summed up as: - -Each variable name should be relevant - to whatever data is stored in the - variable. -Your naming scheme should be consistent. - -So a major no-no would be -single letter variables (some people -use i and j for indexing loops, which -is OK because every programmer knows -what they are. Nevertheless, I prefer -'idx' instead of 'i'). Also out are -names like 'method1', it means nothing -- it should indicate what the variable holds. -Another (less common) convention is the 'Hungarian' notation where the data type is prefixed to the variable name such as 'int i_idx'. This is quite useless in modern, object oriented programming languages. Not to mention a blatant violation of the DRY principle. -The second point, consistency, is just as important. camelCase, UpperCamelCase, whatever - just don't switch between them for no reason. -You'll find that naming conventions vary from language to language and often, a company will have their own rules on naming. -Its a worthwhile investment to properly name your variables because when you come to maintain your code much later on and you have forgotten what everything means, it will pay dividends.",0.1016881243684853,False,7,722 2010-08-07 09:23:49.240,How to organize Eclipse - Workspace VS Programming languages,"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. Of 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? e.g.: @@ -8609,10 +8609,10 @@ I choose /workspace/android/, so then only Android tools and buttons in toolbars Do I have to manually remove all unneccessary things from each of the workspace? Or it is either possible to remove all?","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. Another 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.",1.2,True,1,723 +2010-08-08 08:09:32.740,Python Time Delays,"I want to know how to call a function after a certain time. I have tried time.sleep() but this halts the whole script. I want the script to carry on, but after ???secs call a function and run the other script at the same time","If the non-block feature is not needed, just use time.sleep(5) which will work anywhere and save your life.",0.2012947653214861,False,2,724 2010-08-08 08:09:32.740,Python Time Delays,"I want to know how to call a function after a certain time. I have tried time.sleep() but this halts the whole script. I want the script to carry on, but after ???secs call a function and run the other script at the same time","If you want a function to be called after a while and not to stop your script you are inherently dealing with threaded code. If you want to set a function to be called and not to worry about it, you have to either explicitly use multi-threading - like em Mark Byers's answr, or use a coding framework that has a main loop which takes care of function dispatching for you - like twisted, qt, gtk, pyglet, and so many others. Any of these would require you to rewrite your code so that it works from that framework's main loop. It is either that, or writing some main loop from event checking yourself on your code - All in all, if the only thing you want is single function calls, threading.Timer is the way to do it. If you want to use these timed calls to actually loop the program as is usually done with javascript's setTimeout, you are better of selecting one of the coding frameworks I listed above and refactoring your code to take advantage of it.",0.4701041941942874,False,2,724 -2010-08-08 08:09:32.740,Python Time Delays,"I want to know how to call a function after a certain time. I have tried time.sleep() but this halts the whole script. I want the script to carry on, but after ???secs call a function and run the other script at the same time","If the non-block feature is not needed, just use time.sleep(5) which will work anywhere and save your life.",0.2012947653214861,False,2,724 2010-08-10 03:43:31.660,Key commands in Tkinter,"I made a GUI with Tkinter, now how do I make it so when a key command will execute a command even if the Tkinter window is not in focus? Basically I want it so everything is bound to that key command. Example: Say I was browsing the internet and the focus was on my browser, I then type Ctrl + U. An event would then run on my program.","Tkinter, on its own, cannot grab keystrokes that (from the OS's/WM's viewpoint) were directed to other, unrelated windows -- you'll need to instruct your window manager, desktop manager, or ""operating system"", to direct certain keystrokes differently than it usually does. So, what platform do you need to support for this functionality? Each platform has different ways to perform this kind of functionality, of course.",0.6730655149877884,False,1,725 @@ -8678,10 +8678,10 @@ In Python (Pseudocode): if file.endswith(""ext""): move file to destination In this case, what should I do?",The quoting issues alone suggest that a pure Python solution is preferable.,0.0582430451621389,False,3,731 -2010-08-14 14:11:58.803,How to make a event run immediately after a GUI program starts in wxpython?,"I'm working on a GUI program in which I already bind a start button with one event, and when I click the start button, the event runs as I like. My question is, if I want my program to start the event immediately after the GUI program starts, which means the start button is immediately being ""clicked"" once the program starts, how do I do it?",In the main frame constructor set a one-shot timer with interval 0 that fires the event.,1.2,True,2,732 2010-08-14 14:11:58.803,How to make a event run immediately after a GUI program starts in wxpython?,"I'm working on a GUI program in which I already bind a start button with one event, and when I click the start button, the event runs as I like. My question is, if I want my program to start the event immediately after the GUI program starts, which means the start button is immediately being ""clicked"" once the program starts, how do I do it?","In the __init__( ) for your main frame put this: wx.CallAfter( func_name )",0.0,False,2,732 +2010-08-14 14:11:58.803,How to make a event run immediately after a GUI program starts in wxpython?,"I'm working on a GUI program in which I already bind a start button with one event, and when I click the start button, the event runs as I like. My question is, if I want my program to start the event immediately after the GUI program starts, which means the start button is immediately being ""clicked"" once the program starts, how do I do it?",In the main frame constructor set a one-shot timer with interval 0 that fires the event.,1.2,True,2,732 2010-08-15 05:54:51.633,Output first 100 characters in a string,"Can seem to find a substring function in python. Say I want to output the first 100 characters in a string, how can I do this? I want to do it safely also, meaning if the string is 50 characters it shouldn't fail.","Most of previous examples will raise an exception in case your string is not long enough. @@ -8696,9 +8696,7 @@ Does each cluster point to the correct children? Does each cluster point to the correct parent? I 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. -Actually my main problem here is to find a way to specify the expected output in a readable and understandable way. Any suggestions?","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. -This 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. -As 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.",1.2,True,2,734 +Actually my main problem here is to find a way to specify the expected output in a readable and understandable way. Any suggestions?","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.",0.0,False,2,734 2010-08-15 13:16:02.713,Writing unittests for a function that returns a hierarchy of objects,"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: Does each cluster contain the correct elements (and maybe other properties as well)? @@ -8706,7 +8704,9 @@ Does each cluster point to the correct children? Does each cluster point to the correct parent? I 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. -Actually my main problem here is to find a way to specify the expected output in a readable and understandable way. Any suggestions?","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.",0.0,False,2,734 +Actually my main problem here is to find a way to specify the expected output in a readable and understandable way. Any suggestions?","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. +This 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. +As 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.",1.2,True,2,734 2010-08-15 20:47:55.287,How can I get a human-readable timezone name in Python?,"In a Python project I'm working on, I'd like to be able to get a ""human-readable"" timezone name of the form America/New_York, corresponding to the system local timezone, to display to the user. Every piece of code I've seen that accesses timezone information only returns either a numeric offset (-0400) or a letter code (EDT) or sometimes both. Is there some Python library that can access this information, or if not that, convert the offset/letter code into a human-readable name? If there's more than one human-readable name corresponding to a particular timezone, either a list of the possible results or any one of them is fine, and if there is no human-readable name corresponding to the current time zone, I'll take either an exception or None or [] or whatever. @@ -8734,12 +8734,12 @@ Thanks","First you have to draw the image. You can do this my making a QLabel wi You can get mouse clicks by subclassing the QImage and intercepting mousePressEvent. Look up the pixel value with QImage.pixel().",0.2655860252697744,False,1,741 2010-08-17 22:22:10.787,Recommended language for multithreaded data work,"Right now, I use a combination of Python and R for all of my data processing needs. However, some of my datasets are incredibly large and would benefit strongly from multithreaded processing. For example, if there are two steps that each have to performed on a set of several millions of data points, I would like to be able to start the second step while the first step is still being run, using the part of the data that has already been processed through the first step. -From my understanding, neither Python nor R is the ideal language for this type of work (at least, I don't know how to implement it in either language). What would be the best language/implementation for this type of data processing?","If I remember correctly (but I might be wrong here) one of the main purposes of Ada95 was parallel processing. Funny language, that was. -Jokes aside I'm not quite sure how good performance wise it would be (but seeing you are using Python now then it shouldn't be that bad) but I'd suggest Java since the basics of multithreading are quite simple there (but making a well written, complex multithreaded application is rather hard). Heard the Concurrency library is also quite nice, I haven't tried it out myself yet, though.",0.0,False,2,742 -2010-08-17 22:22:10.787,Recommended language for multithreaded data work,"Right now, I use a combination of Python and R for all of my data processing needs. However, some of my datasets are incredibly large and would benefit strongly from multithreaded processing. -For example, if there are two steps that each have to performed on a set of several millions of data points, I would like to be able to start the second step while the first step is still being run, using the part of the data that has already been processed through the first step. From my understanding, neither Python nor R is the ideal language for this type of work (at least, I don't know how to implement it in either language). What would be the best language/implementation for this type of data processing?","On the Python side, your best bet is probably to separate the two steps in two different processes. There are a couple of modules that help you to achieve that. You would couple the two processes through pipes. In order to pass arbitrary data through the pipe, you need to serialize and deserialize it. The pickle module would be a good candidate for this. If you want to jump ship, languages like Erlang, Haskell, Scala or Clojure have probably the concurrency features you are looking for, but I don't know how well they would integrate with R or some other statistical package that suits you.",0.0679224682270276,False,2,742 +2010-08-17 22:22:10.787,Recommended language for multithreaded data work,"Right now, I use a combination of Python and R for all of my data processing needs. However, some of my datasets are incredibly large and would benefit strongly from multithreaded processing. +For example, if there are two steps that each have to performed on a set of several millions of data points, I would like to be able to start the second step while the first step is still being run, using the part of the data that has already been processed through the first step. +From my understanding, neither Python nor R is the ideal language for this type of work (at least, I don't know how to implement it in either language). What would be the best language/implementation for this type of data processing?","If I remember correctly (but I might be wrong here) one of the main purposes of Ada95 was parallel processing. Funny language, that was. +Jokes aside I'm not quite sure how good performance wise it would be (but seeing you are using Python now then it shouldn't be that bad) but I'd suggest Java since the basics of multithreading are quite simple there (but making a well written, complex multithreaded application is rather hard). Heard the Concurrency library is also quite nice, I haven't tried it out myself yet, though.",0.0,False,2,742 2010-08-17 23:20:13.877,Sending integer values to Arduino from PySerial,I need to send integers greater than 255? Does anyone know how to do this?,"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;-).",0.3869120172231254,False,1,743 2010-08-18 20:49:49.700,"Coming from C, how should I learn Python?","I've got a good grasp on C, my first programming language. I know a reasonable number of tricks and techniques and have written quite a few programs, mostly for scientific stuff. Now I'd like to branch out and understand OOP, and Python seems like a good direction to go. I've seen several questions on how to learn Python, but most of them were from folks who were looking to start programming for the first time. I don't need a tutorial that will tell me what a string is, but I do need one that can tell me how to make a string in Python. Any help on some good sources to look through? Bonus points if the source is free :)","I knew C before I knew Python. No offence intended, but I don't think that your C knowledge is that big a deal. Unless you read very, very slowly, just set out to learn Python. It won't take that long to skim through the material you're familiar with, and it's not as if a Python tutorial aimed at C programmers will make you a better Python programmer - it might teach you things in a different order, is all, and raise some specific things that you would do in C but that you should not do in Python. @@ -8804,11 +8804,11 @@ I am using gettext for the localization. Thank you, Tomas","You should be able to create a *.pot file from a *.glade file using intltool-extract --type=gettext/glade foo.glade, and intltool supposedly knows what is translatable. Also, I suggest you look into GtkBuilder if you didn't do that already (you can save GtkBuilder interface files from recent Glade 3 versions, and you won't need the extra libglade anymore).",1.2,True,1,754 2010-08-29 12:04:07.393,Keeping multiple clients showing up-to-date information in Python?,"I am new to network programming but old to Python. I have a simple blotter program that is to be used on multiple client computers. The blotter works two ways, it can show and update the information in the database. To avoid any blotters showing old data, how can I make all blotters re-fetch information from the database as soon as another blotter has updated some data in the database? -I would rather like to avoid complexity in setting up some client-server protocol. Is it possible to create some form of client-only protocol where a simple refresh message is passed along straight to the other blotters when they need to update their information?","You could use triggers. When an information is updated send a signal (is up to you choose how, maybe just an udp packet) to all blotters that will update their information consequentially. Postgresql could be scripted using python.",0.0,False,2,755 -2010-08-29 12:04:07.393,Keeping multiple clients showing up-to-date information in Python?,"I am new to network programming but old to Python. I have a simple blotter program that is to be used on multiple client computers. The blotter works two ways, it can show and update the information in the database. To avoid any blotters showing old data, how can I make all blotters re-fetch information from the database as soon as another blotter has updated some data in the database? I would rather like to avoid complexity in setting up some client-server protocol. Is it possible to create some form of client-only protocol where a simple refresh message is passed along straight to the other blotters when they need to update their information?","To receive messages (e.g. the UDP package suggested by the other poster or an http request), the clients would have to run a basic server on the client machine. You could use the Python xmlrpc module for example. However, a local firewall may block the inward communication. The easiest solution, if the number of clients is moderate, will be to frequently poll the database for changes: add a column ""last modification time"" to your drawing table and have the clients check this field. This way the clients can find out whether they need to reload the drawing without wasting too many resources. Edit: The last modification field could either be actively updated by the client that made a change to the drawing, or automatically updated by a database trigger.",1.2,True,2,755 +2010-08-29 12:04:07.393,Keeping multiple clients showing up-to-date information in Python?,"I am new to network programming but old to Python. I have a simple blotter program that is to be used on multiple client computers. The blotter works two ways, it can show and update the information in the database. To avoid any blotters showing old data, how can I make all blotters re-fetch information from the database as soon as another blotter has updated some data in the database? +I would rather like to avoid complexity in setting up some client-server protocol. Is it possible to create some form of client-only protocol where a simple refresh message is passed along straight to the other blotters when they need to update their information?","You could use triggers. When an information is updated send a signal (is up to you choose how, maybe just an udp packet) to all blotters that will update their information consequentially. Postgresql could be scripted using python.",0.0,False,2,755 2010-08-30 21:28:08.487,Python PyGTK. What's this component?,"I'm trying to write a simple GTD-style todo list app with python and gtk to learn python. I want a container that can select an individual list from a lot of choices. It would be something like the list of notebooks area in tomboy. Not a combobox. As you can probably tell I'm a beginner and the terminology is probably off. Can you please tell me what it is I'm looking for and an overview of how to implement it?","You mean a widget to filter a large collection into multiple subsets / views? @@ -8823,6 +8823,12 @@ C:\""Python2.5.2""\python.exe setup.py install",0.0,False,1,757 2010-08-31 07:46:53.923,Module vs object-oriented programming in vba,"My first ""serious"" language was Java, so I have comprehended object-oriented programming in sense that elemental brick of program is a class. Now I write on VBA and Python. There are module languages and I am feeling persistent discomfort: I don't know how should I decompose program in a modules/classes. I understand that one module corresponds to one knowledge domain, one module should ba able to test separately... +Should I apprehend module as namespace(c++) only?","VBA also allows the use of classes. Unfortunately, those classes don't support all the features of a full-fleged object oriented language. Especially inheritance is not supported. +But you can work with interfaces, at least up to a certain degree. +I only used modules like ""one module = one singleton"". My modules contain ""static"" or even stateless methods. So in my opinion a VBa module is not namespace. More often a bunch of classes and modules would form a ""namespace"". I often create a new project (DLL, DVB or something similar) for such a ""namespace"".",0.1016881243684853,False,4,758 +2010-08-31 07:46:53.923,Module vs object-oriented programming in vba,"My first ""serious"" language was Java, so I have comprehended object-oriented programming in sense that elemental brick of program is a class. +Now I write on VBA and Python. There are module languages and I am feeling persistent discomfort: I don't know how should I decompose program in a modules/classes. +I understand that one module corresponds to one knowledge domain, one module should ba able to test separately... Should I apprehend module as namespace(c++) only?","Idioms of languages are different and thats the reason a problem solved in different languages take different approaches. ""C"" is all about procedural decomposition. @@ -8835,12 +8841,6 @@ If you are comfortable with OO, you should be able to use it very well in Python 2010-08-31 07:46:53.923,Module vs object-oriented programming in vba,"My first ""serious"" language was Java, so I have comprehended object-oriented programming in sense that elemental brick of program is a class. Now I write on VBA and Python. There are module languages and I am feeling persistent discomfort: I don't know how should I decompose program in a modules/classes. I understand that one module corresponds to one knowledge domain, one module should ba able to test separately... -Should I apprehend module as namespace(c++) only?","VBA also allows the use of classes. Unfortunately, those classes don't support all the features of a full-fleged object oriented language. Especially inheritance is not supported. -But you can work with interfaces, at least up to a certain degree. -I only used modules like ""one module = one singleton"". My modules contain ""static"" or even stateless methods. So in my opinion a VBa module is not namespace. More often a bunch of classes and modules would form a ""namespace"". I often create a new project (DLL, DVB or something similar) for such a ""namespace"".",0.1016881243684853,False,4,758 -2010-08-31 07:46:53.923,Module vs object-oriented programming in vba,"My first ""serious"" language was Java, so I have comprehended object-oriented programming in sense that elemental brick of program is a class. -Now I write on VBA and Python. There are module languages and I am feeling persistent discomfort: I don't know how should I decompose program in a modules/classes. -I understand that one module corresponds to one knowledge domain, one module should ba able to test separately... Should I apprehend module as namespace(c++) only?","I don't do VBA but in python, modules are fundamental. As you say, the can be viewed as namespaces but they are also objects in their own right. They are not classes however, so you cannot inherit from them (at least not directly). I find that it's a good rule to keep a module concerned with one domain area. The rule that I use for deciding if something is a module level function or a class method is to ask myself if it could meaningfully be used on any objects that satisfy the 'interface' that it's arguments take. If so, then I free it from a class hierarchy and make it a module level function. If its usefulness truly is restricted to a particular class hierarchy, then I make it a method. If you need it work on all instances of a class hierarchy and you make it a module level function, just remember that all the the subclasses still need to implement the given interface with the given semantics. This is one of the tradeoffs of stepping away from methods: you can no longer make a slight modification and call super. On the other hand, if subclasses are likely to redefine the interface and its semantics, then maybe that particular class hierarchy isn't a very good abstraction and should be rethought.",1.2,True,4,758 @@ -8850,10 +8850,22 @@ I understand that one module corresponds to one knowledge domain, one module sho Should I apprehend module as namespace(c++) only?","It is matter of taste. If you use modules your 'program' will be more procedural oriented. If you choose classes it will be more or less object oriented. I'm working with Excel for couple of months and personally I choose classes whenever I can because it is more comfortable to me. If you stop thinking about objects and think of them as Components you can use them with elegance. The main reason why I prefer classes is that you can have it more that one. You can't have two instances of module. It allows me use encapsulation and better code reuse. For example let's assume that you like to have some kind of logger, to log actions that were done by your program during execution. You can write a module for that. It can have for example a global variable indicating on which particular sheet logging will be done. But consider the following hypothetical situation: your client wants you to include some fancy report generation functionality in your program. You are smart so you figure out that you can use your logging code to prepare them. But you can't do log and report simultaneously by one module. And you can with two instances of logging Component without any changes in their code.",0.296905446847765,False,4,758 2010-08-31 17:59:58.667,how do I return all memcached values in Google App Engine?,"I want to use all the data in my python app engine memcache. I do not know the keys in advance. +How do I go about getting all data?","I am using a 'well known key' called ""config"" where I store a list of all other keys and use that to enumerate the rest of the items.",0.1352210990936997,False,2,759 +2010-08-31 17:59:58.667,how do I return all memcached values in Google App Engine?,"I want to use all the data in my python app engine memcache. I do not know the keys in advance. How do I go about getting all data?","as in comments above, I guess I could stick all data in a single memcache entry with a known key. Still for non-static data there are scenarios where it would be useful.",0.0,False,2,759 -2010-08-31 17:59:58.667,how do I return all memcached values in Google App Engine?,"I want to use all the data in my python app engine memcache. I do not know the keys in advance. -How do I go about getting all data?","I am using a 'well known key' called ""config"" where I store a list of all other keys and use that to enumerate the rest of the items.",0.1352210990936997,False,2,759 +2010-08-31 19:18:39.657,Clyther-how to get started?,"I don't get what Clyther is or how to use it. +My stuff: + ATI OpenCl SDK (just dl'd) + clyther beta (just dl'd) + windows 7 pro 64 bit + active python 3.1.2 + Xfxs Ati radeon 5850 video card +I downloaded the ATI OpenCl SDK and the clyther beta from sourceforge. Then I tooke the sample 'reduce' function from the sourceforge documents and pasted the code into notepad and named it clythersample.py. When I double-click the file or open it in the interactiveshell, it gives an error message on the first line. +Is naming the file .py wrong? I guess clyther is its own lqnguage and not really python? Can I write python code and in the middle of the program, write a chunk of clyther code? Will python IDEs (esp. Wing understand and debug it?) Will it work with python 3 or do I need 2.6? Is 64 bit os ok? +(I'm not a programme or technically competent, so things like its a python API for OpenCl or it had C bindings for python don't mean a whole lot).","Clyther is a Python package for High-Performance Computing (HPC) using, for example, video cards with multiple Graphics Packaging Units (GPUs) or (less frequently) multi-core processors. Clyther is for parallel processing of algorithms or data sets that would normally take a lot of time to process serially. Meaning, if you have a problem that can be split into many smaller problems, then Clyther is a useful package to use. Additionally, your problem must be something that can use numpy arrays. +Clyther is a nice package to use if you have the problem it is intended to solve. It makes it fairly easy to write Python code to run on multiple processes. +If that's not the problem you need to solve, then Clyther probably won't help you.",0.3869120172231254,False,2,760 2010-08-31 19:18:39.657,Clyther-how to get started?,"I don't get what Clyther is or how to use it. My stuff: ATI OpenCl SDK (just dl'd) @@ -8877,18 +8889,6 @@ Will python IDEs (esp. Wing understand and debug it?) Not natively, I suppose. Side note: The project is in a very early stage of developement (very first beta-release), so don't expect things to run smoothly right now.",0.2012947653214861,False,2,760 -2010-08-31 19:18:39.657,Clyther-how to get started?,"I don't get what Clyther is or how to use it. -My stuff: - ATI OpenCl SDK (just dl'd) - clyther beta (just dl'd) - windows 7 pro 64 bit - active python 3.1.2 - Xfxs Ati radeon 5850 video card -I downloaded the ATI OpenCl SDK and the clyther beta from sourceforge. Then I tooke the sample 'reduce' function from the sourceforge documents and pasted the code into notepad and named it clythersample.py. When I double-click the file or open it in the interactiveshell, it gives an error message on the first line. -Is naming the file .py wrong? I guess clyther is its own lqnguage and not really python? Can I write python code and in the middle of the program, write a chunk of clyther code? Will python IDEs (esp. Wing understand and debug it?) Will it work with python 3 or do I need 2.6? Is 64 bit os ok? -(I'm not a programme or technically competent, so things like its a python API for OpenCl or it had C bindings for python don't mean a whole lot).","Clyther is a Python package for High-Performance Computing (HPC) using, for example, video cards with multiple Graphics Packaging Units (GPUs) or (less frequently) multi-core processors. Clyther is for parallel processing of algorithms or data sets that would normally take a lot of time to process serially. Meaning, if you have a problem that can be split into many smaller problems, then Clyther is a useful package to use. Additionally, your problem must be something that can use numpy arrays. -Clyther is a nice package to use if you have the problem it is intended to solve. It makes it fairly easy to write Python code to run on multiple processes. -If that's not the problem you need to solve, then Clyther probably won't help you.",0.3869120172231254,False,2,760 2010-09-01 02:17:21.410,Python: open a file *with* script?,"I have a python script bundled into a application (I'm on a mac) and have the application set to be able to open .zip files. But when I say ""open foo.zip with bar.py"" how do I access the file that I have passed to it? Additional info: Using tkinter. @@ -8916,6 +8916,17 @@ I have only 3 months. I want to do it in Python. I can put in say 20-30 hours every week into it. +I want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations? +Is there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS) +If the idea is not feasible, can anyone tell me how much do I need to scale down my idea? +Any help is much appreciated!","You could probably code a small embedded-system OS in the timeframe you indicate, using concepts that are over a decade old. Many newer operating systems require many more complicated scheduling and memory-management heuristics than would be typical in a small embedded OS; designing an entire modern OS would not be a practical single-person project, but one might be able to do something interesting with some subsystem of it. I personally think there's some room for improvement in flash file systems, but I don't know what your prof would think. What is your prof really looking for?",0.0370887312438237,False,7,767 +2010-09-04 18:35:42.723,Operating System from scratch,"I have been asked to choose a project for my Operating System course at my university. I was bubbled with the idea of making an Operating System from scratch in Python. +I have a few limitations: + +I have only 3 months. +I want to do it in Python. +I can put in say 20-30 hours every week into it. + I want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations? Is there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS) If the idea is not feasible, can anyone tell me how much do I need to scale down my idea? @@ -8982,7 +8993,7 @@ I can put in say 20-30 hours every week into it. I want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations? Is there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS) If the idea is not feasible, can anyone tell me how much do I need to scale down my idea? -Any help is much appreciated!","You could probably code a small embedded-system OS in the timeframe you indicate, using concepts that are over a decade old. Many newer operating systems require many more complicated scheduling and memory-management heuristics than would be typical in a small embedded OS; designing an entire modern OS would not be a practical single-person project, but one might be able to do something interesting with some subsystem of it. I personally think there's some room for improvement in flash file systems, but I don't know what your prof would think. What is your prof really looking for?",0.0370887312438237,False,7,767 +Any help is much appreciated!","Developing an operating system in Python is possible. However, you might want to choose C or Assembly because there's an huge code base developed in those languages.",0.0,False,7,767 2010-09-04 18:35:42.723,Operating System from scratch,"I have been asked to choose a project for my Operating System course at my university. I was bubbled with the idea of making an Operating System from scratch in Python. I have a few limitations: @@ -9002,6 +9013,19 @@ I have only 3 months. I want to do it in Python. I can put in say 20-30 hours every week into it. +I want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations? +Is there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS) +If the idea is not feasible, can anyone tell me how much do I need to scale down my idea? +Any help is much appreciated!","Scale this down a lot. I would recommend looking at one very small piece of an operating system that you would want to do, perhaps parallel processing. There is no feasible way you will be able to write an entire operating system in under 500 hours, let only 5000 hours. The real question is is this for an undergraduate course or a graduate course? The answer to that will greatly reflect what is needed to pass. +Adding +Grab a book on a topic about the operating system that interests you and focus intently on that for 3 months and you may just produce something that is good. Operating systems may seem like they don't do much on the outside, but think of it this way Windows has ~50 million lines of code.",0.5325457524925297,False,7,767 +2010-09-04 18:35:42.723,Operating System from scratch,"I have been asked to choose a project for my Operating System course at my university. I was bubbled with the idea of making an Operating System from scratch in Python. +I have a few limitations: + +I have only 3 months. +I want to do it in Python. +I can put in say 20-30 hours every week into it. + I want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations? Is there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS) If the idea is not feasible, can anyone tell me how much do I need to scale down my idea? @@ -9051,30 +9075,6 @@ Your project makes good (efficient, measurable) use of the real operating system Then it will be a good Operating Systems project, regardless of the language used. I would suggest implementing your own memcached, map-reduce or a simple version control system as good project examples. Edited: removed ranting",0.3220671291218403,False,7,767 -2010-09-04 18:35:42.723,Operating System from scratch,"I have been asked to choose a project for my Operating System course at my university. I was bubbled with the idea of making an Operating System from scratch in Python. -I have a few limitations: - -I have only 3 months. -I want to do it in Python. -I can put in say 20-30 hours every week into it. - -I want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations? -Is there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS) -If the idea is not feasible, can anyone tell me how much do I need to scale down my idea? -Any help is much appreciated!","Scale this down a lot. I would recommend looking at one very small piece of an operating system that you would want to do, perhaps parallel processing. There is no feasible way you will be able to write an entire operating system in under 500 hours, let only 5000 hours. The real question is is this for an undergraduate course or a graduate course? The answer to that will greatly reflect what is needed to pass. -Adding -Grab a book on a topic about the operating system that interests you and focus intently on that for 3 months and you may just produce something that is good. Operating systems may seem like they don't do much on the outside, but think of it this way Windows has ~50 million lines of code.",0.5325457524925297,False,7,767 -2010-09-04 18:35:42.723,Operating System from scratch,"I have been asked to choose a project for my Operating System course at my university. I was bubbled with the idea of making an Operating System from scratch in Python. -I have a few limitations: - -I have only 3 months. -I want to do it in Python. -I can put in say 20-30 hours every week into it. - -I want to know, how feasible is the idea? Like how far can I go in building the same. I would be very happy, if I can get a basic version running (something with a handful of very basic apps running.) Is it possible with the given limitations? -Is there a book that can help me like a guideline? (need not be for python, I just need a guide to tell me how I should go about making the OS) -If the idea is not feasible, can anyone tell me how much do I need to scale down my idea? -Any help is much appreciated!","Developing an operating system in Python is possible. However, you might want to choose C or Assembly because there's an huge code base developed in those languages.",0.0,False,7,767 2010-09-05 12:11:30.483,"Django, Turbo Gears, Web2Py, which is better for what?","I got a project in mind that makes it worth to finally take the plunge into programming. After reading a lot of stuff, here and elsewhere, I'm set on making Python the one I learn for now, over C# or java. What convinced me the most was actually Paul Graham's excursions on programming languages and Lisp, though Arc is in the experimental stage, which wouldn't help me do this web app right now. As for web app fast, I've checked out Django, Turbo Gears and Py2Web. In spite of spending a lot of time reading, I still have no clue which one I should use. @@ -9085,15 +9085,7 @@ I haven't decided on an IDE yet, though I read all the answers to the Intellisen Since probably no framework is hands down the best at everything, I will give some specifics on the app I want to build: It will use MySQL, it needs register/sign-in, and there will be a load of simple math operations on data from input and SQL queries. I've completed a functional prototype in Excel, so I know exactly what I want to build, which I hope will help me overcome my noobness. I'll be a small app, nothing big. And I don't want to see any HTML while building it ;-) -PS: thanks to the people running Stackoverflow, found this place just at the right moment too!","Django: Heard it has the best administrative -interface. But uses it's own ORM, i.e. doesn't use SQL-Alchemy. -Web2py: Didn't research this. -Turbogears2: -Uses SQL-Alchemy by default, uses Catwalk for admin -interface, but documentation isn't as -great. - -I chose Turbogears2 because it uses popular components, so I didn't have to learn anything new...",0.1160922760327606,False,3,768 +PS: thanks to the people running Stackoverflow, found this place just at the right moment too!","I've used both web2py and RoR extensively, and while RoR has gotten a lot of popularity and support in the past few years, web2py is simpler, cleaner, less ""magical"", and yet also offers more (useful) out-of-the-box functionality. I'd say that web2py has more potential than RoR, but it is a relatively new framework and does yet not have the maturity of RoR. (Despite that, though, I'd choose web2py over RoR any day...)",0.1160922760327606,False,3,768 2010-09-05 12:11:30.483,"Django, Turbo Gears, Web2Py, which is better for what?","I got a project in mind that makes it worth to finally take the plunge into programming. After reading a lot of stuff, here and elsewhere, I'm set on making Python the one I learn for now, over C# or java. What convinced me the most was actually Paul Graham's excursions on programming languages and Lisp, though Arc is in the experimental stage, which wouldn't help me do this web app right now. As for web app fast, I've checked out Django, Turbo Gears and Py2Web. In spite of spending a lot of time reading, I still have no clue which one I should use. @@ -9119,24 +9111,32 @@ I haven't decided on an IDE yet, though I read all the answers to the Intellisen Since probably no framework is hands down the best at everything, I will give some specifics on the app I want to build: It will use MySQL, it needs register/sign-in, and there will be a load of simple math operations on data from input and SQL queries. I've completed a functional prototype in Excel, so I know exactly what I want to build, which I hope will help me overcome my noobness. I'll be a small app, nothing big. And I don't want to see any HTML while building it ;-) -PS: thanks to the people running Stackoverflow, found this place just at the right moment too!","I've used both web2py and RoR extensively, and while RoR has gotten a lot of popularity and support in the past few years, web2py is simpler, cleaner, less ""magical"", and yet also offers more (useful) out-of-the-box functionality. I'd say that web2py has more potential than RoR, but it is a relatively new framework and does yet not have the maturity of RoR. (Despite that, though, I'd choose web2py over RoR any day...)",0.1160922760327606,False,3,768 -2010-09-05 19:46:57.897,"PEP8 and PyQt, how to reconcile function capitalization?","I'm starting to use PyQt in some projects and I'm running into a stylistic dilemma. PyQt's functions use camel case, but PEP8, which I prefer to follow, says to use underscores and all lowercase for function names. -So on the one hand, I can continue to follow PEP8, meaning that my code will have mixed functions calls to camel case and underscore functions, and even my classes will have mixed function names, since I'll need to be overloading functions like mousePressEvent. Or, I can break PEP8 and adopt camel case for all my function names in the name of consistency. -I realize this is subjective and it's really just what I personally prefer, but I like to hear from others about what they do and why they chose to do it that way.",Maybe sensible use of modules to separate the styles in different modules can help. At least try to modularize basic PEP8 style code to own module of helper functions.,0.0,False,4,769 +PS: thanks to the people running Stackoverflow, found this place just at the right moment too!","Django: Heard it has the best administrative +interface. But uses it's own ORM, i.e. doesn't use SQL-Alchemy. +Web2py: Didn't research this. +Turbogears2: +Uses SQL-Alchemy by default, uses Catwalk for admin +interface, but documentation isn't as +great. + +I chose Turbogears2 because it uses popular components, so I didn't have to learn anything new...",0.1160922760327606,False,3,768 2010-09-05 19:46:57.897,"PEP8 and PyQt, how to reconcile function capitalization?","I'm starting to use PyQt in some projects and I'm running into a stylistic dilemma. PyQt's functions use camel case, but PEP8, which I prefer to follow, says to use underscores and all lowercase for function names. So on the one hand, I can continue to follow PEP8, meaning that my code will have mixed functions calls to camel case and underscore functions, and even my classes will have mixed function names, since I'll need to be overloading functions like mousePressEvent. Or, I can break PEP8 and adopt camel case for all my function names in the name of consistency. -I realize this is subjective and it's really just what I personally prefer, but I like to hear from others about what they do and why they chose to do it that way.","The pep8 document says what to do in this case (emphasis mine): - -New modules and packages (including third party frameworks) should be written to these standards, but where an existing library has a different style, internal consistency is preferred.",0.7408590612005881,False,4,769 +I realize this is subjective and it's really just what I personally prefer, but I like to hear from others about what they do and why they chose to do it that way.","Use what fits best. +If you're subclassing Qt classes, or have a function heavily integrated with them UseCamelCase. +Otherwise, use_underscores.",0.3869120172231254,False,4,769 2010-09-05 19:46:57.897,"PEP8 and PyQt, how to reconcile function capitalization?","I'm starting to use PyQt in some projects and I'm running into a stylistic dilemma. PyQt's functions use camel case, but PEP8, which I prefer to follow, says to use underscores and all lowercase for function names. So on the one hand, I can continue to follow PEP8, meaning that my code will have mixed functions calls to camel case and underscore functions, and even my classes will have mixed function names, since I'll need to be overloading functions like mousePressEvent. Or, I can break PEP8 and adopt camel case for all my function names in the name of consistency. I realize this is subjective and it's really just what I personally prefer, but I like to hear from others about what they do and why they chose to do it that way.","In your shoes, I wouldn't fight your framework, just like, as a general principle, I don't fight City Hall;-). I happen to share your preference for lowercase-with-underscore function names as PEP 8 specifies, but when I'm programming in a framework that forces a different capitalization style, I resign myself to adopting that style too, since I can't convince the framework to adopt the ""better"" style, and style inconsistencies (haphazard mixes of different styles) are really worse. Of course, some mixage is inevitable if you're using more than one framework... e.g., PyQt with its camelcase, and standard Python library functions with their lowercase and underscores!-). But since frameworks like Qt are often intended to be extended by subclassing, while the standard Python library has less aspects of such a design, in most case where the capitalization style is forced (because you need to override a method, so you can't choose a different capitalization), it will be forced to camelcase (by Qt), only rarely to lowercase (by the standard Python library). So, I think that adopting Qt style in this case is still the lesser evil.",0.9999665971563038,False,4,769 2010-09-05 19:46:57.897,"PEP8 and PyQt, how to reconcile function capitalization?","I'm starting to use PyQt in some projects and I'm running into a stylistic dilemma. PyQt's functions use camel case, but PEP8, which I prefer to follow, says to use underscores and all lowercase for function names. So on the one hand, I can continue to follow PEP8, meaning that my code will have mixed functions calls to camel case and underscore functions, and even my classes will have mixed function names, since I'll need to be overloading functions like mousePressEvent. Or, I can break PEP8 and adopt camel case for all my function names in the name of consistency. -I realize this is subjective and it's really just what I personally prefer, but I like to hear from others about what they do and why they chose to do it that way.","Use what fits best. -If you're subclassing Qt classes, or have a function heavily integrated with them UseCamelCase. -Otherwise, use_underscores.",0.3869120172231254,False,4,769 +I realize this is subjective and it's really just what I personally prefer, but I like to hear from others about what they do and why they chose to do it that way.",Maybe sensible use of modules to separate the styles in different modules can help. At least try to modularize basic PEP8 style code to own module of helper functions.,0.0,False,4,769 +2010-09-05 19:46:57.897,"PEP8 and PyQt, how to reconcile function capitalization?","I'm starting to use PyQt in some projects and I'm running into a stylistic dilemma. PyQt's functions use camel case, but PEP8, which I prefer to follow, says to use underscores and all lowercase for function names. +So on the one hand, I can continue to follow PEP8, meaning that my code will have mixed functions calls to camel case and underscore functions, and even my classes will have mixed function names, since I'll need to be overloading functions like mousePressEvent. Or, I can break PEP8 and adopt camel case for all my function names in the name of consistency. +I realize this is subjective and it's really just what I personally prefer, but I like to hear from others about what they do and why they chose to do it that way.","The pep8 document says what to do in this case (emphasis mine): + +New modules and packages (including third party frameworks) should be written to these standards, but where an existing library has a different style, internal consistency is preferred.",0.7408590612005881,False,4,769 2010-09-06 00:04:04.113,"In Python, how can I access the namespace of the main module from an imported module?","Specifically, I need to get at some objects and globals from the main module in an imported module. I know how to find those things when the parent module wants some particular thing from a child module, but I can't figure out how to go in the other direction.",Not sure if it is a good practice but maybe you could pass the objects and variables you need as parameters to the methods or classes you call in the imported module.,0.1016881243684853,False,1,770 2010-09-06 17:26:48.150,Subdomains vs folders/directories,"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. I 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! @@ -9217,7 +9217,7 @@ Please suggest an efficient way of storing and searching through the index. My dictionary structure is as follows (using nested dictionaries) {word : {doc1:[locations], doc2:[locations], ....}} so that I can get the documents containing a word by -dictionary[word].keys() ... and so on.","I am using anydmb for that purpose. Anydbm provides the same dictionary-like interface, except it allow only strings as keys and values. But this is not a constraint since you can use cPickle's loads/dumps to store more complex structures in the index.",0.0,False,2,779 +dictionary[word].keys() ... and so on.",You could store the repr() of the dictionary and use that to re-create it.,0.0,False,2,779 2010-09-10 19:29:56.637,Storing an inverted index,"I am working on a project on Info Retrieval. I have made a Full Inverted Index using Hadoop/Python. Hadoop outputs the index as (word,documentlist) pairs which are written on the file. @@ -9229,7 +9229,7 @@ Please suggest an efficient way of storing and searching through the index. My dictionary structure is as follows (using nested dictionaries) {word : {doc1:[locations], doc2:[locations], ....}} so that I can get the documents containing a word by -dictionary[word].keys() ... and so on.",You could store the repr() of the dictionary and use that to re-create it.,0.0,False,2,779 +dictionary[word].keys() ... and so on.","I am using anydmb for that purpose. Anydbm provides the same dictionary-like interface, except it allow only strings as keys and values. But this is not a constraint since you can use cPickle's loads/dumps to store more complex structures in the index.",0.0,False,2,779 2010-09-11 04:11:54.723,Will nginx+paste hold up in a production environment?,"I've developed a website in Pylons (Python web framework) and have it running, on my production server, under Apache + mod_wsgi. I'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. What I want to know is, how will Paste hold up under a heavy load? Am I better off going with nginx + mod_wsgi ?","Your app will be the bottleneck in performance not Apache or Paste. @@ -9306,6 +9306,13 @@ REST is one option to implement the latter. You should then look for frameworks for REST development with python, or if it’s simple logic with not so many possible requests can do it on your own as a web-script.",0.0,False,1,787 2010-09-13 19:29:52.310,top gotchas for someone moving from a static lang (java/c#) to dynamic language like python,"What are the top gotchas for someone moving from a static lang (java/c#) to dynamic language like python? It seems cool how things can be done, but renaming a method, or adding/removing parameters seems so risky! +Is the only solution to write tests for each method?","Some things that struck me when first trying out Python (coming from a mainly Java background): + +Write 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. +Get comfortable with the idea that functions are truly objects. Pass them around as callbacks, make functions return functions, learn about closures etc. +There 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.",0.2655860252697744,False,2,788 +2010-09-13 19:29:52.310,top gotchas for someone moving from a static lang (java/c#) to dynamic language like python,"What are the top gotchas for someone moving from a static lang (java/c#) to dynamic language like python? +It seems cool how things can be done, but renaming a method, or adding/removing parameters seems so risky! Is the only solution to write tests for each method?","""Is the only solution to write tests for each method?"" Are you saying you didn't write tests for each method in Java? @@ -9328,13 +9335,6 @@ Why Python doesn't have super-complex protected, private and public declarations Why Python doesn't have an enum type. The #1 chronic problem seems to be using mutable objects as default values for a function. Simply avoid this.",0.3869120172231254,False,2,788 -2010-09-13 19:29:52.310,top gotchas for someone moving from a static lang (java/c#) to dynamic language like python,"What are the top gotchas for someone moving from a static lang (java/c#) to dynamic language like python? -It seems cool how things can be done, but renaming a method, or adding/removing parameters seems so risky! -Is the only solution to write tests for each method?","Some things that struck me when first trying out Python (coming from a mainly Java background): - -Write 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. -Get comfortable with the idea that functions are truly objects. Pass them around as callbacks, make functions return functions, learn about closures etc. -There 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.",0.2655860252697744,False,2,788 2010-09-14 04:25:59.440,how can I get the window name? [Python],"How can I get the window name? I want to make a script where I have some keyboard event, and I want it to happens only if the window name has something in the name, like, Firefox. how can I do it? @@ -9364,10 +9364,10 @@ Include the version of Netbeans and the Java you are using - and whether you usi Also include at which point you see the error message - when you create a new file, new project etc - does Netbeans start up ok etc ?",0.0,False,1,793 2010-09-16 23:41:03.663,Capturing user input at arbitrary times in python,"Is there a way to send an interrupt to a python module when the user inputs something in the console? For example, if I'm running an infinite while loop, i can surround it with a try/except for KeyboardInterrupt and then do what I need to do in the except block. Is there a way to duplicate this functionality with any arbitrary input? Either a control sequence or a standard character? -Edit: Sorry, this is on linux","KeyboardInterrupt is special in that it can be trapped (i.e. SIGINT under operating systems with respective POSIX support, SetConsoleCtrlHandler on Windows) and handled accordingly. If you want to process user input while at the same time doing work in a otherwise blocking loop, have a look at the threading or subprocess modules, taking a look at how to exchange data between two different threads / processes. Also be sure to get an understanding of the issues that go hand in hand with parallel computing (i.e. race conditions, thread safety / synchronization etc.)",0.0679224682270276,False,2,794 +Edit: Sorry, this is on linux","You need a separate process (or possibly a thread) to read the terminal and send it to the process of interest via some form of inter-process communication (IPC) (inter-thread communication may be harder -- basically the only thing you do is send a KeyboardInterrupt from a secondary thread to the main thread). Since you say ""I was hoping there would be a simple way to inject user input into the loop other than just ^C"", I'm sad to disappoint you, but that's the truth: there are ways to do what you request, but simple they aren't.",0.1352210990936997,False,2,794 2010-09-16 23:41:03.663,Capturing user input at arbitrary times in python,"Is there a way to send an interrupt to a python module when the user inputs something in the console? For example, if I'm running an infinite while loop, i can surround it with a try/except for KeyboardInterrupt and then do what I need to do in the except block. Is there a way to duplicate this functionality with any arbitrary input? Either a control sequence or a standard character? -Edit: Sorry, this is on linux","You need a separate process (or possibly a thread) to read the terminal and send it to the process of interest via some form of inter-process communication (IPC) (inter-thread communication may be harder -- basically the only thing you do is send a KeyboardInterrupt from a secondary thread to the main thread). Since you say ""I was hoping there would be a simple way to inject user input into the loop other than just ^C"", I'm sad to disappoint you, but that's the truth: there are ways to do what you request, but simple they aren't.",0.1352210990936997,False,2,794 +Edit: Sorry, this is on linux","KeyboardInterrupt is special in that it can be trapped (i.e. SIGINT under operating systems with respective POSIX support, SetConsoleCtrlHandler on Windows) and handled accordingly. If you want to process user input while at the same time doing work in a otherwise blocking loop, have a look at the threading or subprocess modules, taking a look at how to exchange data between two different threads / processes. Also be sure to get an understanding of the issues that go hand in hand with parallel computing (i.e. race conditions, thread safety / synchronization etc.)",0.0679224682270276,False,2,794 2010-09-17 14:39:46.393,How can I tell Pychecker to ignore an imported library?,"One of the modules I import into my python project triggers lots of warnings under Pychecker. Fixing up this external module isn't really an option, so I want to tell Pychecker to ignore it. Does anyone know how to do this? I'm sure it's possible, and probably quite simple, but after trawling Google for a while I've not found any documentation or examples. Thanks, @@ -9423,16 +9423,6 @@ Once logged in, users can add items to pre-created collections (like ""DVD"" or Each collection has it's own template with attributes (ie: DVD has Name, Year, Studio, Rating, Comments, etc) Users can list all items in collections (all DVDs, all Software), sort by various attributes -Also: Yes I know there are lots of online tools like this, but I want to build it on my own with Python","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.",0.0,False,2,803 -2010-09-20 04:31:00.510,Complete newbie excited about Python. How hard would this app be to build?,"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. -I'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? -Online Collection DB - -Users can create accounts that are authenticated through token sent via e-mail -Once logged in, users can add items to pre-created collections (like ""DVD"" or ""Software"") -Each collection has it's own template with attributes (ie: DVD has Name, Year, Studio, Rating, Comments, etc) -Users can list all items in collections (all DVDs, all Software), sort by various attributes - Also: Yes I know there are lots of online tools like this, but I want to build it on my own with Python","Assuming you're already familiar with another programming language: Time to learn python basics: 1 week. @@ -9444,6 +9434,16 @@ Total time to figure out that you probably don't need SQL: 1 week. Total time writing the rest of the logic in python: 1 week. Probably...",0.9981778976111988,False,2,803 +2010-09-20 04:31:00.510,Complete newbie excited about Python. How hard would this app be to build?,"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. +I'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? +Online Collection DB + +Users can create accounts that are authenticated through token sent via e-mail +Once logged in, users can add items to pre-created collections (like ""DVD"" or ""Software"") +Each collection has it's own template with attributes (ie: DVD has Name, Year, Studio, Rating, Comments, etc) +Users can list all items in collections (all DVDs, all Software), sort by various attributes + +Also: Yes I know there are lots of online tools like this, but I want to build it on my own with Python","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.",0.0,False,2,803 2010-09-20 13:58:52.517,how to get the value of the 'class' attribute in a link?,"I wrote the sentence as follows: allLinkValues = ie.getLinksValue('class') but the return values are all None, don't know why...",should be 'className' in IE...,1.2,True,1,804 @@ -9499,9 +9499,6 @@ Essentially, send your chart data to the page along with the chart image, and us It's a bit harder than the bar graphs I've done this to before, but should work fine.",0.2012947653214861,False,1,808 2010-09-21 09:37:01.020,Django Google app engine reference issues,"I am working on an application on Django and google application engine. In my application I have several models with several ReferenceProperty fields. The issue is that if any of the ReferenceProperty field gets deleted it produces a ReferenceProperty related errors in all the other models where it has been used. What I want is, when a field is deleted say a User is deleted, all the fields having User as the ReferenceProperty should still work without any error messages displaying the associated user as unavailable or something like that. Can someone please suggest how that can be done? -Thanks in advance.","When I have the same problem ago, I could not find a general solution. The only way I found is to do try/except for every reference property. If you find another answer post it here.",0.0,False,3,809 -2010-09-21 09:37:01.020,Django Google app engine reference issues,"I am working on an application on Django and google application engine. In my application I have several models with several ReferenceProperty fields. The issue is that if any of the ReferenceProperty field gets deleted it produces a ReferenceProperty related errors in all the other models where it has been used. What I want is, when a field is deleted say a User is deleted, all the fields having User as the ReferenceProperty should still work without any error messages displaying the associated user as unavailable or something like that. -Can someone please suggest how that can be done? Thanks in advance.","Two possible solutions: Check if the reference still exists, before you access it: @@ -9510,6 +9507,9 @@ if not obj.reference: When you delete a model object that may be referenced, query all models that might reference it, and set their reference property to None.",1.2,True,3,809 2010-09-21 09:37:01.020,Django Google app engine reference issues,"I am working on an application on Django and google application engine. In my application I have several models with several ReferenceProperty fields. The issue is that if any of the ReferenceProperty field gets deleted it produces a ReferenceProperty related errors in all the other models where it has been used. What I want is, when a field is deleted say a User is deleted, all the fields having User as the ReferenceProperty should still work without any error messages displaying the associated user as unavailable or something like that. Can someone please suggest how that can be done? +Thanks in advance.","When I have the same problem ago, I could not find a general solution. The only way I found is to do try/except for every reference property. If you find another answer post it here.",0.0,False,3,809 +2010-09-21 09:37:01.020,Django Google app engine reference issues,"I am working on an application on Django and google application engine. In my application I have several models with several ReferenceProperty fields. The issue is that if any of the ReferenceProperty field gets deleted it produces a ReferenceProperty related errors in all the other models where it has been used. What I want is, when a field is deleted say a User is deleted, all the fields having User as the ReferenceProperty should still work without any error messages displaying the associated user as unavailable or something like that. +Can someone please suggest how that can be done? Thanks in advance.","You could also just set a flag, say deleted, on the entity you're deleting, and then leave it in the datastore. This has the advantage of avoiding all referential integrity problems in the first place, but it comes at the cost of two main disadvantages: All your existing queries need to be changed to deal with entities that have the deleted property set, either by omitting them from the result set or by special casing them somehow. @@ -9561,15 +9561,8 @@ If your device uses HTTP to get commands and updates, you'll need to work out a Building 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.",0.0,False,1,818 2010-09-28 02:40:30.817,How to install both Python 2.x and Python 3.x in Windows,"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I ""choose"" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. -Thanks.","I use a simple solution to switch from a version to another version of python, you can install all version you want. All you have to do is creating some variable environment. -In my case, I have installed python 2.7 and python 3.8.1, so I have created this environment variables: - -PYTHON_HOME_2.7= -PYTHON_HOME_3.8.1= -PYTHON_HOME=%PYTHON_HOME_2.7% - -then in my PATH environment variable I put only %PYTHON_HOME% and %PYTHON_HOME%\Scripts. In the example above I'm using the version 2.7, when I want to switch to the other version I have only to set the PYTHON_HOME=%PYTHON_HOME_3.8.1%. -I use this method to switch quickly from a version to another also for JAVA, MAVEN, GRADLE,ANT, and so on.",0.0,False,8,819 +Thanks.","Only Works if your running your code in your Python IDE +I have both Python 2.7 and Python 3.3 installed on my windows operating system. If I try to launch a file, it will usually open up on the python 2.7 IDE. How I solved this issue, was when I choose to run my code on python 3.3, I open up python 3.3 IDLE(Python GUI), select file, open my file with the IDLE and save it. Then when I run my code, it runs to the IDLE that I currently opened it with. It works vice versa with 2.7.",-0.0214789731252583,False,8,819 2010-09-28 02:40:30.817,How to install both Python 2.x and Python 3.x in Windows,"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I ""choose"" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. Thanks.","To install and run any version of Python in the same system follow my guide below. @@ -9607,22 +9600,19 @@ Now py -4 or py -5 etc. on my system outputs: Requested Python version (4) not i Hopefully this is clear enough.",0.2722289464304554,False,8,819 2010-09-28 02:40:30.817,How to install both Python 2.x and Python 3.x in Windows,"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I ""choose"" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. -Thanks.","I have installed both python 2.7.13 and python 3.6.1 on windows 10pro and I was getting the same ""Fatal error"" when I tried pip2 or pip3. -What I did to correct this was to go to the location of python.exe for python 2 and python 3 files and create a copy of each, I then renamed each copy to python2.exe and python3.exe depending on the python version in the installation folder. I therefore had in each python installation folder both a python.exe file and a python2.exe or python3.exe depending on the python version. -This resolved my problem when I typed either pip2 or pip3.",-0.0214789731252583,False,8,819 -2010-09-28 02:40:30.817,How to install both Python 2.x and Python 3.x in Windows,"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. -Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I ""choose"" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. -Thanks.","Check your system environment variables after installing Python, python 3's directories should be first in your PATH variable, then python 2. -Whichever path variable matches first is the one Windows uses. -As always py -2 will launch python2 in this scenario.",0.0214789731252583,False,8,819 -2010-09-28 02:40:30.817,How to install both Python 2.x and Python 3.x in Windows,"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. -Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I ""choose"" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. -Thanks.","You can install multiple versions of Python one machine, and during setup, you can choose to have one of them associate itself with Python file extensions. If you install modules, there will be different setup packages for different versions, or you can choose which version you want to target. Since they generally install themselves into the site-packages directory of the interpreter version, there shouldn't be any conflicts (but I haven't tested this). To choose which version of python, you would have to manually specify the path to the interpreter if it is not the default one. As far as I know, they would share the same PATH and PYTHONPATH variables, which may be a problem. -Note: I run Windows XP. I have no idea if any of this changes for other versions, but I don't see any reason that it would.",0.06435775498645,False,8,819 -2010-09-28 02:40:30.817,How to install both Python 2.x and Python 3.x in Windows,"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. -Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I ""choose"" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. -Thanks.","Only Works if your running your code in your Python IDE -I have both Python 2.7 and Python 3.3 installed on my windows operating system. If I try to launch a file, it will usually open up on the python 2.7 IDE. How I solved this issue, was when I choose to run my code on python 3.3, I open up python 3.3 IDLE(Python GUI), select file, open my file with the IDLE and save it. Then when I run my code, it runs to the IDLE that I currently opened it with. It works vice versa with 2.7.",-0.0214789731252583,False,8,819 +Thanks.","What I did was download both 2.7.6 and 3.3.4. Python 3.3.4 has the option to add the path to it in the environment variable so that was done. So basically I just manually added Python 2.7.6. +How to... + +Start > in the search type in environment select ""Edit environment variables to your account""1 +Scroll down to Path, select path, click edit. +Add C:\Python27; +so you should have paths to both versions of Python there, but if you don't this you can easily edit it so that you do..... C:\Python27;C:\Python33; +Navigate to the Python27 folder in C:\ and rename a copy of python.exe to python2.exe +Navigate to the Python34 folder in C:\ and rename a copy of python.exe to python3.exe +Test: open up commmand prompt and type python2 ....BOOM! Python 2.7.6. exit out. +Test: open up commmand prompt and type python3 ....BOOM! Python 3.4.3. exit out. + +Note: (so as not to break pip commands in step 4 and 5, keep copy of python.exe in the same directory as the renamed file)",0.9996037109834162,False,8,819 2010-09-28 02:40:30.817,How to install both Python 2.x and Python 3.x in Windows,"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I ""choose"" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. Thanks.","Install the one you use most (3.3 in my case) over the top of the other. That'll force IDLE to use the one you want. @@ -9643,19 +9633,29 @@ primary version, you would execute ""make install"" in your 2.7 build directory and ""make altinstall"" in the others.",0.0,False,8,819 2010-09-28 02:40:30.817,How to install both Python 2.x and Python 3.x in Windows,"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I ""choose"" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. -Thanks.","What I did was download both 2.7.6 and 3.3.4. Python 3.3.4 has the option to add the path to it in the environment variable so that was done. So basically I just manually added Python 2.7.6. -How to... +Thanks.","I use a simple solution to switch from a version to another version of python, you can install all version you want. All you have to do is creating some variable environment. +In my case, I have installed python 2.7 and python 3.8.1, so I have created this environment variables: -Start > in the search type in environment select ""Edit environment variables to your account""1 -Scroll down to Path, select path, click edit. -Add C:\Python27; -so you should have paths to both versions of Python there, but if you don't this you can easily edit it so that you do..... C:\Python27;C:\Python33; -Navigate to the Python27 folder in C:\ and rename a copy of python.exe to python2.exe -Navigate to the Python34 folder in C:\ and rename a copy of python.exe to python3.exe -Test: open up commmand prompt and type python2 ....BOOM! Python 2.7.6. exit out. -Test: open up commmand prompt and type python3 ....BOOM! Python 3.4.3. exit out. +PYTHON_HOME_2.7= +PYTHON_HOME_3.8.1= +PYTHON_HOME=%PYTHON_HOME_2.7% -Note: (so as not to break pip commands in step 4 and 5, keep copy of python.exe in the same directory as the renamed file)",0.9996037109834162,False,8,819 +then in my PATH environment variable I put only %PYTHON_HOME% and %PYTHON_HOME%\Scripts. In the example above I'm using the version 2.7, when I want to switch to the other version I have only to set the PYTHON_HOME=%PYTHON_HOME_3.8.1%. +I use this method to switch quickly from a version to another also for JAVA, MAVEN, GRADLE,ANT, and so on.",0.0,False,8,819 +2010-09-28 02:40:30.817,How to install both Python 2.x and Python 3.x in Windows,"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. +Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I ""choose"" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. +Thanks.","Check your system environment variables after installing Python, python 3's directories should be first in your PATH variable, then python 2. +Whichever path variable matches first is the one Windows uses. +As always py -2 will launch python2 in this scenario.",0.0214789731252583,False,8,819 +2010-09-28 02:40:30.817,How to install both Python 2.x and Python 3.x in Windows,"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. +Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I ""choose"" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. +Thanks.","I have installed both python 2.7.13 and python 3.6.1 on windows 10pro and I was getting the same ""Fatal error"" when I tried pip2 or pip3. +What I did to correct this was to go to the location of python.exe for python 2 and python 3 files and create a copy of each, I then renamed each copy to python2.exe and python3.exe depending on the python version in the installation folder. I therefore had in each python installation folder both a python.exe file and a python2.exe or python3.exe depending on the python version. +This resolved my problem when I typed either pip2 or pip3.",-0.0214789731252583,False,8,819 +2010-09-28 02:40:30.817,How to install both Python 2.x and Python 3.x in Windows,"I do most of my programming in Python 3.x on Windows 7, but now I need to use the Python Imaging Library (PIL), ImageMagick, and wxPython, all of which require Python 2.x. +Can I have both Python 2.x and Python 3.x installed in Windows 7? When I run a script, how would I ""choose"" which version of Python should run it? Will the aforementioned programs be able to handle multiple versions of Python installed at once? I have searched for hours and hours for how to do this to no avail. +Thanks.","You can install multiple versions of Python one machine, and during setup, you can choose to have one of them associate itself with Python file extensions. If you install modules, there will be different setup packages for different versions, or you can choose which version you want to target. Since they generally install themselves into the site-packages directory of the interpreter version, there shouldn't be any conflicts (but I haven't tested this). To choose which version of python, you would have to manually specify the path to the interpreter if it is not the default one. As far as I know, they would share the same PATH and PYTHONPATH variables, which may be a problem. +Note: I run Windows XP. I have no idea if any of this changes for other versions, but I don't see any reason that it would.",0.06435775498645,False,8,819 2010-09-28 09:04:13.757,Getting admin password while copy file using shutil.copy?,"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. So How could i copy files with admin permission or how could i get the admin password from the user to copy the files? @@ -9764,16 +9764,16 @@ Thank you Let's say I two applications in my Django application. Now i don't mean two separate Django applications but the separate folders inside the 'app' directory. Let's call this app1 and app2 I want all requests on port 8000 to go to app1 and all requests on port XXXX to go to app2 -HTH.","Just run two instances of ./manage.py runserver. You can set a port by simply specifying it directly: ./manage.py runserver 8002 to listen on port 8002. -Edit I don't really understand why you want to do this. If you want two servers serving different parts of your site, then you have in effect two sites, which will need two separate settings.py and urls.py files. You'd then run one instance of runserver with each, passing the settings flag appropriately: ./manage.py runserver 8002 --settings=app1.settings",1.2,True,2,837 +HTH.","The built-in web-server is intended for development only, so you should really be using apache or similar in an situation where you need to run on multiple ports. +On the other hand you should be able to start up multiple servers just by starting multiple instances of runserver. As long as you are using a separate database server I don't think that will have any extra problems.",0.2655860252697744,False,2,837 2010-10-07 15:57:27.913,Run Django on multiple ports,"Could someone tell me how I can run Django on two ports simultaneously? The default Django configuration only listens on port 8000. I'd like to run another instance on port xxxx as well. I'd like to redirect all requests to this second port to a particular app in my Django application. I need to accomplish this with the default Django installation and not by using a webserver like nginx, Apache, etc. Thank you Let's say I two applications in my Django application. Now i don't mean two separate Django applications but the separate folders inside the 'app' directory. Let's call this app1 and app2 I want all requests on port 8000 to go to app1 and all requests on port XXXX to go to app2 -HTH.","The built-in web-server is intended for development only, so you should really be using apache or similar in an situation where you need to run on multiple ports. -On the other hand you should be able to start up multiple servers just by starting multiple instances of runserver. As long as you are using a separate database server I don't think that will have any extra problems.",0.2655860252697744,False,2,837 +HTH.","Just run two instances of ./manage.py runserver. You can set a port by simply specifying it directly: ./manage.py runserver 8002 to listen on port 8002. +Edit I don't really understand why you want to do this. If you want two servers serving different parts of your site, then you have in effect two sites, which will need two separate settings.py and urls.py files. You'd then run one instance of runserver with each, passing the settings flag appropriately: ./manage.py runserver 8002 --settings=app1.settings",1.2,True,2,837 2010-10-07 16:12:42.083,"django, python: reload function in shell","I work in the django IPython-shell, which can be started with manage.py shell. When i load an extern function in the shell for testing, everything is alright. But when i make changes to the function, the shell still has the old version of the function. Even if i make a new import. Does anyone know how to reload the actual version of the function? @@ -9820,12 +9820,12 @@ Well jaascript does have a native way to convert javascript to string, its just 2010-10-09 17:31:57.473,URL rewriting 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. I'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. In particular, looking through index.cgi, its looking for strings like ""@edit"" in REQUEST_URI environment variable. -Any idea how to fix this?","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""",1.2,True,2,845 +Any idea how to fix this?","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). +If 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.",0.0,False,2,845 2010-10-09 17:31:57.473,URL rewriting 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. I'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. In particular, looking through index.cgi, its looking for strings like ""@edit"" in REQUEST_URI environment variable. -Any idea how to fix this?","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). -If 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.",0.0,False,2,845 +Any idea how to fix this?","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""",1.2,True,2,845 2010-10-10 04:11:19.010,How to control a frame from another frame?,"I'm writing a small app which has 2 separate frames. The first frame is like a video player controller. It has Play/Stop/Pause buttons etc. It's named controller.py. The second frame contains OpenGL rendering and many things inside it, but everything is wrapped inside a Frame() class as the above. It's named model.py. @@ -9840,12 +9840,12 @@ An alternative is to use locking or semaphores, to prevent multiple clients acce 2010-10-11 01:28:00.427,How to get out of interactive mode in Python,"This obviously an extremely novice question, but I've installed Python 2.7 and started reading the manual. However I looked and looked, and couldn't understand how to start programming a file rather than writing in interactive mode. One book that was online suggested quit(), which surprise -- quit the program. Should coding be done in a different program? I'm using IDLE (Python GUI). Can coding not be done within that program?","Yes, coding should be done in a different program. The interactive shell is very useful but it's not an editor.",0.1352210990936997,False,4,848 2010-10-11 01:28:00.427,How to get out of interactive mode in Python,"This obviously an extremely novice question, but I've installed Python 2.7 and started reading the manual. However I looked and looked, and couldn't understand how to start programming a file rather than writing in interactive mode. One book that was online suggested quit(), which surprise -- quit the program. -Should coding be done in a different program? I'm using IDLE (Python GUI). Can coding not be done within that program?","To start coding in a file, just open a new file and start typing.",-0.1352210990936997,False,4,848 +Should coding be done in a different program? I'm using IDLE (Python GUI). Can coding not be done within that program?","use new window tool in the file icon,in the python idle itself to write a program",0.0,False,4,848 2010-10-11 01:28:00.427,How to get out of interactive mode in Python,"This obviously an extremely novice question, but I've installed Python 2.7 and started reading the manual. However I looked and looked, and couldn't understand how to start programming a file rather than writing in interactive mode. One book that was online suggested quit(), which surprise -- quit the program. Should coding be done in a different program? I'm using IDLE (Python GUI). Can coding not be done within that program?","Push new to start making your own script file. Then when you are ready to test click run and then you can watch the results in the interactive mode, and even try new things as if you were adding code to the end of your script file, its a very useful app for debugging, testing and trying new things. Also in the options you can change the way python opens your scripts when you click edit from windows, you can set it so that it opens the interactive shell or just the editor.",0.0,False,4,848 2010-10-11 01:28:00.427,How to get out of interactive mode in Python,"This obviously an extremely novice question, but I've installed Python 2.7 and started reading the manual. However I looked and looked, and couldn't understand how to start programming a file rather than writing in interactive mode. One book that was online suggested quit(), which surprise -- quit the program. -Should coding be done in a different program? I'm using IDLE (Python GUI). Can coding not be done within that program?","use new window tool in the file icon,in the python idle itself to write a program",0.0,False,4,848 +Should coding be done in a different program? I'm using IDLE (Python GUI). Can coding not be done within that program?","To start coding in a file, just open a new file and start typing.",-0.1352210990936997,False,4,848 2010-10-11 11:33:22.310,Twisted factory protocol instance based callback,"Hey, I got a ReconnectingClientFactory and I wonder if I can somehow define protocol-instance-based connectionMade/connectionLost callbacks so that i can use the factory to connect to different hosts ans distinguish between each connection. Thanks in advance.","No. Write a class that does the interaction with one user. In connectionMade you check if a instance of this class already exists, if not you make a new one and store it on the factory, ie in a { addr : handler } dict. If the connection exists alreay you get the old handler from the factory.",0.3869120172231254,False,1,849 2010-10-12 07:53:45.903,Issue happens when installing Django on Windows 7,"I've got an issue when installing Django. @@ -9856,12 +9856,6 @@ That should fix the pb",1.2,True,1,850 2010-10-12 09:30:05.113,What are Python namespaces all about,"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. Some browsing on the net revealed that one of the reasons going against PHP is that it has no native support for namespaces. Could 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). -I am predominantly coming from Java and C programming backgrounds.","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. -When 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. -You could think one file one object in Python. When you write PHP programs you can achieve the same by writing classes with instance variables.",-0.0679224682270276,False,2,851 -2010-10-12 09:30:05.113,What are Python namespaces all about,"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. -Some browsing on the net revealed that one of the reasons going against PHP is that it has no native support for namespaces. -Could 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). I am predominantly coming from Java and C programming backgrounds.","Namespace is a way to implement scope. In Java (or C) the compiler determines where a variable is visible through static scope analysis. @@ -9872,6 +9866,12 @@ In Python, each package, module, class, function and method function owns a ""na Each variable name is checked in the local namespace (the body of the function, the module, etc.), and then checked in the global namespace. Variables are generally created only in a local namespace. The global and nonlocal statements can create variables in other than the local namespace. When 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.",1.2,True,2,851 +2010-10-12 09:30:05.113,What are Python namespaces all about,"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. +Some browsing on the net revealed that one of the reasons going against PHP is that it has no native support for namespaces. +Could 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). +I am predominantly coming from Java and C programming backgrounds.","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. +When 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. +You could think one file one object in Python. When you write PHP programs you can achieve the same by writing classes with instance variables.",-0.0679224682270276,False,2,851 2010-10-12 12:35:38.810,How to turn a float number like 293.4662543 into 293.47 in python?,"How to shorten the float result I got? I only need 2 digits after the dot. Sorry I really don't know how to explain this better in English... Thanks","x = round(293.4662543, 2)",0.2497086294969975,False,1,852 2010-10-12 15:50:47.623,Python garbage collection can be that slow?,"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... @@ -10001,16 +10001,16 @@ How do I tell B that ""For this url return that image"" How can I handle errors or timeouts? And how can this be done asynchronously?","Afaik you can not store files in App Engine programmatically. You can just store them, when uploading your app. You can however store information in its data store. So you would need to deploy an app, that authenticates your user and then writs the image to the gae's data store",0.2012947653214861,False,1,858 2010-10-18 21:12:28.127,What makes some programming languages more powerful than others?,"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. -I'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?","I would not say that there are computer languages ""more powerful"", just languages more suited for your specific problem domain. -That 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. -IMHO Python is much more general, well designed and elegant, but your question is one that usually starts flamewars.",0.0679224682270276,False,4,859 -2010-10-18 21:12:28.127,What makes some programming languages more powerful than others?,"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. I'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?","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. I'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. PHP 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. And 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. In short - Pick you favorite.",0.0,False,4,859 2010-10-18 21:12:28.127,What makes some programming languages more powerful than others?,"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. +I'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?","I would not say that there are computer languages ""more powerful"", just languages more suited for your specific problem domain. +That 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. +IMHO Python is much more general, well designed and elegant, but your question is one that usually starts flamewars.",0.0679224682270276,False,4,859 +2010-10-18 21:12:28.127,What makes some programming languages more powerful than others?,"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. I'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?","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. This 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.",0.0,False,4,859 2010-10-18 21:12:28.127,What makes some programming languages more powerful than others?,"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. @@ -10025,11 +10025,6 @@ Be aware that if there are children in the frame that are managed by grid or pac I need users to get authenficated before the can't see any of my .pdf but i don't know how (and i can't put my pdf in my database). I'm using Pylons with Python. Thank for you help. -If you have any question, ask me! :)",You want to use the X-Sendfile header to send those files. Precise details will depend on which Http server you're using.,0.2012947653214861,False,3,862 -2010-10-20 18:01:00.337,Show pdf only to authenticated users,"I'm building a web site from the old one and i need to show a lot of .pdf files. -I need users to get authenficated before the can't see any of my .pdf but i don't know how (and i can't put my pdf in my database). -I'm using Pylons with Python. -Thank for you help. If you have any question, ask me! :)","Paul's suggestion of X-Sendfile is excellent - this is truly a great way to deal with actually getting the document back to the user. (+1 for Paul :) As for the front end, do something like this: @@ -10044,6 +10039,11 @@ Thank for you help. If you have any question, ask me! :)","Maybe filename with md5 key will be enough? 48cd84ab06b0a18f3b6e024703cfd246-myfilename.pdf You can use filename and datetime.now to generate md5 key.",0.0,False,3,862 +2010-10-20 18:01:00.337,Show pdf only to authenticated users,"I'm building a web site from the old one and i need to show a lot of .pdf files. +I need users to get authenficated before the can't see any of my .pdf but i don't know how (and i can't put my pdf in my database). +I'm using Pylons with Python. +Thank for you help. +If you have any question, ask me! :)",You want to use the X-Sendfile header to send those files. Precise details will depend on which Http server you're using.,0.2012947653214861,False,3,862 2010-10-20 19:02:41.107,how to input python code in run time and execute it?,"Well i want to input a python function as an input in run time and execute that part of code 'n' no of times. For example using tkinter i create a textbox where the user writes the function and submits it , also mentioning how many times it wants to be executed. My program should be able to run that function as many times as mentioned by the user. Ps: i did think of an alternative method where the user can write the program in a file and then i can simply execute it as python filename as a system cmd inside my python program , but i dont want it that way.","Python provides number of ways to do this using function calls: - eval() @@ -10054,13 +10054,13 @@ I'm running some experiments and I need to precisely measure participants' respo I 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. So my question is, will the response time measure with time module be very accurate or there will be some noise associate with it? Thank you, -Joon","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.",1.2,True,2,864 +Joon","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().",0.2012947653214861,False,2,864 2010-10-21 16:55:44.280,Is python time module reliable enough to use to measure response time?,"My question was not specific enough last time, and so this is second question about this topic. I'm running some experiments and I need to precisely measure participants' response time to questions in millisecond unit. I 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. So my question is, will the response time measure with time module be very accurate or there will be some noise associate with it? Thank you, -Joon","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().",0.2012947653214861,False,2,864 +Joon","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.",1.2,True,2,864 2010-10-21 21:37:11.653,String length without len function,"Can anyone tell me how can I get the length of a string without using the len() function or any string methods. Please anyone tell me as I'm tapping my head madly for the answer. Thank you.","Create a for loop styx = ""How do I count this without using Lens function"" @@ -10072,8 +10072,6 @@ print(number)",-0.0479823334210096,False,1,865 xTensor0[...] = xVTensor[..., 0] From my experimentation, it appears to function the similarly to : in indexing, but stands in for multiple :'s, making x[:,:,1] equivalent to x[...,1].","Yes, you're right. It fills in as many : as required. The only difference occurs when you use multiple ellipses. In that case, the first ellipsis acts in the same way, but each remaining one is converted to a single :.",1.2,True,1,866 2010-10-22 16:41:13.373,How to limit file size when writing one?,"I am using the output streams from the io module and writing to files. I want to be able to detect when I have written 1G of data to a file and then start writing to a second file. I can't seem to figure out how to determine how much data I have written to the file. -Is there something easy built in to io? Or might I have to count the bytes before each write manually?",See the tell() method on the stream object.,0.2012947653214861,False,2,867 -2010-10-22 16:41:13.373,How to limit file size when writing one?,"I am using the output streams from the io module and writing to files. I want to be able to detect when I have written 1G of data to a file and then start writing to a second file. I can't seem to figure out how to determine how much data I have written to the file. Is there something easy built in to io? Or might I have to count the bytes before each write manually?","I noticed an ambiguity in your question. Do you want the file to be (a) over (b) under (c) exactly 1GiB large, before switching? It's easy to tell if you've gone over. tell() is sufficient for that kind of thing; just check if tell() > 1024*1024*1024: and you'll know. Checking if you're under 1GiB, but will go over 1GiB on your next write, is a similar technique. if len(data_to_write) + tell > 1024*1024*1024: will suffice. @@ -10081,11 +10079,25 @@ The trickiest thing to do is to get the file to exactly 1GiB. You will need to t Regardless of exactly which semantics you want, tell() is always going to be at least as slow as doing the counting yourself, and possibly slower. This doesn't mean that it's the wrong thing to do; if you're writing the file from a thread, then you almost certainly will want to tell() rather than hope that you've correctly preempted other threads writing to the same file. (And do your locks, etc., but that's another question.) By the way, I noticed a definite direction in your last couple questions. Are you aware of #twisted and #python IRC channels on Freenode (irc.freenode.net)? You will get timelier, more useful answers. ~ C.",0.0679224682270276,False,2,867 +2010-10-22 16:41:13.373,How to limit file size when writing one?,"I am using the output streams from the io module and writing to files. I want to be able to detect when I have written 1G of data to a file and then start writing to a second file. I can't seem to figure out how to determine how much data I have written to the file. +Is there something easy built in to io? Or might I have to count the bytes before each write manually?",See the tell() method on the stream object.,0.2012947653214861,False,2,867 2010-10-23 04:42:50.287,Getting the Tasks in a Google App Engine TaskQueue,"I know you can view the currently queued and running tasks in the Dashboard or development server console. However, is there any way to get that list programmatically? The docs only describe how to add tasks to the queue, but not how to list and/or cancel them. In python please.","A workaround, since they don't seem to support this yet, would be to model a Task datastore object. Create one on task queue add, update it when running, and delete it when your task fires. This can also be a nice way to get around the payload limits of the task queue api.",0.1352210990936997,False,1,868 2010-10-23 11:58:22.260,How to build a conceptual search engine?,"I would like to build an internal search engine (I have a very large collection of thousands of XML files) that is able to map queries to concepts. For example, if I search for ""big cats"", I would want highly ranked results to return documents with ""large cats"" as well. But I may also be interested in having it return ""huge animals"", albeit at a much lower relevancy score. I'm currently reading through the Natural Language Processing in Python book, and it seems WordNet has some word mappings that might prove useful, though I'm not sure how to integrate that into a search engine. Could I use Lucene to do this? How? From further research, it seems ""latent semantic analysis"" is relevant to what I'm looking for but I'm not sure how to implement it. +Any advice on how to get this done?","I'm not sure how to integrate that into a search engine. Could I use Lucene to do this? How? + +Step 1. Stop. +Step 2. Get something to work. +Step 3. By then, you'll understand more about Python and Lucene and other tools and ways you might integrate them. +Don't start by trying to solve integration problems. Software can always be integrated. That's what an Operating System does. It integrates software. Sometimes you want ""tighter"" integration, but that's never the first problem to solve. +The first problem to solve is to get your search or concept thing or whatever it is to work as a dumb-old command-line application. Or pair of applications knit together by passing files around or knit together with OS pipes or something. +Later, you can try and figure out how to make the user experience seamless. +But don't start with integration and don't stall because of integration questions. Set integration aside and get something to work.",1.2,True,3,869 +2010-10-23 11:58:22.260,How to build a conceptual search engine?,"I would like to build an internal search engine (I have a very large collection of thousands of XML files) that is able to map queries to concepts. For example, if I search for ""big cats"", I would want highly ranked results to return documents with ""large cats"" as well. But I may also be interested in having it return ""huge animals"", albeit at a much lower relevancy score. +I'm currently reading through the Natural Language Processing in Python book, and it seems WordNet has some word mappings that might prove useful, though I'm not sure how to integrate that into a search engine. Could I use Lucene to do this? How? +From further research, it seems ""latent semantic analysis"" is relevant to what I'm looking for but I'm not sure how to implement it. Any advice on how to get this done?","This is an incredibly hard problem and it can't be solved in a way that would always produce adequate results. I'd suggest to stick to some very simple principles instead so that the results are at least predictable. I think you need 2 things: some basic morphology engine plus a dictionary of synonyms. Whenever a search query arrives, for each word you @@ -10099,18 +10111,6 @@ As for concepts, such as cats are also animals - this is where it gets tricky. I 2010-10-23 11:58:22.260,How to build a conceptual search engine?,"I would like to build an internal search engine (I have a very large collection of thousands of XML files) that is able to map queries to concepts. For example, if I search for ""big cats"", I would want highly ranked results to return documents with ""large cats"" as well. But I may also be interested in having it return ""huge animals"", albeit at a much lower relevancy score. I'm currently reading through the Natural Language Processing in Python book, and it seems WordNet has some word mappings that might prove useful, though I'm not sure how to integrate that into a search engine. Could I use Lucene to do this? How? From further research, it seems ""latent semantic analysis"" is relevant to what I'm looking for but I'm not sure how to implement it. -Any advice on how to get this done?","I'm not sure how to integrate that into a search engine. Could I use Lucene to do this? How? - -Step 1. Stop. -Step 2. Get something to work. -Step 3. By then, you'll understand more about Python and Lucene and other tools and ways you might integrate them. -Don't start by trying to solve integration problems. Software can always be integrated. That's what an Operating System does. It integrates software. Sometimes you want ""tighter"" integration, but that's never the first problem to solve. -The first problem to solve is to get your search or concept thing or whatever it is to work as a dumb-old command-line application. Or pair of applications knit together by passing files around or knit together with OS pipes or something. -Later, you can try and figure out how to make the user experience seamless. -But don't start with integration and don't stall because of integration questions. Set integration aside and get something to work.",1.2,True,3,869 -2010-10-23 11:58:22.260,How to build a conceptual search engine?,"I would like to build an internal search engine (I have a very large collection of thousands of XML files) that is able to map queries to concepts. For example, if I search for ""big cats"", I would want highly ranked results to return documents with ""large cats"" as well. But I may also be interested in having it return ""huge animals"", albeit at a much lower relevancy score. -I'm currently reading through the Natural Language Processing in Python book, and it seems WordNet has some word mappings that might prove useful, though I'm not sure how to integrate that into a search engine. Could I use Lucene to do this? How? -From further research, it seems ""latent semantic analysis"" is relevant to what I'm looking for but I'm not sure how to implement it. Any advice on how to get this done?","First , write a piece of python code that will return you pineapple , orange , papaya when you input apple. By focusing on ""is"" relation of semantic network. Then continue with has a relationship and so on. I think at the end , you might get a fairly sufficient piece of code for a school project.",0.0,False,3,869 2010-10-23 18:02:59.153,Python Swig wrapper: how access underlying PyObject,"I've got class A wrapped with method foo implemented using %extend: @@ -10160,16 +10160,16 @@ Let's say I have some kind of dynamic content that users can add to via Ajax. Fo The question is, how do I implement the addition itself of the new content. For example, it looks like the ajax call which Stack Overflow uses to add a comment, simply returns html which replaces all of the comments (not just the new one). This way saves redundant logic in the Javascript code which has to ""know"" what the html looks like. Is this the best approach? If so, how best to implement it in Django so that there is no redundancy (i.e., so that the view doesn't have to know what the html looks like?) Thanks! -EDIT: In my specific case, there is no danger of other comments being added in the meantime - this is purely a question of the best implementation.","The reason to update all of the comments is to take in account other comments that other people may have also submitted in the meantime. to keep the site truly dynamic, you can do either that, or even, when the page is loaded, load up a variable with the newest submitted comment ID, and set a timer that goes back to check if there are more comments since then. if there are, return them as a JSON object and append them onto the current page a DIV at a time. That would be my preferred way to handle it, because you can then target actions based on each DIV's id or rel, which directly relates back to the comment's ID in the database...",0.1352210990936997,False,3,873 +EDIT: In my specific case, there is no danger of other comments being added in the meantime - this is purely a question of the best implementation.","I am not proficient neither with Django nor Python but I suppose the basic logic is similar for all server-side languages. +When weighing the pros and cons of either approach things depend on what you want to optimize. If bandwidth is important then obviously using pure JSON in communication reduces latency when compared to transmitting ready-made HTML. +However, duplicating the server-side view functionality to Javascript is a tedious and error-prone process. It simply takes a lot of time. +I personally feel that in most cases (for small and medium traffic sites) it's perfectly fine to put the HTML fragment together on server side and simply replace the contents of a container (e.g. contents of a div) inside an AJAX callback function. Of course, replacing the whole page would be silly, hence your Django application needs to support outputting specific regions of the document.",0.1352210990936997,False,3,873 2010-10-26 20:02:49.697,Loading New Content with Ajax,"This is a situation I've run into several times, not sure what the best approach is. Let's say I have some kind of dynamic content that users can add to via Ajax. For example, take Stack Overflow's comments - people can add comments directly on to the page using Ajax. The question is, how do I implement the addition itself of the new content. For example, it looks like the ajax call which Stack Overflow uses to add a comment, simply returns html which replaces all of the comments (not just the new one). This way saves redundant logic in the Javascript code which has to ""know"" what the html looks like. Is this the best approach? If so, how best to implement it in Django so that there is no redundancy (i.e., so that the view doesn't have to know what the html looks like?) Thanks! -EDIT: In my specific case, there is no danger of other comments being added in the meantime - this is purely a question of the best implementation.","I am not proficient neither with Django nor Python but I suppose the basic logic is similar for all server-side languages. -When weighing the pros and cons of either approach things depend on what you want to optimize. If bandwidth is important then obviously using pure JSON in communication reduces latency when compared to transmitting ready-made HTML. -However, duplicating the server-side view functionality to Javascript is a tedious and error-prone process. It simply takes a lot of time. -I personally feel that in most cases (for small and medium traffic sites) it's perfectly fine to put the HTML fragment together on server side and simply replace the contents of a container (e.g. contents of a div) inside an AJAX callback function. Of course, replacing the whole page would be silly, hence your Django application needs to support outputting specific regions of the document.",0.1352210990936997,False,3,873 +EDIT: In my specific case, there is no danger of other comments being added in the meantime - this is purely a question of the best implementation.","The reason to update all of the comments is to take in account other comments that other people may have also submitted in the meantime. to keep the site truly dynamic, you can do either that, or even, when the page is loaded, load up a variable with the newest submitted comment ID, and set a timer that goes back to check if there are more comments since then. if there are, return them as a JSON object and append them onto the current page a DIV at a time. That would be my preferred way to handle it, because you can then target actions based on each DIV's id or rel, which directly relates back to the comment's ID in the database...",0.1352210990936997,False,3,873 2010-10-26 20:02:49.697,Loading New Content with Ajax,"This is a situation I've run into several times, not sure what the best approach is. Let's say I have some kind of dynamic content that users can add to via Ajax. For example, take Stack Overflow's comments - people can add comments directly on to the page using Ajax. The question is, how do I implement the addition itself of the new content. For example, it looks like the ajax call which Stack Overflow uses to add a comment, simply returns html which replaces all of the comments (not just the new one). This way saves redundant logic in the Javascript code which has to ""know"" what the html looks like. @@ -10181,15 +10181,15 @@ EDIT: In my specific case, there is no danger of other comments being added in t Python features on Appcelerator Titanum are so limited (can't use some modules for example). My question is How can I use html & javascript as a GUI tool for a real python application ? I am running windows 7 and i was thinking of using webkit for that purpose but couldn't know how to work with it in python. -I am planning to make a standalone executable using py2exe as I don't know if the users always have python and the appropriate modules installed.","I assume you are mobilizing a web-application for cross platform access. -If so have you considered abstracting the cross platform access at the web-app presentation layer ? -Appcelerator / Webkit does not provide true native look-and-feel on mobile devices but this is where a new technology can help.",0.0,False,2,875 +I am planning to make a standalone executable using py2exe as I don't know if the users always have python and the appropriate modules installed.","If you are thinking about real desktop applications that are multi-threaded and/or use multiple system component - forget about JavaScript. That requires a very good SDK (like PyQt4), and not a basic wrapper like Appcelerator Titanium. Note that developing such applications takes a lot of time. +Second option is to drop the desktop binding and make a web application with an advanced frontend UI made with one of JavaScript frameworks & friends (Ember, Angular... up to things like dhtmlx and alike widgets). Those can't use system components (like access some hardware), but they can provide nice services.",0.0,False,2,875 2010-10-27 14:09:50.060,How can I use HTML + Javascript to build a python GUI?,"I have been experimenting with Appcelerator Titanum yesterday and I think it's cool when it comes to Javascript. Python features on Appcelerator Titanum are so limited (can't use some modules for example). My question is How can I use html & javascript as a GUI tool for a real python application ? I am running windows 7 and i was thinking of using webkit for that purpose but couldn't know how to work with it in python. -I am planning to make a standalone executable using py2exe as I don't know if the users always have python and the appropriate modules installed.","If you are thinking about real desktop applications that are multi-threaded and/or use multiple system component - forget about JavaScript. That requires a very good SDK (like PyQt4), and not a basic wrapper like Appcelerator Titanium. Note that developing such applications takes a lot of time. -Second option is to drop the desktop binding and make a web application with an advanced frontend UI made with one of JavaScript frameworks & friends (Ember, Angular... up to things like dhtmlx and alike widgets). Those can't use system components (like access some hardware), but they can provide nice services.",0.0,False,2,875 +I am planning to make a standalone executable using py2exe as I don't know if the users always have python and the appropriate modules installed.","I assume you are mobilizing a web-application for cross platform access. +If so have you considered abstracting the cross platform access at the web-app presentation layer ? +Appcelerator / Webkit does not provide true native look-and-feel on mobile devices but this is where a new technology can help.",0.0,False,2,875 2010-10-28 11:27:06.540,Defining Constants in Django,"I want to have some constants in a Django Projects. For example, let's say a constant called MIN_TIME_TEST. I would like to be able to access this constant in two places: from within my Python code, and from within any Templates. What's the best way to go about doing this? @@ -10245,32 +10245,6 @@ cond = ""if ( no is yes and no is no ) or ( no is yes and no is no )"" cond2 = ""if (yes is no or no is no )"" -First of all, is this the right approach? -Secondly, how do I validate above conditions if True or False ? -Thank You in advance.","Use Python's language services to parse and compile the string, then execute the resulting AST.",0.1352210990936997,False,2,879 -2010-10-30 16:53:57.167,python: how to validate userdefined condition?,"what I am struggling with is testing predefined conditions which takes user provided parameters like in example below: - -cond = ""if ( 1 is yes and 2 is no ) or ( 1 is yes and 2 is no )"" -cond2 = ""if (3 is no or 1 is no )"" -vars = [] - -lst = cond.split() -lst += cond2.split() - -for l in lst: - if l.isdigit(): - if l not in vars: - vars.append(l) -# ... sort -# ... read user answers => x = no, y = no, y = yes -# ... replace numbers with input (yes or no) - -# ... finally I have - -cond = ""if ( no is yes and no is no ) or ( no is yes and no is no )"" -cond2 = ""if (yes is no or no is no )"" - - First of all, is this the right approach? Secondly, how do I validate above conditions if True or False ? Thank You in advance.","so, after some reading based on Ignacio's tip, I think I have it after some string modifications. However, still not quite sure if this is the right approach. @@ -10298,6 +10272,32 @@ else: print ""Condition wasn't met"" Any thoughts or comments highly appreciated.",0.0,False,2,879 +2010-10-30 16:53:57.167,python: how to validate userdefined condition?,"what I am struggling with is testing predefined conditions which takes user provided parameters like in example below: + +cond = ""if ( 1 is yes and 2 is no ) or ( 1 is yes and 2 is no )"" +cond2 = ""if (3 is no or 1 is no )"" +vars = [] + +lst = cond.split() +lst += cond2.split() + +for l in lst: + if l.isdigit(): + if l not in vars: + vars.append(l) +# ... sort +# ... read user answers => x = no, y = no, y = yes +# ... replace numbers with input (yes or no) + +# ... finally I have + +cond = ""if ( no is yes and no is no ) or ( no is yes and no is no )"" +cond2 = ""if (yes is no or no is no )"" + + +First of all, is this the right approach? +Secondly, how do I validate above conditions if True or False ? +Thank You in advance.","Use Python's language services to parse and compile the string, then execute the resulting AST.",0.1352210990936997,False,2,879 2010-11-01 12:37:14.677,"Either Python, PyQT, QT, or Windows Vista is finding my dll, no matter what I rename it to. Is this normal?","I'm experimenting with PyQT, and I was trying to figure out how to get it to work with Firebird. I built the Firebird driver, but couldn't get it to work, so I was thinking maybe I wasn't putting it in the right place. So I tried experimenting with the SQLite driver, since PyQT came with it already installed, with working examples. I figured if I renamed all the qsqlite4.dll driver files I could find, eventually the example program would stop working when I renamed the one it was actually using. That didn't work. So I tried renaming the ""site-packages\pyqt4\plugins\sqldrivers"" folder to ""site-packages\pyqt4\plugins\sqldrivers-old"", and that did it. The example program stopped working. So I changed the folder name back, and tried renaming all the files in the folder. But the example program started working again. Then I moved the qsqlite4.dll file to a subdirectory, and it stopped working. So I moved it back, and renamed it to blah.blah.blah. And it worked again. Then I opened up blah.blah.blah with notepad++, and deleted some stuff at the top of the file, and that kept the example program from working. So I'm confused. As far as I can tell, either Python, PyQT, QT, or Windows Vista is finding the dll, no matter what I rename it to, as long as it's in the right folder. I even tried renaming it to the name of one of the other dll's, thinking maybe that would confuse it. But it only confused me. Is this normal? edit: I'm thinking this has something to do with plugins","Yes, Qt plugin infrastructure is a fairly simple and robust one. It attempts to load every file in sqldrivers directory. If it is successful, each dll then runs a function that registers all the features such a plugin supports. @@ -10331,11 +10331,11 @@ B. Override the draw method so it updates the on-screen coordinates of every spr I think A it's easier and cleaner.",0.0814518047658113,False,3,881 2010-11-02 08:49:57.407,How implement .NET server and Python client?,"I've got a problem. I Have a tool(threads manager) that receives some data and do some computation. I need to write Python client to send data to that tool...I thing I should use .NET Remoting, but how to do that? pls share some links where I can read or post some code...I can't google info about that... -P.S Python 2.7, NOT IronPython",".Net Remoting is designed for when you have .net at both ends so will be very hard to use from the Python end. (Event the XML encoding of .net remoting is not easy to use from other platforms) -I am assuming that Python has support for soap, if so I would look at using WCF at the .net end running over the “basic profile”. JSON is another option, there are lots of open source projects that add JSON support to .net, I assume that Python also has JSON surport.",1.2,True,2,882 +P.S Python 2.7, NOT IronPython","I would use XML-RPC for communication. It is very simple to implement (a couple lines of code in Python, not sure about .NET but it shouldn't be difficult there either) and should be enough in your scenario.",0.0,False,2,882 2010-11-02 08:49:57.407,How implement .NET server and Python client?,"I've got a problem. I Have a tool(threads manager) that receives some data and do some computation. I need to write Python client to send data to that tool...I thing I should use .NET Remoting, but how to do that? pls share some links where I can read or post some code...I can't google info about that... -P.S Python 2.7, NOT IronPython","I would use XML-RPC for communication. It is very simple to implement (a couple lines of code in Python, not sure about .NET but it shouldn't be difficult there either) and should be enough in your scenario.",0.0,False,2,882 +P.S Python 2.7, NOT IronPython",".Net Remoting is designed for when you have .net at both ends so will be very hard to use from the Python end. (Event the XML encoding of .net remoting is not easy to use from other platforms) +I am assuming that Python has support for soap, if so I would look at using WCF at the .net end running over the “basic profile”. JSON is another option, there are lots of open source projects that add JSON support to .net, I assume that Python also has JSON surport.",1.2,True,2,882 2010-11-02 11:52:42.017,regression test dealing with hard coded path,"I need to extend a python code which has plenty of hard coded path In 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) But because of hard coded system path, I shall run my test inside a chroot tree (I don't want to pollute my system dir) @@ -10367,13 +10367,13 @@ Perhaps a book could work as well. Basically, I'm just trying to find a way to l Any suggestions?","IMHO your time would be better invested learning something like Django, because much of what you could improve in a micro framework is already builtin on a bigger framework.",0.0,False,1,885 2010-11-03 11:44:32.623,Portable Python (Mac -> Windows),"I have a lovely Macbook now, and I'm enjoying coding on the move. I'm also enjoying coding in Python. However, I'd like to distribute the end result to friends using Windows, as an executable. I know that Py2Exe does this, but I don't know how portable Python is across operating systems. Can anyone offer any advice? I'm using PyGame too. -Many thanks","The Python scripts are reasonably portable, as long as the interpreter and relevant libraries are installed. Generated .exe and .app files are not.",0.296905446847765,False,3,886 -2010-11-03 11:44:32.623,Portable Python (Mac -> Windows),"I have a lovely Macbook now, and I'm enjoying coding on the move. I'm also enjoying coding in Python. However, I'd like to distribute the end result to friends using Windows, as an executable. -I know that Py2Exe does this, but I don't know how portable Python is across operating systems. Can anyone offer any advice? I'm using PyGame too. Many thanks","If you are planning to include Linux in your portability criteria, it's worth remembering that many distributions still package 2.6 (or even 2.5), and will probably be a version behind in the 3.x series as well (I'm assuming your using 2.x given the PyGame requirement though). Versions of PyGame seem to vary quite heavily between distros as well.",0.0,False,3,886 2010-11-03 11:44:32.623,Portable Python (Mac -> Windows),"I have a lovely Macbook now, and I'm enjoying coding on the move. I'm also enjoying coding in Python. However, I'd like to distribute the end result to friends using Windows, as an executable. I know that Py2Exe does this, but I don't know how portable Python is across operating systems. Can anyone offer any advice? I'm using PyGame too. +Many thanks","The Python scripts are reasonably portable, as long as the interpreter and relevant libraries are installed. Generated .exe and .app files are not.",0.296905446847765,False,3,886 +2010-11-03 11:44:32.623,Portable Python (Mac -> Windows),"I have a lovely Macbook now, and I'm enjoying coding on the move. I'm also enjoying coding in Python. However, I'd like to distribute the end result to friends using Windows, as an executable. +I know that Py2Exe does this, but I don't know how portable Python is across operating systems. Can anyone offer any advice? I'm using PyGame too. Many thanks","Personally I experienced huge difficult with all the Exe builder, py2exe , cx_freeze etc. Bugs and errors all the time , keep displaying an issue with atexit module. I find just by including the python distro way more convinient. There is one more advantage beside ease of use. Each time you build an EXE for a python app, what you essential do is include the core of the python installation but only with the modules your app is using. But even in that case your app may increase from a mere few Kbs that the a python module is to more than 15 mbs because of the inclusion of python installation. @@ -10386,14 +10386,14 @@ It works fine, except that if one were to run the program from the Python comman Do you know a way of getting the .write() function to write a file to a specific location on the disc (e.g. C:\Users\User\Desktop)? Extra cool-points if you know how to open a file browser window.","I'll admit I don't know Python 3, so I may be wrong, but in Python 2, you can just check the __file__ variable in your module to get the name of the file it was loaded from. Just create your file in that same directory (preferably using os.path.dirname and os.path.join to remain platform-independent).",0.0,False,1,887 2010-11-04 04:07:44.283,How do I add widgets to a file dialog in wxpython?,"I'm creating a file dialog that allows the user to save a file after editing it in my app. I want to add a checkbox to the dialog so the user can make some choices about what format the file is saved in. I think I need to make some new class that inherits from FileDialog and inserts a checkbox into the frame created by the filedialog, but I don't really know how to do that. Can anyone help me out? -(I also want to create an analogous file dialog for opening a file, but I assume that will just mean replacing the SAVE style with the OPEN style.)","In wxWidgets 2.9 custom controls can be added to file dialogs using wxFileDialog::SetExtraControlCreator(). It's implemented for GTK, MSW and generic dialogs. -Alternatively, you may use the wxFileCtrl class. It has native implementation only in wxGTK. -I don't know if these features is available from Python wrappers, though.",0.2012947653214861,False,2,888 -2010-11-04 04:07:44.283,How do I add widgets to a file dialog in wxpython?,"I'm creating a file dialog that allows the user to save a file after editing it in my app. I want to add a checkbox to the dialog so the user can make some choices about what format the file is saved in. I think I need to make some new class that inherits from FileDialog and inserts a checkbox into the frame created by the filedialog, but I don't really know how to do that. Can anyone help me out? (I also want to create an analogous file dialog for opening a file, but I assume that will just mean replacing the SAVE style with the OPEN style.)","I have to disagree with the sentiment that you should use standard dialogs only how they were designed. I take another view and would rather look at using subclassing the way that subclassing was intended. And to me, it is to add additional functionality/specialization to a class. So it is not changing the behavior of the standard dialog. It is creating a new dialog BASED ON the standard dialog with a little additional functionality. In my case, I want to add two buttons to the wx.MultiChoiceDialog to provide a Select All and/or Unselect All functions.",0.2012947653214861,False,2,888 +2010-11-04 04:07:44.283,How do I add widgets to a file dialog in wxpython?,"I'm creating a file dialog that allows the user to save a file after editing it in my app. I want to add a checkbox to the dialog so the user can make some choices about what format the file is saved in. I think I need to make some new class that inherits from FileDialog and inserts a checkbox into the frame created by the filedialog, but I don't really know how to do that. Can anyone help me out? +(I also want to create an analogous file dialog for opening a file, but I assume that will just mean replacing the SAVE style with the OPEN style.)","In wxWidgets 2.9 custom controls can be added to file dialogs using wxFileDialog::SetExtraControlCreator(). It's implemented for GTK, MSW and generic dialogs. +Alternatively, you may use the wxFileCtrl class. It has native implementation only in wxGTK. +I don't know if these features is available from Python wrappers, though.",0.2012947653214861,False,2,888 2010-11-04 10:55:24.267,python: how to make threads wait for specific response?,"could anyone please provide on how to achieve below scenario ? 2 queues - destination queue, response queue thread picks task up from destination queue @@ -10446,10 +10446,10 @@ This is just a personal project to get to understand Python better. I thought th Instead, the registering process creates a _meta object on the model with all the data needed for the admin and ORM. You can see the ModelBase metaclass in django/db/models/base.py, as you can see in the __new__ function it walks through all the fields to add them to the _meta object. The _meta object itself is generated dynamically using the Meta class definition on the model. You can see the result with print SomeModel._meta or print SomeModel._meta.fields",1.2,True,1,894 2010-11-05 23:48:15.580,"Python/Tkinter: Building a toolbar that provides edit cut, copy, paste commands","I'm looking for suggestions on how one might implement a toolbar that provides edit cut, copy, paste commands using the Tkinter framework. I understand how to build a toolbar and bind the toolbar commands, but I'm confused over how the toolbar button bound commands will know which widget to apply the cut, copy, or paste action because the widget with edit activity will lose focus when the toolbar button is clicked. My first thought was to have each widget with potential edit activity set a global variable when the widget gains focus and have other widgets (without edit activity, eg. buttons, sliders, checkbox/radiobox, etc) clear this global variable. But this sounds complicated to maintain unless I build a framework of widgets that inherit this behavior. +Is there a simpler way to go about this or am I on the right track?","You can tell the toolbar buttons to not take the focus; it's a configuration option and no UI guidelines I've ever seen have had toolbar buttons with focus. (Instead, the functionality is always available through some other keyboard-activatable mechanism, e.g., a hotkey combo.)",1.2,True,2,895 +2010-11-05 23:48:15.580,"Python/Tkinter: Building a toolbar that provides edit cut, copy, paste commands","I'm looking for suggestions on how one might implement a toolbar that provides edit cut, copy, paste commands using the Tkinter framework. I understand how to build a toolbar and bind the toolbar commands, but I'm confused over how the toolbar button bound commands will know which widget to apply the cut, copy, or paste action because the widget with edit activity will lose focus when the toolbar button is clicked. My first thought was to have each widget with potential edit activity set a global variable when the widget gains focus and have other widgets (without edit activity, eg. buttons, sliders, checkbox/radiobox, etc) clear this global variable. But this sounds complicated to maintain unless I build a framework of widgets that inherit this behavior. Is there a simpler way to go about this or am I on the right track?","You don't have to maintain a big framework, you can create a single binding on the root widget for and put all the logic in that binding. Or, use focus_class and bind to the class all. Binding on the root will only affect children of the root, binding to all will affect all widgets in the entire app. That only matters if you have more than one toplevel widget.",0.3869120172231254,False,2,895 -2010-11-05 23:48:15.580,"Python/Tkinter: Building a toolbar that provides edit cut, copy, paste commands","I'm looking for suggestions on how one might implement a toolbar that provides edit cut, copy, paste commands using the Tkinter framework. I understand how to build a toolbar and bind the toolbar commands, but I'm confused over how the toolbar button bound commands will know which widget to apply the cut, copy, or paste action because the widget with edit activity will lose focus when the toolbar button is clicked. My first thought was to have each widget with potential edit activity set a global variable when the widget gains focus and have other widgets (without edit activity, eg. buttons, sliders, checkbox/radiobox, etc) clear this global variable. But this sounds complicated to maintain unless I build a framework of widgets that inherit this behavior. -Is there a simpler way to go about this or am I on the right track?","You can tell the toolbar buttons to not take the focus; it's a configuration option and no UI guidelines I've ever seen have had toolbar buttons with focus. (Instead, the functionality is always available through some other keyboard-activatable mechanism, e.g., a hotkey combo.)",1.2,True,2,895 2010-11-06 20:34:00.770,python threading and shared variables,"how can i update a shared variable between different threading.Thread in python? lets say that i have 5 threads working down a Queue.Queue(). after the queue is done i want to do an other operation but i want it to happen only once. is it possible to share and update a variable betweeen the threads. so when Queue.empty() is True this event gets fired but if one of the threads is doing it i dont want the others to do do that too because i would get wrong results. @@ -10507,7 +10507,8 @@ i also tried to empty the set but it doesnt work. while 1: line = raw_input('type \'q\' to stop filewatcher... or \'qq\' to force quit...\n').strip() -this is what i was trying basically. but of course the part of queue.empty() gets exectued as many times as threads i have.",Why can't you just add the final step to the queue ?,0.0,False,2,896 +this is what i was trying basically. but of course the part of queue.empty() gets exectued as many times as threads i have.","Have another queue where you place this event after first queue is empty. +Or have special thread for this event.",0.0,False,2,896 2010-11-06 20:34:00.770,python threading and shared variables,"how can i update a shared variable between different threading.Thread in python? lets say that i have 5 threads working down a Queue.Queue(). after the queue is done i want to do an other operation but i want it to happen only once. is it possible to share and update a variable betweeen the threads. so when Queue.empty() is True this event gets fired but if one of the threads is doing it i dont want the others to do do that too because i would get wrong results. @@ -10565,8 +10566,7 @@ i also tried to empty the set but it doesnt work. while 1: line = raw_input('type \'q\' to stop filewatcher... or \'qq\' to force quit...\n').strip() -this is what i was trying basically. but of course the part of queue.empty() gets exectued as many times as threads i have.","Have another queue where you place this event after first queue is empty. -Or have special thread for this event.",0.0,False,2,896 +this is what i was trying basically. but of course the part of queue.empty() gets exectued as many times as threads i have.",Why can't you just add the final step to the queue ?,0.0,False,2,896 2010-11-08 17:19:47.970,How to upload zope site on my ftp?,"Hey, I'd like to know how to upload my zope site on my ftp. I have a domain, and I like to upload it, like a upload normal files on my ftp. Thanks.","You can upload zope the same way you would upload anything else, but it's not suitable for deploying on many shared webhosts as many of them would not like you running the zope process due to the ammount of resources it can consume You are best off trying to find a webhost that supports zope or to use a VPS",1.2,True,1,897 @@ -10623,18 +10623,18 @@ So, I want to be able to know how many memory was used by python before I loaded Also I wondering, if it is some way to check memory usage of complex object. Let say i have nested dictionary with different types of data inside. How can i know how many memory used by all data in this dictionary. Thanks, -Alex","As far as I know there is no easy way to see what the memory consumption of a certain object is. It would be a non-trivial thing to do because references could be shared among objects. -Here are my two favourite workarounds: - -Use the process manager. Have the program pause for before allocation. Write down the memory used before allocation. Allocate. Write down memory after allocation. It's a low-tech method but it works. -Alternatively you can use pickle.dump to serialize your data structure. The resulting pickle will be comparable (not identical!) in size to the space needed to store the data structure in memory. For better results, use the binary pickle protocol.",0.4701041941942874,False,2,902 +Alex",An alternative is that you could use windows's performance counters through pywin32,0.0,False,2,902 2010-11-11 14:00:37.690,How to find total amount of memory used by python process/object in windows,"I have some script that loads a lot of data to memory. I want to know how efficient the data stored in memory. So, I want to be able to know how many memory was used by python before I loaded data, and after I loaded data. Also I wondering, if it is some way to check memory usage of complex object. Let say i have nested dictionary with different types of data inside. How can i know how many memory used by all data in this dictionary. Thanks, -Alex",An alternative is that you could use windows's performance counters through pywin32,0.0,False,2,902 +Alex","As far as I know there is no easy way to see what the memory consumption of a certain object is. It would be a non-trivial thing to do because references could be shared among objects. +Here are my two favourite workarounds: + +Use the process manager. Have the program pause for before allocation. Write down the memory used before allocation. Allocate. Write down memory after allocation. It's a low-tech method but it works. +Alternatively you can use pickle.dump to serialize your data structure. The resulting pickle will be comparable (not identical!) in size to the space needed to store the data structure in memory. For better results, use the binary pickle protocol.",0.4701041941942874,False,2,902 2010-11-11 19:19:27.727,more than 9 subplots in matplotlib,"Is it possible to get more than 9 subplots in matplotlib? I am on the subplots command pylab.subplot(449); how can I get a 4410 to work? Thank you very much.","It was easier than I expected, I just did: pylab.subplot(4,4,10) and it worked.",1.2,True,1,903 @@ -10719,9 +10719,9 @@ And if it does work, how can I make it work on my machine? What am I doing wrong Thanks in advance.",My guess is that you installed it for 2.6 and so it is residing in 2.6's library directory. Install it in 2.7's library directory and you should be good to go. I don't know OSX so I can't help with the details but a little bit of googling shouldn't be too hard. The problem is that the two python installations have distinct import paths.,1.2,True,1,914 2010-11-17 04:46:37.963,Is it good form to have an __init__ method that checks the type of its input?,I have a class that wants to be initialized from a few possible inputs. However a combination of no function overloading and my relative inexperience with the language makes me unsure of how to proceed. Any advice?,"No, don't check for types explicitly. Python is a duck typed language. If the wrong type is passed, a TypeError will be raised. That's it. You need not bother about the type, that is the responsibility of the programmer.",0.1016881243684853,False,1,915 2010-11-17 07:34:03.270,how do run syncdb without loading fixtures?,"is there a way to run syncdb without loading fixtures? -xo","best to name your fixtures something_else.json, then run syncdb (and migrate if needed), followed by manage.py loaddata something_else.json",0.0,False,2,916 -2010-11-17 07:34:03.270,how do run syncdb without loading fixtures?,"is there a way to run syncdb without loading fixtures? xo",Rename the fixture to something else than initial_data,1.2,True,2,916 +2010-11-17 07:34:03.270,how do run syncdb without loading fixtures?,"is there a way to run syncdb without loading fixtures? +xo","best to name your fixtures something_else.json, then run syncdb (and migrate if needed), followed by manage.py loaddata something_else.json",0.0,False,2,916 2010-11-18 08:29:04.310,When and how to use Tornado? When is it useless?,"Ok, Tornado is non-blocking and quite fast and it can handle a lot of standing requests easily. But I guess it's not a silver bullet and if we just blindly run Django-based or any other site with Tornado it won't give any performance boost. I couldn't find comprehensive explanation of this, so I'm asking it here: @@ -10763,6 +10763,14 @@ Is there a convention about how to do this? Is there a variable that can tell me Thank you for your time.","Use a command line option that only cron will use. Or 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.",0.3869120172231254,False,1,918 2010-11-18 12:44:24.473,"An example using python bindings for SVM library, LIBSVM","I am in dire need of a classification task example using LibSVM in python. I don't know how the Input should look like and which function is responsible for training and which one for testing +Thanks","Adding to @shinNoNoir : +param.kernel_type represents the type of kernel function you want to use, +0: Linear +1: polynomial +2: RBF +3: Sigmoid +Also have in mind that, svm_problem(y,x) : here y is the class labels and x is the class instances and x and y can only be lists,tuples and dictionaries.(no numpy array)",0.1518770276964961,False,2,919 +2010-11-18 12:44:24.473,"An example using python bindings for SVM library, LIBSVM","I am in dire need of a classification task example using LibSVM in python. I don't know how the Input should look like and which function is responsible for training and which one for testing Thanks","LIBSVM reads the data from a tuple containing two lists. The first list contains the classes and the second list contains the input data. create simple dataset with two possible classes you also need to specify which kernel you want to use by creating svm_parameter. @@ -10774,25 +10782,17 @@ you also need to specify which kernel you want to use by creating svm_parameter. >> m = svm_model(prob, param) #testing the model >> m.predict([1, 1, 1])",1.2,True,2,919 -2010-11-18 12:44:24.473,"An example using python bindings for SVM library, LIBSVM","I am in dire need of a classification task example using LibSVM in python. I don't know how the Input should look like and which function is responsible for training and which one for testing -Thanks","Adding to @shinNoNoir : -param.kernel_type represents the type of kernel function you want to use, -0: Linear -1: polynomial -2: RBF -3: Sigmoid -Also have in mind that, svm_problem(y,x) : here y is the class labels and x is the class instances and x and y can only be lists,tuples and dictionaries.(no numpy array)",0.1518770276964961,False,2,919 -2010-11-18 16:16:19.927,"Tried to embed python in a visual studio 2010 c++ file, exits with code 1","I am trying to embed some python code in a c++ application i am developing with ms visual studio c++ 2010. But when i run the program, it exits with code 0x01 when i call Py_initialize(). -I dont know how to find out what went wrong. the help file says, Py_Initialize can't return an error value, it only fails fataly. -But, why did it fail? -I am using a self-compiled python27_d.dll, which i created with the msvs project files in the source downloads from python.org.","Is there simple 'hello world' type example of the Py_Initilize code in the python sdk you can start with? -That will at least tell you if you have the compiler environment setup correctly, or if the error is in your usage.",0.0,False,2,920 2010-11-18 16:16:19.927,"Tried to embed python in a visual studio 2010 c++ file, exits with code 1","I am trying to embed some python code in a c++ application i am developing with ms visual studio c++ 2010. But when i run the program, it exits with code 0x01 when i call Py_initialize(). I dont know how to find out what went wrong. the help file says, Py_Initialize can't return an error value, it only fails fataly. But, why did it fail? I am using a self-compiled python27_d.dll, which i created with the msvs project files in the source downloads from python.org.","Well, i finally found out what went wrong. I did compile my python27_d.dll with the same VC10 as my program itself. But my program is normally compiled as 64 bit executable. I just forgot to compile the dll for x64, too. I didnt think this would lead to such annoying behavoiur, as i believed i would get a linkr error then.",1.2,True,2,920 +2010-11-18 16:16:19.927,"Tried to embed python in a visual studio 2010 c++ file, exits with code 1","I am trying to embed some python code in a c++ application i am developing with ms visual studio c++ 2010. But when i run the program, it exits with code 0x01 when i call Py_initialize(). +I dont know how to find out what went wrong. the help file says, Py_Initialize can't return an error value, it only fails fataly. +But, why did it fail? +I am using a self-compiled python27_d.dll, which i created with the msvs project files in the source downloads from python.org.","Is there simple 'hello world' type example of the Py_Initilize code in the python sdk you can start with? +That will at least tell you if you have the compiler environment setup correctly, or if the error is in your usage.",0.0,False,2,920 2010-11-19 19:43:43.893,Python: Test if an argument is an integer,"I want to write a python script that takes 3 parameters. The first parameter is a string, the second is an integer, and the third is also an integer. I want to put conditional checks at the start to ensure that the proper number of arguments are provided, and they are the right type before proceeding. I know we can use sys.argv to get the argument list, but I don't know how to test that a parameter is an integer before assigning it to my local variable for use. @@ -10851,10 +10851,10 @@ Some widgets have takefocus option. Set takefocus to 0 to take your widget out o 2010-11-28 22:15:04.157,In Tkinter how do i remove focus from a widget?,I'd like to remove focus from a widget manually.,My solution is root.focus() it will remove widget focus.,0.1352210990936997,False,2,930 2010-11-29 12:49:31.810,"3d game with Python, starting from nothing","So we want to program a 3d game for school, we can probably use blender for the 3d models, however we are totally clueless as to how to use them in a game/application. Are there any recommended guides/documents we should read on general 3d game programming and perhaps python specific stuff. -We are also possibly considering programming it in C++ but for now I think it's easier to use Python as we can fully focus on the 3d mechanics that way.","If you want to write a 3D game you might want to start by understanding the basics of programming and computer science. Starting with the top and learning a language, then find yourself a good graphics library for example Panda, Pygame are all good choices, then there are other parts to consider like networking with twisted for example or a physics engine. It might also be a good choice to consider using a working engine like the unreal engine as often game designers get too wrapped up in game mechanics and not the game itself",0.1016881243684853,False,3,931 +We are also possibly considering programming it in C++ but for now I think it's easier to use Python as we can fully focus on the 3d mechanics that way.","I would implement the time-critical stuff as 3D and its object handling + rendering in raw C/C++ and let an embedded Python with external modules handle the game logic (object movement, object properties, scripting and so on).",0.0,False,3,931 2010-11-29 12:49:31.810,"3d game with Python, starting from nothing","So we want to program a 3d game for school, we can probably use blender for the 3d models, however we are totally clueless as to how to use them in a game/application. Are there any recommended guides/documents we should read on general 3d game programming and perhaps python specific stuff. -We are also possibly considering programming it in C++ but for now I think it's easier to use Python as we can fully focus on the 3d mechanics that way.","I would implement the time-critical stuff as 3D and its object handling + rendering in raw C/C++ and let an embedded Python with external modules handle the game logic (object movement, object properties, scripting and so on).",0.0,False,3,931 +We are also possibly considering programming it in C++ but for now I think it's easier to use Python as we can fully focus on the 3d mechanics that way.","If you want to write a 3D game you might want to start by understanding the basics of programming and computer science. Starting with the top and learning a language, then find yourself a good graphics library for example Panda, Pygame are all good choices, then there are other parts to consider like networking with twisted for example or a physics engine. It might also be a good choice to consider using a working engine like the unreal engine as often game designers get too wrapped up in game mechanics and not the game itself",0.1016881243684853,False,3,931 2010-11-29 12:49:31.810,"3d game with Python, starting from nothing","So we want to program a 3d game for school, we can probably use blender for the 3d models, however we are totally clueless as to how to use them in a game/application. Are there any recommended guides/documents we should read on general 3d game programming and perhaps python specific stuff. We are also possibly considering programming it in C++ but for now I think it's easier to use Python as we can fully focus on the 3d mechanics that way.","You should be aware that 3D game consists of @@ -10961,13 +10961,13 @@ I'm writing code where I need to use complex data structures like dictionaries o The issue is that when I must use these objects I barely remember their structure and so how to access them. This makes it difficult to resume working on code that was untouched for days. A very poor solution is to use comments for each variable, but that's very inflexible. -So, given that python variables are just pointers to memory and they cannot be statically type-declared, is there any convention or rule that I could follow to ease complex data structures usage?","I believe you should take a good look some of your complex structures, what you are doing with them, and ask... Is This Pythonic? Ask here on SO. I think you will find some cases where the complexity is an artifact of C/C++.",0.1016881243684853,False,2,939 +So, given that python variables are just pointers to memory and they cannot be statically type-declared, is there any convention or rule that I could follow to ease complex data structures usage?","Include an example somewhere in your code, or in your tests.",0.0,False,2,939 2010-12-02 17:11:11.110,Declaring types for complex data structures in python,"I am quite new to python programming (C/C++ background). I'm writing code where I need to use complex data structures like dictionaries of dictionaries of lists. The issue is that when I must use these objects I barely remember their structure and so how to access them. This makes it difficult to resume working on code that was untouched for days. A very poor solution is to use comments for each variable, but that's very inflexible. -So, given that python variables are just pointers to memory and they cannot be statically type-declared, is there any convention or rule that I could follow to ease complex data structures usage?","Include an example somewhere in your code, or in your tests.",0.0,False,2,939 +So, given that python variables are just pointers to memory and they cannot be statically type-declared, is there any convention or rule that I could follow to ease complex data structures usage?","I believe you should take a good look some of your complex structures, what you are doing with them, and ask... Is This Pythonic? Ask here on SO. I think you will find some cases where the complexity is an artifact of C/C++.",0.1016881243684853,False,2,939 2010-12-02 20:53:52.887,ARP missing from the module scapy,"i am trying to use scapy in python while i try to import the scapy import scapy its just fine but the line scapy.ARP() causes a @@ -11045,30 +11045,30 @@ which is the esaist way to create a user interface ? thanks","Django auth also provide generic views for login/logout etc. You can use build-in templates or expand it. See in documentation for generic views: django.contrib.auth.views.login, django.contrib.auth.views.logout",0.2012947653214861,False,1,946 2010-12-06 03:20:41.123,Why don't django templates just use python code?,"I mean I understand that these templates are aimed at designers and other less code-savvy people, but for developers I feel the template language is just a hassle. I need to re-learn how to do very simple things like iterate through dictionaries or lists that I pass into the template, and it doesn't even seem to work very well. I'm still having trouble getting the whole ""dot"" notation working as I would expect (for example, {{mydict.dictkey}} inside a for loop doesn't work :S -- I might ask this as a separate question), and I don't see why it wouldn't be possible to just use python code in a template system. In particular, I feel that if templates are meant to be simple, then the level of python code that would need to be employed in these templates would be of a caliber not more complicated than the current templating language. So these designer peeps wouldn't have more trouble learning that much python than they would learning the Django template language (and there's more places you can go with this knowledge of basic python as opposed to DTL) And the added advantage would be that people who already know python would be in familiar territory with all the usual syntax and power available to them and can just get going. -Am I missing something? If so I plead django noob and would love for you to enlighten me on the many merits of the current system. But otherwise, any recommendations on other template systems that may be more what I'm looking for?","Seperation of concerns. -Designer does design. Developer does development. Templates are written by the designers. -Design and development are independent and different areas of work typically handled by different people. -I guess having template code in python would work very well if one is a developer and their spouse is a designer. Otherwise, let each do his job, with least interference.",0.1016881243684853,False,3,947 +Am I missing something? If so I plead django noob and would love for you to enlighten me on the many merits of the current system. But otherwise, any recommendations on other template systems that may be more what I'm looking for?","Don't forget that you aren't limited to Django's template language. You're free to use whatever templating system you like in your view functions. However you want to create the HTML to return from your view function is fine. There are many templating implementations in the Python world: choose one that suits you better, and use it.",0.2012947653214861,False,3,947 2010-12-06 03:20:41.123,Why don't django templates just use python code?,"I mean I understand that these templates are aimed at designers and other less code-savvy people, but for developers I feel the template language is just a hassle. I need to re-learn how to do very simple things like iterate through dictionaries or lists that I pass into the template, and it doesn't even seem to work very well. I'm still having trouble getting the whole ""dot"" notation working as I would expect (for example, {{mydict.dictkey}} inside a for loop doesn't work :S -- I might ask this as a separate question), and I don't see why it wouldn't be possible to just use python code in a template system. In particular, I feel that if templates are meant to be simple, then the level of python code that would need to be employed in these templates would be of a caliber not more complicated than the current templating language. So these designer peeps wouldn't have more trouble learning that much python than they would learning the Django template language (and there's more places you can go with this knowledge of basic python as opposed to DTL) And the added advantage would be that people who already know python would be in familiar territory with all the usual syntax and power available to them and can just get going. Am I missing something? If so I plead django noob and would love for you to enlighten me on the many merits of the current system. But otherwise, any recommendations on other template systems that may be more what I'm looking for?","Django templates don’t just use Python code for the same reason Django uses the MVC paradigm:     No particular reason.     (ie: The same reason anyone utilizes MVC at all, and that reason is just that certain people prefer this rigid philosophical pattern.) In general I’d suggest you avoid Django if you don’t like things like this, because the Django people won’t be changing this approach. You could also, however, do something silly (in that it’d be contradictory to the philosophy of the chosen software), like put all the markup and anything else you can into the ""view"" files, turning Django from its ""MVC"" (or ""MTV"" ) paradigm into roughly what everything else is (a boring but straightforward lump).",0.1016881243684853,False,3,947 2010-12-06 03:20:41.123,Why don't django templates just use python code?,"I mean I understand that these templates are aimed at designers and other less code-savvy people, but for developers I feel the template language is just a hassle. I need to re-learn how to do very simple things like iterate through dictionaries or lists that I pass into the template, and it doesn't even seem to work very well. I'm still having trouble getting the whole ""dot"" notation working as I would expect (for example, {{mydict.dictkey}} inside a for loop doesn't work :S -- I might ask this as a separate question), and I don't see why it wouldn't be possible to just use python code in a template system. In particular, I feel that if templates are meant to be simple, then the level of python code that would need to be employed in these templates would be of a caliber not more complicated than the current templating language. So these designer peeps wouldn't have more trouble learning that much python than they would learning the Django template language (and there's more places you can go with this knowledge of basic python as opposed to DTL) And the added advantage would be that people who already know python would be in familiar territory with all the usual syntax and power available to them and can just get going. -Am I missing something? If so I plead django noob and would love for you to enlighten me on the many merits of the current system. But otherwise, any recommendations on other template systems that may be more what I'm looking for?","Don't forget that you aren't limited to Django's template language. You're free to use whatever templating system you like in your view functions. However you want to create the HTML to return from your view function is fine. There are many templating implementations in the Python world: choose one that suits you better, and use it.",0.2012947653214861,False,3,947 +Am I missing something? If so I plead django noob and would love for you to enlighten me on the many merits of the current system. But otherwise, any recommendations on other template systems that may be more what I'm looking for?","Seperation of concerns. +Designer does design. Developer does development. Templates are written by the designers. +Design and development are independent and different areas of work typically handled by different people. +I guess having template code in python would work very well if one is a developer and their spouse is a designer. Otherwise, let each do his job, with least interference.",0.1016881243684853,False,3,947 2010-12-07 16:42:51.677,Download Manager: How to re-construct chunks fetched by multiple connections,"so i am developing my own download manager for educational purpose. I have multiple connections/threads downloading a file, each connection works on a particular range of the file. Now after they have all fetched their chunks, i dont exact know how to i bring this chunks together to re-make the original file. What i did: First, i created a temporary file in 'wb' mode, and allowed each connections/threads to dump their chunks. But everytime a connection does this, it overwrites previously saved chunks. I figured this was because i used the 'wb' file descriptor. I changed it to 'ab', but i can no longer perform seek() operations What i am looking for: I need an elegant way of re-packaging this chunk to the original file. I would like to know how other download managers do it. -Thank in advance.","You were doing it just fine: seek() and write(). That should work! -Now, if you want a cleaner structure, without so many threads moving their hands all over a file, you might want to consider having downloader threads and a disk-writing thread. This last one may just sleep until woken by one of the others, write some kb to disk, and go back to sleep.",1.2,True,2,948 +Thank in advance.","You need to write chunks it different temporary files and then join them in the original order. If you open one file for all the threads, you should make the access to it sequential to preserve to correct order of data, which discards thread usage since a thread should wait for the previous one. BTW, you should open files in wb mode.",0.3869120172231254,False,2,948 2010-12-07 16:42:51.677,Download Manager: How to re-construct chunks fetched by multiple connections,"so i am developing my own download manager for educational purpose. I have multiple connections/threads downloading a file, each connection works on a particular range of the file. Now after they have all fetched their chunks, i dont exact know how to i bring this chunks together to re-make the original file. What i did: First, i created a temporary file in 'wb' mode, and allowed each connections/threads to dump their chunks. But everytime a connection does this, it overwrites previously saved chunks. I figured this was because i used the 'wb' file descriptor. I changed it to 'ab', but i can no longer perform seek() operations What i am looking for: I need an elegant way of re-packaging this chunk to the original file. I would like to know how other download managers do it. -Thank in advance.","You need to write chunks it different temporary files and then join them in the original order. If you open one file for all the threads, you should make the access to it sequential to preserve to correct order of data, which discards thread usage since a thread should wait for the previous one. BTW, you should open files in wb mode.",0.3869120172231254,False,2,948 +Thank in advance.","You were doing it just fine: seek() and write(). That should work! +Now, if you want a cleaner structure, without so many threads moving their hands all over a file, you might want to consider having downloader threads and a disk-writing thread. This last one may just sleep until woken by one of the others, write some kb to disk, and go back to sleep.",1.2,True,2,948 2010-12-07 16:46:51.507,how to bring a background task to foreground in google app engine?,"Currently I have tasks running in background. After the tasks are done executing I need to show output. How do I do this in Google App Engine? Once the tasks are done the only thing I can do is create another task which is supposed to show output or is there any other way?","This won't work directly as you describe it. Once a background task is started, it's a background task for its entire existence. If you want to return some information from the background task to the user, you'll have to add it to the datastore, and have a foreground handler check the datastore for that information. @@ -11085,10 +11085,6 @@ A text editor that allows editing within the graphical diff view would be really 2010-12-09 19:58:46.997,How do you avoid leaving debugger print/pdb statements in python open source apps when you're debugging them and just finish?,"Sometimes when developing using open source software, you need to read it's source code (specially zope/plone). A lot of times I need to write print statements, or debug calls (import pdb), or comment try/except clauses, you name it. Sometimes I have a lot of files opened when trying to find an issue, and sometimes I forget to remove these print/debug alterations. So, my question is: how do you keep yourself organized when doing it? Do you write ""TODOs"" along the modifications and search for them later, do you keep everything opened in your editor and when you find what you were looking for you just revert the files (This approach isn't useful when you're searching for a really big problem that needs days, you need to turn off your computer and return the other day)? Or you just don't do nothing since print statements in development environment is nothing to worry about? -I'm using Vim. I'm just interested to know how other programmers treat this issue.","Well +1 for starting this discussion. Yes sometime this happen to me. I left those pdb and commit the code to the central code base, git. I use 'emacs'. So, Before commit the code I usually search for pdb in the file. But it is hectic checking each file.So, Before committing the code I usually check the diff very carefully. I am also finding the better way to resolve this issue.",0.1618299653758019,False,3,951 -2010-12-09 19:58:46.997,How do you avoid leaving debugger print/pdb statements in python open source apps when you're debugging them and just finish?,"Sometimes when developing using open source software, you need to read it's source code (specially zope/plone). A lot of times I need to write print statements, or debug calls (import pdb), or comment try/except clauses, you name it. -Sometimes I have a lot of files opened when trying to find an issue, and sometimes I forget to remove these print/debug alterations. -So, my question is: how do you keep yourself organized when doing it? Do you write ""TODOs"" along the modifications and search for them later, do you keep everything opened in your editor and when you find what you were looking for you just revert the files (This approach isn't useful when you're searching for a really big problem that needs days, you need to turn off your computer and return the other day)? Or you just don't do nothing since print statements in development environment is nothing to worry about? I'm using Vim. I'm just interested to know how other programmers treat this issue.","I also develop Python with Vim. I have never had to substantially modify the source code for debugging. I do sometimes put debugging print statements, and I have the habit of putting ""# XXX"" after every one. Then when I want to remove them (before a commit), and just search for the XXX and delete those lines. For exceptions, I have arranged to run my code in the Vim buffer with an external interpreter that is set up to automatically enter the debugger on any uncaught exception. Then I'm placed automatically in the code at the point the exception occured. I use a modified debugger that can also signal Vim (actually GTK Gvim) to open that source at that line. Caught exceptions should report meaningful errors, anyway. It is considered by many to be bad practice to do things like: @@ -11097,6 +11093,10 @@ try: except: handle everything Since you probably aren't actually handling every possible error case. By not doing that you also enable the automatic debugging.",0.0814518047658113,False,3,951 +2010-12-09 19:58:46.997,How do you avoid leaving debugger print/pdb statements in python open source apps when you're debugging them and just finish?,"Sometimes when developing using open source software, you need to read it's source code (specially zope/plone). A lot of times I need to write print statements, or debug calls (import pdb), or comment try/except clauses, you name it. +Sometimes I have a lot of files opened when trying to find an issue, and sometimes I forget to remove these print/debug alterations. +So, my question is: how do you keep yourself organized when doing it? Do you write ""TODOs"" along the modifications and search for them later, do you keep everything opened in your editor and when you find what you were looking for you just revert the files (This approach isn't useful when you're searching for a really big problem that needs days, you need to turn off your computer and return the other day)? Or you just don't do nothing since print statements in development environment is nothing to worry about? +I'm using Vim. I'm just interested to know how other programmers treat this issue.","Well +1 for starting this discussion. Yes sometime this happen to me. I left those pdb and commit the code to the central code base, git. I use 'emacs'. So, Before commit the code I usually search for pdb in the file. But it is hectic checking each file.So, Before committing the code I usually check the diff very carefully. I am also finding the better way to resolve this issue.",0.1618299653758019,False,3,951 2010-12-11 01:07:46.273,"Python, BaseHTTPRequestHandler: how to read what's available on file from socket?","I'm using Python's BaseHTTPRequestHandler class to build a web server. I want to add an endpoint for WebSockets. This means that I need to read whatever is available from the handler's rfile, so that I can process messages one by one, as I'm receiving them (instead of having to read the while input). I tried using different combinations of 'read' (eg. with a big buffer, thinking that it'd return early with less data if less data was available; with no parameter, but then it just means to read until EOF) but couldn't get this to work. I can think of two solutions: @@ -11106,8 +11106,6 @@ To temporally make the file non-blocking, then attempt a read for a chunk of dat Any ideas of how to get read to return whatever data is available?","WebSockets aren't HTTP, so you can't really handle them with an HTTP request handler. However, using BaseHTTPRequestHandler with HTTP, you would normally be reading only the exact amount of data you expect (for instance, as specified in the Content-length header.)",0.3869120172231254,False,1,952 -2010-12-11 12:17:05.983,Change background color of python shell,"Is it possible to change background color of the Python Shell from white to black for example. I did find how to change text color, but can't figure out how to change background color. I'm running it under the Windows. Any suggestions?","If you are reffering to the window idle for example for version 2.6 there is now way to change the background color from withe to another one. But you can change the background color of your text if you go to options. -Another thing you can do is to use other gui for python which could be more elaborated such as eclipse pydev or to use a text editor you like and configure it the way you want to write your scripts and then run them into the idle.",0.1618299653758019,False,3,953 2010-12-11 12:17:05.983,Change background color of python shell,"Is it possible to change background color of the Python Shell from white to black for example. I did find how to change text color, but can't figure out how to change background color. I'm running it under the Windows. Any suggestions?","just go through simple steps - go to options - configure IDLE @@ -11115,6 +11113,8 @@ Another thing you can do is to use other gui for python which could be more elab - then select background and click on choose color for: - you can change the color to any color but becareful if u change only the background color the foreground color may not be visible because they both might be black Enjoy",0.1618299653758019,False,3,953 +2010-12-11 12:17:05.983,Change background color of python shell,"Is it possible to change background color of the Python Shell from white to black for example. I did find how to change text color, but can't figure out how to change background color. I'm running it under the Windows. Any suggestions?","If you are reffering to the window idle for example for version 2.6 there is now way to change the background color from withe to another one. But you can change the background color of your text if you go to options. +Another thing you can do is to use other gui for python which could be more elaborated such as eclipse pydev or to use a text editor you like and configure it the way you want to write your scripts and then run them into the idle.",0.1618299653758019,False,3,953 2010-12-11 12:17:05.983,Change background color of python shell,"Is it possible to change background color of the Python Shell from white to black for example. I did find how to change text color, but can't figure out how to change background color. I'm running it under the Windows. Any suggestions?","You can,,go to options then configure IDE, then on the settings window select highlights, on the rightside press the button below a builtin theme, then choose your choice theme",-0.0814518047658113,False,3,953 2010-12-11 18:30:43.653,comparing batch to python commands?,"Ok i have these commands used in batch and i wanted to know the commands in python that would have a similar affect, just to be clear i dont want to just use os.system(""command here"") for each of them. For example in batch if you wanted a list of commands you would type help but in python you would type help() and then modules... I am not trying to use batch in a python script, i just wanna know the similarities in both languages. Like in english you say "" Hello"" but in french you say ""Bonjour"" not mix the two languages. (heres the list of commands/functions id like to know: @@ -11129,8 +11129,8 @@ how to get help with a specific module without having to type help() @8: (in batch it would be command /?) EDITED COMPLETELY -Thanks in Adnvance!","I am pretty much facing the same problem as you, daniel11. As a solution, I am learning BATCH commands and their meaning. After I understand those, I am going to write a program in Python that does the same or accomplishes the same task. -Thanks to Adam V. and katrielatex for their insight and suggestions.",0.0,False,2,954 +Thanks in Adnvance!","Python is not a system shell, Python is a multi-paradigm programming language. +If you want to compare .bat with anything, compare it with sh or bash. (You can have those on various platforms too - for example, sh for windows is in the MinGW package).",0.0814518047658113,False,2,954 2010-12-11 18:30:43.653,comparing batch to python commands?,"Ok i have these commands used in batch and i wanted to know the commands in python that would have a similar affect, just to be clear i dont want to just use os.system(""command here"") for each of them. For example in batch if you wanted a list of commands you would type help but in python you would type help() and then modules... I am not trying to use batch in a python script, i just wanna know the similarities in both languages. Like in english you say "" Hello"" but in french you say ""Bonjour"" not mix the two languages. (heres the list of commands/functions id like to know: change the current directory @@ -11144,8 +11144,8 @@ how to get help with a specific module without having to type help() @8: (in batch it would be command /?) EDITED COMPLETELY -Thanks in Adnvance!","Python is not a system shell, Python is a multi-paradigm programming language. -If you want to compare .bat with anything, compare it with sh or bash. (You can have those on various platforms too - for example, sh for windows is in the MinGW package).",0.0814518047658113,False,2,954 +Thanks in Adnvance!","I am pretty much facing the same problem as you, daniel11. As a solution, I am learning BATCH commands and their meaning. After I understand those, I am going to write a program in Python that does the same or accomplishes the same task. +Thanks to Adam V. and katrielatex for their insight and suggestions.",0.0,False,2,954 2010-12-11 19:17:03.457,How to maintain order of paragraphs in a Django document revision system?,"I'm having trouble figuring out how to best implement a document (paragraph-) revision system in Django. I want to save a revision history of a document, paragraph-by-paragraph. In other words, there will be a class Document, which has a ManyToManyField to Paragraph. To maintain the order of the paragraphs, a third class ParagraphContainer can be created. My question is, what is a good way to implement this in Django so that the order of paragraphs is maintained when someone adds a new paragraph in-between existing paragraphs? @@ -11199,8 +11199,8 @@ How do I programmatically add and remove scripts that run daily depending on the How would I schedule this script to run for each website of each user, passing in the appropriate parameters? I'm somewhat acquainted with cronjobs, as it's the only thing I know of that is made for routine processes.","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.",0.0,False,2,960 -2010-12-15 14:50:29.110,Keyboard interface to wxPython listbox,"I'm using a wxPython listbox on Windows to get a choice from the user, and I would like them to be able to select an item using the ENTER key, as if they had double-clicked. I know how to do this in C or C++ using the Windows API directly, but can't seem to find how to do it using wxPython. Anyone know how? It seems like an obvious thing to want to do.","Maybe I'm missing some nuance, there wasn't much info to go on, but it sounds like you could accomplish this by catching the keydown event, matching for enter and then calling your on_doubleclick function. Unless there's an implicit double-click handling you should be good to go.",0.1352210990936997,False,2,961 2010-12-15 14:50:29.110,Keyboard interface to wxPython listbox,"I'm using a wxPython listbox on Windows to get a choice from the user, and I would like them to be able to select an item using the ENTER key, as if they had double-clicked. I know how to do this in C or C++ using the Windows API directly, but can't seem to find how to do it using wxPython. Anyone know how? It seems like an obvious thing to want to do.",The simple answer is that the wx.ListBox doesn't support that. Try using a one column wx.ListCtrl (in Report mode) instead.,0.1352210990936997,False,2,961 +2010-12-15 14:50:29.110,Keyboard interface to wxPython listbox,"I'm using a wxPython listbox on Windows to get a choice from the user, and I would like them to be able to select an item using the ENTER key, as if they had double-clicked. I know how to do this in C or C++ using the Windows API directly, but can't seem to find how to do it using wxPython. Anyone know how? It seems like an obvious thing to want to do.","Maybe I'm missing some nuance, there wasn't much info to go on, but it sounds like you could accomplish this by catching the keydown event, matching for enter and then calling your on_doubleclick function. Unless there's an implicit double-click handling you should be good to go.",0.1352210990936997,False,2,961 2010-12-16 01:14:58.910,Django: correct way to group a bunch of media's,"I send several forms to a template, and I want to put all required media in the tag. Some forms might require the same media (for instance, the same JS file), so I would like to unify all medias before putting them in the . Question is, how do I do that? I know you can unify two medias by doing m1 + m2, but this will look ugly in the generic case where I have an unknown number of forms. Is there some shortcut?","What happens if you just use {{ form.media }} for each form, and link up the media in the form's Meta? I seem to remember that making sure that it didn't insert anything twice, but it's been a while. Have you tried that yet?",0.0,False,1,962 2010-12-16 08:24:28.850,How to get the list of all initialized objects and function definitions alive in python?,"Say that in the python shell (IDLE) I have defined some classes, functions, variables. Also created objects of the classes. Then I deleted some of the objects and created some others. At a later point in time, how can I get to know what are the currently active objects, variables, and methods definitions active in the memory?","How about dir() which will output instantiated objects as a list? I just used this just now: @@ -11239,24 +11239,24 @@ J",0.0,False,1,967 2010-12-20 20:55:57.780,Has anybody been able to install PyWeka?,"I need to install in python 2.6 or 2.7 for windows the library PyWeka0.3dev, It says it requires setuptools, which I installed but then they told me it was a deprecated instalation library and I installed distribute, then I downloaded the PyWeka compressed package and each time I try to install it neither with setup.py nor with easy_install (where it says something like no module ez_setup). Can anybody give me a clue about how to do this?","A punk/goth approach to programming probably has the right to be.. To get the C-compliation part to work on windows you either need (1) to have Visual Studio of the same version that was used to compile the python version you are using, or (2) mingw which is a bit trickier to set up.",0.0,False,1,968 2010-12-22 00:01:58.563,wxPython Whole Window Focus Event,"With wxPython, how does one trigger an event whenever the whole window goes into/out of focus? +To elaborate, I'm building a serial terminal GUI and would like to close down the connection whenever the user doesn't have my application selected, and re-open the connection whenever the user brings my app back into the foreground. My application is just a single window derived from wx.Frame.","In addition to what these fellows are saying, you might also want to try EVT_ENTER_WINDOW and EVT_LEAVE_WINDOW. I think these are fired when you move the mouse into and out of the frame widget, although I don't think the frame has to be in focus for those events to fire. +@ Hugh - thanks for the readership!",0.2012947653214861,False,3,969 +2010-12-22 00:01:58.563,wxPython Whole Window Focus Event,"With wxPython, how does one trigger an event whenever the whole window goes into/out of focus? To elaborate, I'm building a serial terminal GUI and would like to close down the connection whenever the user doesn't have my application selected, and re-open the connection whenever the user brings my app back into the foreground. My application is just a single window derived from wx.Frame.","as WxPerl programmer i know there is EVT_SET_FOCUS( EVT_KILL_FOCUS( if you initialize this event by listening to the frame as first parameter it should work as in Perl since the API is almost the same",0.2012947653214861,False,3,969 2010-12-22 00:01:58.563,wxPython Whole Window Focus Event,"With wxPython, how does one trigger an event whenever the whole window goes into/out of focus? -To elaborate, I'm building a serial terminal GUI and would like to close down the connection whenever the user doesn't have my application selected, and re-open the connection whenever the user brings my app back into the foreground. My application is just a single window derived from wx.Frame.","In addition to what these fellows are saying, you might also want to try EVT_ENTER_WINDOW and EVT_LEAVE_WINDOW. I think these are fired when you move the mouse into and out of the frame widget, although I don't think the frame has to be in focus for those events to fire. -@ Hugh - thanks for the readership!",0.2012947653214861,False,3,969 -2010-12-22 00:01:58.563,wxPython Whole Window Focus Event,"With wxPython, how does one trigger an event whenever the whole window goes into/out of focus? To elaborate, I'm building a serial terminal GUI and would like to close down the connection whenever the user doesn't have my application selected, and re-open the connection whenever the user brings my app back into the foreground. My application is just a single window derived from wx.Frame.",The correct answer for this case is to use an EVT_ACTIVATE handler bound to the frame. There will be an event whenever the frame is activated (brought into the foreground relative to other windows currently open) or deactivated. You can use the event object's GetActive method to tell which just happened.,1.2,True,3,969 2010-12-22 03:47:46.270,How important is it to use short names for Python packages and modules?,"PEP 8 says that Python package and module names should be short, since some file systems will truncate long names. And I'm trying to follow Python conventions in a new project. But I really like long, descriptive names. So I'm wondering, how short do names need to be to comply with PEP 8. And does anyone really worry about this anymore? I'm tempted to ignore this recommendation, and use longer names, thinking this isn't all that relevant anymore. Does anyone think this recommendation is still worth following? If yes, why? And how short is short enough? edit: Thanks for all the helpful answers. I'm not going to worry about making my names real short, since I don't think anyone will be running my system on a really old computer. And if it did happen, I could always shorten some of the names later. But I will limit them to 32 characters. And now I understand that PEP 8 is specifically meant for the standard library, and the name length thing does make sense in that case. But I think longer names will be better for the application I'm working on. I don't think there's one best answer here, so I'm going to flip a coin to help me decide.","The common Python platforms all support directory and file names of 32 characters or more, but I personally feel that if you find yourself breaking 11 characters often that you need to rethink things.",1.2,True,4,970 2010-12-22 03:47:46.270,How important is it to use short names for Python packages and modules?,"PEP 8 says that Python package and module names should be short, since some file systems will truncate long names. And I'm trying to follow Python conventions in a new project. But I really like long, descriptive names. So I'm wondering, how short do names need to be to comply with PEP 8. And does anyone really worry about this anymore? I'm tempted to ignore this recommendation, and use longer names, thinking this isn't all that relevant anymore. Does anyone think this recommendation is still worth following? If yes, why? And how short is short enough? -edit: Thanks for all the helpful answers. I'm not going to worry about making my names real short, since I don't think anyone will be running my system on a really old computer. And if it did happen, I could always shorten some of the names later. But I will limit them to 32 characters. And now I understand that PEP 8 is specifically meant for the standard library, and the name length thing does make sense in that case. But I think longer names will be better for the application I'm working on. I don't think there's one best answer here, so I'm going to flip a coin to help me decide.","If you need to make sure your code works on DOS, use 8 characters. :p -Otherwise, it's a free world. But nobody likes to type insanely long strings. (See powershell = fail). So use your best judgement, and be reasonable.",0.2012947653214861,False,4,970 +edit: Thanks for all the helpful answers. I'm not going to worry about making my names real short, since I don't think anyone will be running my system on a really old computer. And if it did happen, I could always shorten some of the names later. But I will limit them to 32 characters. And now I understand that PEP 8 is specifically meant for the standard library, and the name length thing does make sense in that case. But I think longer names will be better for the application I'm working on. I don't think there's one best answer here, so I'm going to flip a coin to help me decide.","Long names make it easy to make stupid typing mistakes later on. Any modern computer shouldn't have a problem with long filenames, but it's good practice to pick short, descriptive names. Abbreviations are your friend, especially when you like knowing what a function does off the bat,etc.",0.0,False,4,970 2010-12-22 03:47:46.270,How important is it to use short names for Python packages and modules?,"PEP 8 says that Python package and module names should be short, since some file systems will truncate long names. And I'm trying to follow Python conventions in a new project. But I really like long, descriptive names. So I'm wondering, how short do names need to be to comply with PEP 8. And does anyone really worry about this anymore? I'm tempted to ignore this recommendation, and use longer names, thinking this isn't all that relevant anymore. Does anyone think this recommendation is still worth following? If yes, why? And how short is short enough? edit: Thanks for all the helpful answers. I'm not going to worry about making my names real short, since I don't think anyone will be running my system on a really old computer. And if it did happen, I could always shorten some of the names later. But I will limit them to 32 characters. And now I understand that PEP 8 is specifically meant for the standard library, and the name length thing does make sense in that case. But I think longer names will be better for the application I'm working on. I don't think there's one best answer here, so I'm going to flip a coin to help me decide.","The issue is with old(er) file systems (used before Windows 95 and fat16) that don't support names larger than, say, 32 characters (it varies with the file system). It's only an issue if your scripts need to run on old computers.",0.1016881243684853,False,4,970 2010-12-22 03:47:46.270,How important is it to use short names for Python packages and modules?,"PEP 8 says that Python package and module names should be short, since some file systems will truncate long names. And I'm trying to follow Python conventions in a new project. But I really like long, descriptive names. So I'm wondering, how short do names need to be to comply with PEP 8. And does anyone really worry about this anymore? I'm tempted to ignore this recommendation, and use longer names, thinking this isn't all that relevant anymore. Does anyone think this recommendation is still worth following? If yes, why? And how short is short enough? -edit: Thanks for all the helpful answers. I'm not going to worry about making my names real short, since I don't think anyone will be running my system on a really old computer. And if it did happen, I could always shorten some of the names later. But I will limit them to 32 characters. And now I understand that PEP 8 is specifically meant for the standard library, and the name length thing does make sense in that case. But I think longer names will be better for the application I'm working on. I don't think there's one best answer here, so I'm going to flip a coin to help me decide.","Long names make it easy to make stupid typing mistakes later on. Any modern computer shouldn't have a problem with long filenames, but it's good practice to pick short, descriptive names. Abbreviations are your friend, especially when you like knowing what a function does off the bat,etc.",0.0,False,4,970 +edit: Thanks for all the helpful answers. I'm not going to worry about making my names real short, since I don't think anyone will be running my system on a really old computer. And if it did happen, I could always shorten some of the names later. But I will limit them to 32 characters. And now I understand that PEP 8 is specifically meant for the standard library, and the name length thing does make sense in that case. But I think longer names will be better for the application I'm working on. I don't think there's one best answer here, so I'm going to flip a coin to help me decide.","If you need to make sure your code works on DOS, use 8 characters. :p +Otherwise, it's a free world. But nobody likes to type insanely long strings. (See powershell = fail). So use your best judgement, and be reasonable.",0.2012947653214861,False,4,970 2010-12-22 18:23:07.670,Best way to get user nearest city? Python/Django,"I have a website with a limited number of cities in the database, and need to show the user the nearest city to his current location. I can get the location by MaxMind API, but I want to get the nearest city in my database to user city. For example, if I have these cities in the database: Los Angeles, San Francisco and New York City, and I'm accessing from other city like Miami, I should see NYC selected because it's the nearest geographically. @@ -11267,11 +11267,11 @@ But how often do you plan to add a city? Probably not that often. So, the off-li 2010-12-23 09:26:14.703,Print statements on server give IOError: failed to write data,"I am running Pylons on my local machine with paster, and on a Debian server using WSGI. I want to add some print statements to debug a problem: am not a Pylons or Python expert. On my local machine this works fine: print statements go to the terminal. On the server, the statements don't print to the log files: instead the log file says ""IOError: failed to write data"" whenever a print statement is called. Until I can fix this, I can't debug anything on the server. -Could someone advise how to get printing running on the server? Thanks!","Don't use print statements, use the logging module. We can't help you without knowing the setup of the server.",1.2,True,2,972 +Could someone advise how to get printing running on the server? Thanks!","It's wrong for a WSGI application to use sys.stdout or sys.stderr. If you want to spit debug to a server error log, use environ['wsgi.errors'].write().",0.5457054096481145,False,2,972 2010-12-23 09:26:14.703,Print statements on server give IOError: failed to write data,"I am running Pylons on my local machine with paster, and on a Debian server using WSGI. I want to add some print statements to debug a problem: am not a Pylons or Python expert. On my local machine this works fine: print statements go to the terminal. On the server, the statements don't print to the log files: instead the log file says ""IOError: failed to write data"" whenever a print statement is called. Until I can fix this, I can't debug anything on the server. -Could someone advise how to get printing running on the server? Thanks!","It's wrong for a WSGI application to use sys.stdout or sys.stderr. If you want to spit debug to a server error log, use environ['wsgi.errors'].write().",0.5457054096481145,False,2,972 +Could someone advise how to get printing running on the server? Thanks!","Don't use print statements, use the logging module. We can't help you without knowing the setup of the server.",1.2,True,2,972 2010-12-23 19:56:34.043,Line endings and reading and writing to text files,"I am writing a small script that will need to read and write to text files on Windows and Linux and perhaps Mac even. The script will be used by users on all perhaps all of these platforms (Windows for sure) and interchangeably - so a user who wrote to a file X on Windows, may read the file on Linux with the script. What precautions should I take or how should I implement my code that it is able to handle line endings across various platforms? (reading and writing) Or this is a non-issue and Python handles everything?","It's a non-issue, Python is smart like that. It handles line endings across platforms very well.",1.2,True,1,973 @@ -11309,15 +11309,11 @@ My question is what is the best practice for keeping this number stored inside t Thanks.","Personally, I wouldn't do it manually this way. I'd save my code in Subversion and let it maintain the revision numbers for me.",0.0,False,1,978 2010-12-27 08:21:21.957,how to communicate with ror program in python,"i have a application which use rails to do the CRUD operation,it's handy now i want to write a crawler use python,after that i want to save the data to db, -so my question is how to python communicate with ror program?","Via the CRUD interface, seems the obvious solution.",0.0,False,2,979 -2010-12-27 08:21:21.957,how to communicate with ror program in python,"i have a application which use rails to do the CRUD operation,it's handy -now i want to write a crawler use python,after that i want to save the data to db, so my question is how to python communicate with ror program?","I don't have any idea about python or rails (only grails :) but the easiest solution (if you don't want the python script to touch the DB) would be to implement a controller action for the REST PUT method in your rails application and call it from your python crawler with the crawled data. Now, all the rails controller has to do is to inster the data into your database.",0.2012947653214861,False,2,979 -2010-12-27 10:14:15.277,add a python module with out root permission,"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. -my 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. -Br, -J.K.","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.",1.2,True,2,980 +2010-12-27 08:21:21.957,how to communicate with ror program in python,"i have a application which use rails to do the CRUD operation,it's handy +now i want to write a crawler use python,after that i want to save the data to db, +so my question is how to python communicate with ror program?","Via the CRUD interface, seems the obvious solution.",0.0,False,2,979 2010-12-27 10:14:15.277,add a python module with out root permission,"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. my 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. Br, @@ -11325,6 +11321,18 @@ J.K.","I usually use the --user option instead of --prefix, since it installs it I think this option is available only for python 2.6 + but I am not sure. If you have to install it in an other place, then you have no choice and I don't know what could be wrong. By 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"".",0.2012947653214861,False,2,980 +2010-12-27 10:14:15.277,add a python module with out root permission,"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. +my 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. +Br, +J.K.","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.",1.2,True,2,980 +2010-12-27 20:29:38.720,Python client/server project code layout,"Suppose you have a client/server application, say a webserver component and a qt gui. How do you layout your python code? + +Packages foo.server and foo.client? +Packages fooserver and fooclient, with both importing from foocommon? +Everything together with no clear distinction? + +Having subpackages for server and client code (foo.server and foo.client) seems the best approach to me, but then how do you handle your distutils setup if you don't want the server code to be shipped along with the client code? If you use setuptools (I would rather not), how do you create separate eggs?","I like namespaces, so yes. foo.client and foo.server and foo.common and foo.anythingelsethatcanbeusedseparately. But it's all a matter of taste, really. +And I'd release them as separate packages, and yes, I'd use Distribute.",0.0,False,2,981 2010-12-27 20:29:38.720,Python client/server project code layout,"Suppose you have a client/server application, say a webserver component and a qt gui. How do you layout your python code? Packages foo.server and foo.client? @@ -11344,14 +11352,6 @@ The Apache HTTPD server and the Firefox browser do not have any common code that The Sendmail server and the pop/imap libraries in Python seem to be utterly separated with almost nothing in common. The MySQL database server and the MySQLDB interface in Python seem to be utterly and completely separated with almost nothing in common. I can't see any examples of foo.server and foo.client anywhere. Perhaps you could share an example as part of your question to help clarify your thinking on this subject.",1.2,True,2,981 -2010-12-27 20:29:38.720,Python client/server project code layout,"Suppose you have a client/server application, say a webserver component and a qt gui. How do you layout your python code? - -Packages foo.server and foo.client? -Packages fooserver and fooclient, with both importing from foocommon? -Everything together with no clear distinction? - -Having subpackages for server and client code (foo.server and foo.client) seems the best approach to me, but then how do you handle your distutils setup if you don't want the server code to be shipped along with the client code? If you use setuptools (I would rather not), how do you create separate eggs?","I like namespaces, so yes. foo.client and foo.server and foo.common and foo.anythingelsethatcanbeusedseparately. But it's all a matter of taste, really. -And I'd release them as separate packages, and yes, I'd use Distribute.",0.0,False,2,981 2010-12-27 21:07:40.637,twisted deferred/callbacks and asynchronous execution,"I'm trying to figure out how can i make my code more asynchronous using twisted. A function returns a deferred object @@ -11365,13 +11365,13 @@ However, if I have a deferred object, and I attach as its callback the deferred_ Assuming all of my code is non-blocking, this means that chained callbacks are NOT asynchronous while chained deferreds are, correct?","Sort of, but there is no concurrency in this type of event processing. No new callback will be called until the code gets back to the event loop. So the chain of callbacks is synchronous. It's only asynchronous in the event loop. This is one caveat of this type of programming, the handlers most execute quickly, and get back to the event loop ASAP. It should not do any time consuming task in a handler.",0.2012947653214861,False,1,982 2010-12-27 21:38:07.663,"Updated Python from disk image, want to make it available in terminal","I have Python 2.6.1 which came on the Mac I have, but I'd recently downloaded and installed the disk image of 3.1.3 and I'd like to have it available in Terminal, how can I do this? For instance when I do $ python -V in Terminal I get 2.6.1. +Thanks for any help.","The default Python version in Mac OS X needs to stay the default Python version, or things will break. You want to install it alongside with Python 2. This is most likely exactly what happened, but you start Python 3 with python3.",0.1016881243684853,False,2,983 +2010-12-27 21:38:07.663,"Updated Python from disk image, want to make it available in terminal","I have Python 2.6.1 which came on the Mac I have, but I'd recently downloaded and installed the disk image of 3.1.3 and I'd like to have it available in Terminal, how can I do this? For instance when I do $ python -V in Terminal I get 2.6.1. Thanks for any help.","First, I'm not a Mac user, so I don't know a couple of specifics (default PATH, etc). Also, a bit of clarity - when you use the installer, it lets you customize the installation to install in a specific location - do you know where that is. If you didn't select a location, it defaults to /usr/local/bin. From Terminal, try ""python3"". If that fails, try ""/usr/local/bin/python3"". Outside of that, wherever it's found, you'll want that in your path statement if it isn't there already. It's not recommended that you ""replace"" the system python with python 3.x, as you'll definitely have problems.",0.0,False,2,983 -2010-12-27 21:38:07.663,"Updated Python from disk image, want to make it available in terminal","I have Python 2.6.1 which came on the Mac I have, but I'd recently downloaded and installed the disk image of 3.1.3 and I'd like to have it available in Terminal, how can I do this? For instance when I do $ python -V in Terminal I get 2.6.1. -Thanks for any help.","The default Python version in Mac OS X needs to stay the default Python version, or things will break. You want to install it alongside with Python 2. This is most likely exactly what happened, but you start Python 3 with python3.",0.1016881243684853,False,2,983 2010-12-28 15:24:35.027,Removing code dependency on Greenlets,"I have some code which depends on Greenlets, and need to remove this dependency. Can anyone explain to me exactly what I'll need to do? They would preferably be replaced with threads or (better yet) processes from the multiprocessing module, but anything that relies solely on the Python standard library would be sufficient for my needs. @@ -11394,21 +11394,21 @@ I am surprised by the answers so far. I find that nicely formatted HTML aids in 2010-12-31 02:30:23.963,Multiple inheritance in Python; how to do so in Java?,"I'm porting some Python code to Java, and I am having trouble dealing with the following problem: I have some classes which need to have abilities A, B, or C. Class 1 needs ability A, class 2 needs A, B and C, and class 3 needs B and C. Most importantly, I want to easily be able to change what class can have what ability in the future. I solved this problem pretty easily with multiple inheritance in Python. I'm trying to figure out the best way to do it in Java, but I can't come up with as good of a solution. I know multiple inheritance is frowned-upon, so I'd appreciate being taught a better way. -Thanks!",You can define the abilities in interfaces and implement them in your classes.,0.0,False,4,987 +Thanks!","This is a bit tangential, but you can have python code running in Java via Jython (http://www.jython.org/). This addresses the porting to Java part, not the solving multiple inheritance part (I think you need to determine which is relevant)",0.0,False,4,987 2010-12-31 02:30:23.963,Multiple inheritance in Python; how to do so in Java?,"I'm porting some Python code to Java, and I am having trouble dealing with the following problem: I have some classes which need to have abilities A, B, or C. Class 1 needs ability A, class 2 needs A, B and C, and class 3 needs B and C. Most importantly, I want to easily be able to change what class can have what ability in the future. I solved this problem pretty easily with multiple inheritance in Python. I'm trying to figure out the best way to do it in Java, but I can't come up with as good of a solution. I know multiple inheritance is frowned-upon, so I'd appreciate being taught a better way. -Thanks!","In java you don't have multiple inheritance, instead you can implement multiple interfaces. -So your class 1 will implement interface A and B. Class 2 will implement interface A, B and C. Class 3 will implement B and C.",0.0,False,4,987 +Thanks!","If what you need is interface inheritance, then as mentioned before, you can always implement multiple interfaces. +If you're looking for implementation inheritance, you're somewhat out of luck. The best solution is probably to use delegation — replace the extra superclasses with fields, and implement methods that just delegate to those fields. It does require writing a lot of repetitive delegation methods, but it's rather unavoidable in Java (without resorting to AspectJ or other bytecode-munging tricks; careful, this way madness lies …).",0.0,False,4,987 2010-12-31 02:30:23.963,Multiple inheritance in Python; how to do so in Java?,"I'm porting some Python code to Java, and I am having trouble dealing with the following problem: I have some classes which need to have abilities A, B, or C. Class 1 needs ability A, class 2 needs A, B and C, and class 3 needs B and C. Most importantly, I want to easily be able to change what class can have what ability in the future. I solved this problem pretty easily with multiple inheritance in Python. I'm trying to figure out the best way to do it in Java, but I can't come up with as good of a solution. I know multiple inheritance is frowned-upon, so I'd appreciate being taught a better way. -Thanks!","If what you need is interface inheritance, then as mentioned before, you can always implement multiple interfaces. -If you're looking for implementation inheritance, you're somewhat out of luck. The best solution is probably to use delegation — replace the extra superclasses with fields, and implement methods that just delegate to those fields. It does require writing a lot of repetitive delegation methods, but it's rather unavoidable in Java (without resorting to AspectJ or other bytecode-munging tricks; careful, this way madness lies …).",0.0,False,4,987 +Thanks!","In java you don't have multiple inheritance, instead you can implement multiple interfaces. +So your class 1 will implement interface A and B. Class 2 will implement interface A, B and C. Class 3 will implement B and C.",0.0,False,4,987 2010-12-31 02:30:23.963,Multiple inheritance in Python; how to do so in Java?,"I'm porting some Python code to Java, and I am having trouble dealing with the following problem: I have some classes which need to have abilities A, B, or C. Class 1 needs ability A, class 2 needs A, B and C, and class 3 needs B and C. Most importantly, I want to easily be able to change what class can have what ability in the future. I solved this problem pretty easily with multiple inheritance in Python. I'm trying to figure out the best way to do it in Java, but I can't come up with as good of a solution. I know multiple inheritance is frowned-upon, so I'd appreciate being taught a better way. -Thanks!","This is a bit tangential, but you can have python code running in Java via Jython (http://www.jython.org/). This addresses the porting to Java part, not the solving multiple inheritance part (I think you need to determine which is relevant)",0.0,False,4,987 +Thanks!",You can define the abilities in interfaces and implement them in your classes.,0.0,False,4,987 2010-12-31 04:17:25.633,python socket programming error,"i got this error while running my function. ""socket.error: [Errno 98] Address already in use"" how can i close the address already in use and start new connection with port in python?","Stop the program or the service which is the port which you are trying to use. Alternatively, for whatever program which you are trying to write, use a PORT number which is a sufficiently high number (> 1024 for sure) and is unused.",0.0,False,2,988 @@ -11494,6 +11494,11 @@ You can setup different subdomains to be used by different servers and setup tho 2011-01-05 14:37:12.057,Is it possible to use different technologies in one website,"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. Now 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. But i am confused how can we make make separate modules in diff languages and combine to make one website +Any ideas","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. +If 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).",0.0,False,4,996 +2011-01-05 14:37:12.057,Is it possible to use different technologies in one website,"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. +Now 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. +But i am confused how can we make make separate modules in diff languages and combine to make one website Any ideas","I know in Ruby on Rails, you can execute bash commands. Example: puts ls",0.0,False,4,996 2011-01-05 14:37:12.057,Is it possible to use different technologies in one website,"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. @@ -11501,11 +11506,6 @@ Now initially i was thinking that if i build the website then i have to use one But i am confused how can we make make separate modules in diff languages and combine to make one website Any ideas","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). In general it is very broad topic, so if you're interested, try with some basic keywords: application servers, load balancing, reverse proxy, url rewriting.",1.2,True,4,996 -2011-01-05 14:37:12.057,Is it possible to use different technologies in one website,"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. -Now 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. -But i am confused how can we make make separate modules in diff languages and combine to make one website -Any ideas","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. -If 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).",0.0,False,4,996 2011-01-06 09:02:04.953,Help needed with db structure,"I'm developing a web app that uses stock data. The stock data can be stored in: Files @@ -11529,9 +11529,8 @@ VM is Mysql 5.1 on Fedora 14. 1) I could DUMP to ""shared,"" Restore. Not sure if this will work. 2) I could network Mysql Host to Mysql VM. Not how to do this How would I do this with python 2.7? -I dont want them in sync after set-up phase. But, maybe sync some tables or SP occasionly on-rewrites. After I build out Linux Env. I would like to be able to convert V2P and have a dual-boot system.","You can use mysqldump to make snapshots of the database, and to restore it to known states after tests. -But instead or going into the complication of synchronizing different database instances, it would be best to open the host machine's instance to local network access, and have the applications in the virtual machine access that as if it was a remote server. Overall performance should improve too. -Even if you decide to run different databases for the host and the guest, run then both on the host's MySQL instance. Performance will be better, configuration management will be easier, and the apps in the guest will be tested against a realistic deployment environment.",1.2,True,2,998 +I dont want them in sync after set-up phase. But, maybe sync some tables or SP occasionly on-rewrites. After I build out Linux Env. I would like to be able to convert V2P and have a dual-boot system.","Do you want it synced in realtime? +Why not just connect the guest's mysql process to the host?",0.0,False,2,998 2011-01-06 20:15:51.310,How to Sync MySQL with python?,"Im setting a VM. Both host and VM machine have Mysql. How do keep the VM Mysql sync'd to to the host Mysql. @@ -11540,8 +11539,9 @@ VM is Mysql 5.1 on Fedora 14. 1) I could DUMP to ""shared,"" Restore. Not sure if this will work. 2) I could network Mysql Host to Mysql VM. Not how to do this How would I do this with python 2.7? -I dont want them in sync after set-up phase. But, maybe sync some tables or SP occasionly on-rewrites. After I build out Linux Env. I would like to be able to convert V2P and have a dual-boot system.","Do you want it synced in realtime? -Why not just connect the guest's mysql process to the host?",0.0,False,2,998 +I dont want them in sync after set-up phase. But, maybe sync some tables or SP occasionly on-rewrites. After I build out Linux Env. I would like to be able to convert V2P and have a dual-boot system.","You can use mysqldump to make snapshots of the database, and to restore it to known states after tests. +But instead or going into the complication of synchronizing different database instances, it would be best to open the host machine's instance to local network access, and have the applications in the virtual machine access that as if it was a remote server. Overall performance should improve too. +Even if you decide to run different databases for the host and the guest, run then both on the host's MySQL instance. Performance will be better, configuration management will be easier, and the apps in the guest will be tested against a realistic deployment environment.",1.2,True,2,998 2011-01-07 00:28:42.903,From backslash to slash (to create folders named with number),"I had a bad problem with these two: ""\"" and ""/"" in Windows, obviously :\ I need to replace all \ occurrence in /, so I can use replace() because doesn't work with this ""\6"" for example. What I have to do? I want ""only"" use mkdir() to replicate a structure of folders (without files) from one location to another. So I use mainly os.walk() and mkdir(); everything work well till is found a folder named with numeber. Infact mkdir can do this: @@ -11563,14 +11563,14 @@ what can i do?",The solution was to add an index.,1.2,True,1,1001 --EDIT-- The below turns out to be really really untrue, so don't mind it!!! I'm not going to remove it 'cause that would be lame. I have done some work with the Python SDK and tiny bit with the Java SDK, and doing so I felt the Python SDK was falling behind. More experienced programmers seem to disagree, hence this edit. Have to warn you though, Google is focussing more on the Java platform than the Python platform; very often extra work is involved to achieve the same results as with Java, and sometimes things are simply unsupported. What is your focus here? To learn Python or to learn Python with GAE?",-0.3869120172231254,False,1,1002 +2011-01-07 22:07:39.367,Using Python for quasi randomization,"Here's the problem: I try to randomize n times a choice between two elements (let's say [0,1] -> 0 or 1), and my final list will have n/2 [0] + n/2 [1]. I tend to have this kind of result: [0 1 0 0 0 1 0 1 1 1 1 1 1 0 0, until n]: the problem is that I don't want to have serially 4 or 5 times the same number so often. I know that I could use a quasi randomisation procedure, but I don't know how to do so (I'm using Python).","Having 6 1's in a row isn't particularly improbable -- are you sure you're not getting what you want? +There's a simple Python interface for a uniformly distributed random number, is that what you're looking for?",0.0814518047658113,False,2,1003 2011-01-07 22:07:39.367,Using Python for quasi randomization,"Here's the problem: I try to randomize n times a choice between two elements (let's say [0,1] -> 0 or 1), and my final list will have n/2 [0] + n/2 [1]. I tend to have this kind of result: [0 1 0 0 0 1 0 1 1 1 1 1 1 0 0, until n]: the problem is that I don't want to have serially 4 or 5 times the same number so often. I know that I could use a quasi randomisation procedure, but I don't know how to do so (I'm using Python).","To guarantee that there will be the same number of zeros and ones you can generate a list containing n/2 zeros and n/2 ones and shuffle it with random.shuffle. For small n, if you aren't happy that the result passes your acceptance criteria (e.g. not too many consecutive equal numbers), shuffle again. Be aware that doing this reduces the randomness of the result, not increases it. For larger n it will take too long to find a result that passes your criteria using this method (because most results will fail). Instead you could generate elements one at a time with these rules: If you already generated 4 ones in a row the next number must be zero and vice versa. Otherwise, if you need to generate x more ones and y more zeros, the chance of the next number being one is x/(x+y).",0.3153999413393242,False,2,1003 -2011-01-07 22:07:39.367,Using Python for quasi randomization,"Here's the problem: I try to randomize n times a choice between two elements (let's say [0,1] -> 0 or 1), and my final list will have n/2 [0] + n/2 [1]. I tend to have this kind of result: [0 1 0 0 0 1 0 1 1 1 1 1 1 0 0, until n]: the problem is that I don't want to have serially 4 or 5 times the same number so often. I know that I could use a quasi randomisation procedure, but I don't know how to do so (I'm using Python).","Having 6 1's in a row isn't particularly improbable -- are you sure you're not getting what you want? -There's a simple Python interface for a uniformly distributed random number, is that what you're looking for?",0.0814518047658113,False,2,1003 2011-01-09 11:07:01.303,changing layout and inserting mathematical symbols with pydot,"I am having problem with drawing in pydot. The problem lies in defining the layout of the nodes created. Currently everything is drawn vertically and is not spread. This gives me the problem of going down to see the nodes created. Is there any way I can define the nodes to be created horizontally whenever they are very large in number?? @@ -11593,6 +11593,10 @@ My only concern is that somehow the system gets completely overloaded at some po So my question is, would checking every 0.05 seconds be better? Or is there a way to register an event handler with python for a specific time, so I dont have to keep checking the time myself.","That's not the best solution. It's no guarantee you are locked out for more than one second. You should stick to 0.5 second resolution (or worse if no lives depend on it) and fire the event whenever it is at or past the due time, and keep a flag per event if it has been fired. Then it will always be fired at exactly once, and as close to the target time as achievable.",0.3869120172231254,False,1,1007 2011-01-10 22:56:41.233,How to install python syntax support for Vim on Mac OSX?,"I recently started programming in python and have fallen in love with Vim over the past few weeks. I know want to use Vim as my primary editor for python files. I know there are python plugins for Vim, but I am very confused as to where/how I can install these. I don't really understand where Vim is installed. I'm running the latest version of Mac OS X Snow Leopard. +Any help would be greatly appreciated. Thanks!","for mac os x, the vimrc file is located in /usr/share/vim directory +edit the vimdc file with any text editor. Add the syntax on to the last line of the file. Then next time you start a file you can see color. This is a system wide setting. In other linux flavor it may be located in /etc/ you can find this file by find /etc -name vimdc. The edit will affect all the users on the machine. +These setting can overwritten by the $HOME/.vimrc file. In your home you may also have a .vim directory. To check that you have these, do ls -a in your home directory.",0.0,False,2,1008 +2011-01-10 22:56:41.233,How to install python syntax support for Vim on Mac OSX?,"I recently started programming in python and have fallen in love with Vim over the past few weeks. I know want to use Vim as my primary editor for python files. I know there are python plugins for Vim, but I am very confused as to where/how I can install these. I don't really understand where Vim is installed. I'm running the latest version of Mac OS X Snow Leopard. Any help would be greatly appreciated. Thanks!","To best answer your initial question: ""How to install python syntax support in Vim"": There is no need to install anything! If you have not made any modifications (e.g. no configuration changes for vim in ~/.vimrc) try the following: @@ -11603,10 +11607,6 @@ You should now have VIM properly highlight your Python file. To avoid having to re-type those command over and over again, I would suggest you keep a configuration file for VIM. This is usually located in your home directory, if there is not one there already, create a ~/.vimrc file and add the syntax on directive there to have VIM automatically highlight your Python files. If you need to know more about structure/installation of plugins, then Senthil's answer is better suited :)",1.2,True,2,1008 -2011-01-10 22:56:41.233,How to install python syntax support for Vim on Mac OSX?,"I recently started programming in python and have fallen in love with Vim over the past few weeks. I know want to use Vim as my primary editor for python files. I know there are python plugins for Vim, but I am very confused as to where/how I can install these. I don't really understand where Vim is installed. I'm running the latest version of Mac OS X Snow Leopard. -Any help would be greatly appreciated. Thanks!","for mac os x, the vimrc file is located in /usr/share/vim directory -edit the vimdc file with any text editor. Add the syntax on to the last line of the file. Then next time you start a file you can see color. This is a system wide setting. In other linux flavor it may be located in /etc/ you can find this file by find /etc -name vimdc. The edit will affect all the users on the machine. -These setting can overwritten by the $HOME/.vimrc file. In your home you may also have a .vim directory. To check that you have these, do ls -a in your home directory.",0.0,False,2,1008 2011-01-11 11:06:46.727,Login hook on Google Appengine,"Every time a user logs in to the application, I want to perform a certain task, say, record the time of login. So I wanted to know if a hook is fired on login by default? If yes, how can I make my module respond to it. Edit - Assume there are multiple entry points in the application to login.","I'm using Python on GAE (so it may be different for Java) but have seen no documentation about such a hook for a user logging in. If you used one of the session management frameworks you'd probably get some indication for that, but otherwise I do this kind of house keeping on my opening page itself which requires login. (What do you want to do about an already logged in user returning to your site a few days later... that is, do you really want to record logins or the start time of a visit/session??) If I wanted to do this but with multiple landing pages, and without using a session framework, @@ -11620,8 +11620,7 @@ What would be the best technique to allow this through the web application ? I w I saw existing products doing similar things (webmin, eBox, ...) but I don't know how it works. PS: The classes I received are simple but really badly programmed and barely commented. They are actually in PHP but I'm planning to port them to python. Then I'd like to use the Django framework to build the web admin interface. Thanks and sorry if the question is not clear enough. -EDIT: I read a little bit about webmin and saw that it uses its own mini web server (called miniserv.pl). It seems like a good solution. The user running this server should then have permissions to modify the files and use the commands. How could I do something similar with Django? Use the development server? Would it be better to use something like CherryPy?","Hello -You can easily create web applications in Python using WSGI-compliant web frameworks such as CherryPy2 and templating engines such as Genshi. You can use the 'subprocess' module to manadge external commands...",1.2,True,2,1010 +EDIT: I read a little bit about webmin and saw that it uses its own mini web server (called miniserv.pl). It seems like a good solution. The user running this server should then have permissions to modify the files and use the commands. How could I do something similar with Django? Use the development server? Would it be better to use something like CherryPy?",You can use sudo to give the apache user root permission for only the commands/scripts you need for your web app.,0.0,False,2,1010 2011-01-13 13:44:56.187,Modify system configuration files and use system commands through web interface,"I received a project recently and I am wondering how to do something in a correct and secure manner. The situation is the following: There are classes to manage linux users, mysql users and databases and apache virtual hosts. They're used to automate the addition of users in a small shared-hosting environnement. These classes are then used in command-line scripts to offer a nice interface for the system administrator. @@ -11631,9 +11630,10 @@ What would be the best technique to allow this through the web application ? I w I saw existing products doing similar things (webmin, eBox, ...) but I don't know how it works. PS: The classes I received are simple but really badly programmed and barely commented. They are actually in PHP but I'm planning to port them to python. Then I'd like to use the Django framework to build the web admin interface. Thanks and sorry if the question is not clear enough. -EDIT: I read a little bit about webmin and saw that it uses its own mini web server (called miniserv.pl). It seems like a good solution. The user running this server should then have permissions to modify the files and use the commands. How could I do something similar with Django? Use the development server? Would it be better to use something like CherryPy?",You can use sudo to give the apache user root permission for only the commands/scripts you need for your web app.,0.0,False,2,1010 -2011-01-13 18:17:37.427,Call a program written in python in a program written in Ocaml,"I wanted to ask if you could call in a program written in Ocaml a program written in python , and if the answer is yes how do I do?","It depends on your exact requirements, but you can use pythons os.system() to execute an program in the same way you would call it from the command line. That should be a good starting point.",-0.0679224682270276,False,2,1011 +EDIT: I read a little bit about webmin and saw that it uses its own mini web server (called miniserv.pl). It seems like a good solution. The user running this server should then have permissions to modify the files and use the commands. How could I do something similar with Django? Use the development server? Would it be better to use something like CherryPy?","Hello +You can easily create web applications in Python using WSGI-compliant web frameworks such as CherryPy2 and templating engines such as Genshi. You can use the 'subprocess' module to manadge external commands...",1.2,True,2,1010 2011-01-13 18:17:37.427,Call a program written in python in a program written in Ocaml,"I wanted to ask if you could call in a program written in Ocaml a program written in python , and if the answer is yes how do I do?","You can execute commands using Sys.command, so you can just do Sys.command ""python foo.py"", assuming python is in your path and foo.py is in the current directory.",0.1352210990936997,False,2,1011 +2011-01-13 18:17:37.427,Call a program written in python in a program written in Ocaml,"I wanted to ask if you could call in a program written in Ocaml a program written in python , and if the answer is yes how do I do?","It depends on your exact requirements, but you can use pythons os.system() to execute an program in the same way you would call it from the command line. That should be a good starting point.",-0.0679224682270276,False,2,1011 2011-01-14 12:10:10.240,"My python program always brings down my internet connection after several hours running, how do I debug and fix this problem?","I'm writing a python script checking/monitoring several server/websites status(response time and similar stuff), it's a GUI program and I use separate thread to check different server/website, and the basic structure of each thread is using an infinite while loop to request that site every random time period(15 to 30 seconds), once there's changes in website/server each thread will start a new thread to do a thorough check(requesting more pages and similar stuff). The problem is, my internet connection always got blocked/jammed/messed up after several hours running of this script, the situation is, from my script side I got urlopen error timed out each time it's requesting a page, and from my FireFox browser side I cannot open any site. But the weird thing is, the moment I close my script my Internet connection got back on immediately which means now I can surf any site through my browser, so it must be the script causing all the problem. I've checked the program carefully and even use del to delete any connection once it's used, still get the same problem. I only use urllib2, urllib, mechanize to do network requests. @@ -11738,6 +11738,10 @@ If your string is s: max((j-i,s[i:j]) for i in range(len(s)-1) for j in range(i+2,len(s)+1) if s[i:j]==s[j-1:i-1:-1])[1] will return the answer.",0.0,False,1,1022 2011-01-20 04:40:25.377,When should a Python script be split into multiple files/modules?,"In Java, this question is easy (if a little tedious) - every class requires its own file. So the number of .java files in a project is the number of classes (not counting anonymous/nested classes). +In Python, though, I can define multiple classes in the same file, and I'm not quite sure how to find the point at which I split things up. It seems wrong to make a file for every class, but it also feels wrong just to leave everything in the same file by default. How do I know where to break a program up?","As I see it, this is really a question about reuse and abstraction. If you have a problem that you can solve in a very general way, so that the resulting code would be useful in many other programs, put it in its own module. +For example: a while ago I wrote a (bad) mpd client. I wanted to make configuration file and option parsing easy, so I created a class that combined ConfigParser and optparse functionality in a way I thought was sensible. It needed a couple of support classes, so I put them all together in a module. I never use the client, but I've reused the configuration module in other projects. +EDIT: Also, a more cynical answer just occurred to me: if you can only solve a problem in a really ugly way, hide the ugliness in a module. :)",0.296905446847765,False,3,1023 +2011-01-20 04:40:25.377,When should a Python script be split into multiple files/modules?,"In Java, this question is easy (if a little tedious) - every class requires its own file. So the number of .java files in a project is the number of classes (not counting anonymous/nested classes). In Python, though, I can define multiple classes in the same file, and I'm not quite sure how to find the point at which I split things up. It seems wrong to make a file for every class, but it also feels wrong just to leave everything in the same file by default. How do I know where to break a program up?","In Java ... every class requires its own file. On the flipside, sometimes a Java file, also, will include enums or subclasses or interfaces, within the main class because they are ""closely related."" @@ -11754,10 +11758,6 @@ For good examples, have a look in the Python built-in modules. Just download the source and check them out, the rule of thumb I follow is when you have very tightly coupled classes or functions you keep them in a single file else you break them up.",0.0,False,3,1023 -2011-01-20 04:40:25.377,When should a Python script be split into multiple files/modules?,"In Java, this question is easy (if a little tedious) - every class requires its own file. So the number of .java files in a project is the number of classes (not counting anonymous/nested classes). -In Python, though, I can define multiple classes in the same file, and I'm not quite sure how to find the point at which I split things up. It seems wrong to make a file for every class, but it also feels wrong just to leave everything in the same file by default. How do I know where to break a program up?","As I see it, this is really a question about reuse and abstraction. If you have a problem that you can solve in a very general way, so that the resulting code would be useful in many other programs, put it in its own module. -For example: a while ago I wrote a (bad) mpd client. I wanted to make configuration file and option parsing easy, so I created a class that combined ConfigParser and optparse functionality in a way I thought was sensible. It needed a couple of support classes, so I put them all together in a module. I never use the client, but I've reused the configuration module in other projects. -EDIT: Also, a more cynical answer just occurred to me: if you can only solve a problem in a really ugly way, hide the ugliness in a module. :)",0.296905446847765,False,3,1023 2011-01-20 20:52:13.923,How to determine content type of a string,"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? Thanks.","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. Another 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",0.1016881243684853,False,2,1024 @@ -11795,9 +11795,7 @@ He is using Mac OS X, and I have no experience in installing stuff on mac os X o I believe that getting my backend to run on his computer might be somewhat troublesome, i.e. I have to install a bunch of plugins (which are not available on pip or easy_install as they are the latest version) and I have also made heavy modification to django-socialregistration which I am currently using by symlinking to the modified code in my repos in my python path I tried to look into solutions like pip and easy_install but I have not been able to get them to install code from github -I think the easiest way is to get my backend working on his computer and then he just commiting to the repos. Any ideas how I can make this easy?","An alternative, if that's possible, would be to set up a testing/development environment on a machine with an OS you're familiar with, then install something like Dropbox on his local machine where he can develop the frontend code, and install Dropbox on that other environment with the backend components. Dropbox would sync his local changes to that testing environment for him to run the code on. -That way, he would be able to use that environment to test his code, you wouldn't need to set up a backend on his machine (or keep it up to date) and you'd still be getting the same functionality. -Again, if that's an option.",0.0,False,2,1027 +I think the easiest way is to get my backend working on his computer and then he just commiting to the repos. Any ideas how I can make this easy?","Get him to set up a virtual machine on his Mac, using VMWare Fusion or Parallels, running the same operating system that you currently use for your back end. If he prefers developing using Mac tools he can do still that by sharing his local changes to the virtual machine via a shared directory.",0.1352210990936997,False,2,1027 2011-01-23 23:25:00.063,Easiest way to share work between backend and front end,"Hey everyone, I am expanding my team and I have recently added an additional front end engineer on my site. I am currently using django to run my site but my site is using a lot of plugins, namely: django-celery, django-mailer, django-notification, and django-socialregistration. Let me describe my situation: @@ -11806,15 +11804,17 @@ He is using Mac OS X, and I have no experience in installing stuff on mac os X o I believe that getting my backend to run on his computer might be somewhat troublesome, i.e. I have to install a bunch of plugins (which are not available on pip or easy_install as they are the latest version) and I have also made heavy modification to django-socialregistration which I am currently using by symlinking to the modified code in my repos in my python path I tried to look into solutions like pip and easy_install but I have not been able to get them to install code from github -I think the easiest way is to get my backend working on his computer and then he just commiting to the repos. Any ideas how I can make this easy?","Get him to set up a virtual machine on his Mac, using VMWare Fusion or Parallels, running the same operating system that you currently use for your back end. If he prefers developing using Mac tools he can do still that by sharing his local changes to the virtual machine via a shared directory.",0.1352210990936997,False,2,1027 +I think the easiest way is to get my backend working on his computer and then he just commiting to the repos. Any ideas how I can make this easy?","An alternative, if that's possible, would be to set up a testing/development environment on a machine with an OS you're familiar with, then install something like Dropbox on his local machine where he can develop the frontend code, and install Dropbox on that other environment with the backend components. Dropbox would sync his local changes to that testing environment for him to run the code on. +That way, he would be able to use that environment to test his code, you wouldn't need to set up a backend on his machine (or keep it up to date) and you'd still be getting the same functionality. +Again, if that's an option.",0.0,False,2,1027 +2011-01-25 01:09:53.203,"In Django, how do I check if a user is in a certain group?","I created a custom group in Django's admin site. +In my code, I want to check if a user is in this group. How do I do that?","User.objects.filter(username='tom', groups__name='admin').exists() +That query will inform you user : ""tom"" whether belong to group ""admin "" or not",0.0,False,2,1028 2011-01-25 01:09:53.203,"In Django, how do I check if a user is in a certain group?","I created a custom group in Django's admin site. In my code, I want to check if a user is in this group. How do I do that?","If a user belongs to a certain group or not, can be checked in django templates using: {% if group in request.user.groups.all %} ""some action"" {% endif %}",0.3322620828091938,False,2,1028 -2011-01-25 01:09:53.203,"In Django, how do I check if a user is in a certain group?","I created a custom group in Django's admin site. -In my code, I want to check if a user is in this group. How do I do that?","User.objects.filter(username='tom', groups__name='admin').exists() -That query will inform you user : ""tom"" whether belong to group ""admin "" or not",0.0,False,2,1028 2011-01-25 09:35:18.920,Python: how can I get a thread to kill itself after a timeout?,"I'm writing a multi threaded Python app that makes many TCP connections to servers. Each connection is done on a separate thread. Sometimes the thread hangs for a long time which I don't want. How can I get the thread to kill itself after some given time period? From the main thread how can I determine that the child thread killed itself? If possible I would appreciate a snippet of code showing how to do this. Thanks. Update @@ -11843,16 +11843,16 @@ any suggestion is appreciated.","If all you're doing is showing one file, then a sizer.Add(myTxtCtrl, 0, wx.EXPAND) Then the user can see the file and you can save the data with a Save button or menu item. The handler for that would basically just grab the text control's contents using it's GetValue() method.",0.0,False,1,1033 2011-01-26 16:17:41.890,How are strings compared?,"I'm wondering how Python does string comparison, more specifically how it determines the outcome when a less than < or greater than > operator is used. +For instance if I put print('abc' < 'bac') I get True. I understand that it compares corresponding characters in the string, however its unclear as to why there is more, for lack of a better term, ""weight"" placed on the fact that a is less thanb (first position) in first string rather than the fact that a is less than b in the second string (second position).","The comparison uses lexicographical ordering +For Python 3: Convert it into Unicode to get its order or number that is being used as ""weightage"" here +For Python 2: Use ASCII to get its order or number that is being used as ""weightage"" here +People already answered it in detail, I am leaving it here for anyone who is in a hurry :)",0.0,False,2,1034 +2011-01-26 16:17:41.890,How are strings compared?,"I'm wondering how Python does string comparison, more specifically how it determines the outcome when a less than < or greater than > operator is used. For instance if I put print('abc' < 'bac') I get True. I understand that it compares corresponding characters in the string, however its unclear as to why there is more, for lack of a better term, ""weight"" placed on the fact that a is less thanb (first position) in first string rather than the fact that a is less than b in the second string (second position).","Python and just about every other computer language use the same principles as (I hope) you would use when finding a word in a printed dictionary: (1) Depending on the human language involved, you have a notion of character ordering: 'a' < 'b' < 'c' etc (2) First character has more weight than second character: 'az' < 'za' (whether the language is written left-to-right or right-to-left or boustrophedon is quite irrelevant) (3) If you run out of characters to test, the shorter string is less than the longer string: 'foo' < 'food' Typically, in a computer language the ""notion of character ordering"" is rather primitive: each character has a human-language-independent number ord(character) and characters are compared and sorted using that number. Often that ordering is not appropriate to the human language of the user, and then you need to get into ""collating"", a fun topic.",0.3869120172231254,False,2,1034 -2011-01-26 16:17:41.890,How are strings compared?,"I'm wondering how Python does string comparison, more specifically how it determines the outcome when a less than < or greater than > operator is used. -For instance if I put print('abc' < 'bac') I get True. I understand that it compares corresponding characters in the string, however its unclear as to why there is more, for lack of a better term, ""weight"" placed on the fact that a is less thanb (first position) in first string rather than the fact that a is less than b in the second string (second position).","The comparison uses lexicographical ordering -For Python 3: Convert it into Unicode to get its order or number that is being used as ""weightage"" here -For Python 2: Use ASCII to get its order or number that is being used as ""weightage"" here -People already answered it in detail, I am leaving it here for anyone who is in a hurry :)",0.0,False,2,1034 2011-01-26 17:46:02.463,Automatic indexes for expando properties in the google app engine for python,"The google app engine python sdk offers an Expando type object which can be used for adding dynamic properties to an object that can be persisted to the datastore. The app engine also requires that for any property on which the objects need to be searched or sorted, an index must be created before uploading the app to google's servers. This is really strange because it means that i am supposed to know before hand what properties my users will create on my objects. If i knew that in advance, why would i not define them as static properties in my existing model? Does anyone know how to automatically create indexes for dynamic properties of Expando models after uploading to the app engine? If not, can anyone tell me why does the gae tout Expando as dynamic construct when it can not let you create new properties that can be searched on or sorted by, only properties that arent searchable or sortable.","All properties are automatically indexed for simple queries. Simple queries, in this case, are those that either: @@ -11953,8 +11953,11 @@ PATH=""/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"" PATH=$PATH:/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted export PATH Any ideas how I can get 2.7.1 to see the Twisted install? Or am I trying to do something that just can't be done? -thanks.","Create an environment using virtualenv. -Install Twisted in your newly created environment using pip.",0.2012947653214861,False,3,1047 +thanks.","You'll need to install Twisted into your Python 2.7 installation somehow. The ""2.6"" in that path should be a hint that you shouldn't be trying to tell Python 2.7 about it. Among other things: + +Extension modules are not compatible between python versions. You may get a segfault if you try to use them. +Bytecode formats are not compatible between python versions. Python will fall back to parsing '.py' files, which is slower. +If you're using an operating system that ships with Python 2.6, there is a good chance that the version of Twisted included is not compatible with Python 2.7, since Python 2.7 may not have been out yet when it was released.",1.2,True,3,1047 2011-02-01 23:46:32.170,Python 2.7.1 can't see Twisted,"I have a new MacBook Pro running OS X 10.6.6 / Snow Leopard -- which ships with Python 2.6, although I have installed 2.7.1 Unfortunately, this doesn't seem to see the Twisted install in the 2.6/Extras/lib/python/twisted directory, as I find I'm unable to import modules that I can see are present in that directory. ""which python"" returns ""/Library/Frameworks/Python.framework/Versions/2.7/bin/python"" @@ -11964,11 +11967,8 @@ PATH=""/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"" PATH=$PATH:/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted export PATH Any ideas how I can get 2.7.1 to see the Twisted install? Or am I trying to do something that just can't be done? -thanks.","You'll need to install Twisted into your Python 2.7 installation somehow. The ""2.6"" in that path should be a hint that you shouldn't be trying to tell Python 2.7 about it. Among other things: - -Extension modules are not compatible between python versions. You may get a segfault if you try to use them. -Bytecode formats are not compatible between python versions. Python will fall back to parsing '.py' files, which is slower. -If you're using an operating system that ships with Python 2.6, there is a good chance that the version of Twisted included is not compatible with Python 2.7, since Python 2.7 may not have been out yet when it was released.",1.2,True,3,1047 +thanks.","Create an environment using virtualenv. +Install Twisted in your newly created environment using pip.",0.2012947653214861,False,3,1047 2011-02-02 16:08:27.567,Recursive use of Scrapy to scrape webpages from a website,"I have recently started to work with Scrapy. I am trying to gather some info from a large list which is divided into several pages(about 50). I can easily extract what I want from the first page including the first page in the start_urls list. However I don't want to add all the links to these 50 pages to this list. I need a more dynamic way. Does anyone know how I can iteratively scrape web pages? Does anyone have any examples of this? Thanks!","Why don't you want to add all the links to 50 pages? Are the URLs of the pages consecutive like www.site.com/page=1, www.site.com/page=2 or are they all distinct? Can you show me the code that you have now?",0.0,False,2,1048 2011-02-02 16:08:27.567,Recursive use of Scrapy to scrape webpages from a website,"I have recently started to work with Scrapy. I am trying to gather some info from a large list which is divided into several pages(about 50). I can easily extract what I want from the first page including the first page in the start_urls list. However I don't want to add all the links to these 50 pages to this list. I need a more dynamic way. Does anyone know how I can iteratively scrape web pages? Does anyone have any examples of this? @@ -12033,16 +12033,16 @@ The things I considered are: 1. Creating a Windows service 2. Using a script in python (I have cygwin installed) 3. Scheduled task using a batch file (although I don't want the black cmd window to pop up in my face every minute) -Thanks for any additional ideas or hints on how to best implement it.","If you have cygwin, you probably have cron - run a python script from your crontab.",0.2655860252697744,False,2,1057 +Thanks for any additional ideas or hints on how to best implement it.","This is trivially easy with a scheduled task which is the native Windows way to schedule tasks! There's no need for cygwin or Python or anything like that. +I have such a task running on my machine which pokes my Wordpress blog every few hours. The script is just a .bat file which calls wget. The task is configured to ""Run whether user is logged on or not"" which ensures that it runs when I'm not logged on. There's no ""black cmd window"". +You didn't say which version of Windows you are on and if you are on XP (unlucky for you if you are) then the configuration is probably different since the scheduled task interface changed quite a bit when Vista came out.",0.1352210990936997,False,2,1057 2011-02-08 15:56:27.033,How to periodically create an HTTP POST request from windows,"I need to install on one of my Windows PC's some software that will periodically send a short HTTP POST request to my remote development server. The request is always the same and should get sent every minute. What would you recommend as the best approach for that? The things I considered are: 1. Creating a Windows service 2. Using a script in python (I have cygwin installed) 3. Scheduled task using a batch file (although I don't want the black cmd window to pop up in my face every minute) -Thanks for any additional ideas or hints on how to best implement it.","This is trivially easy with a scheduled task which is the native Windows way to schedule tasks! There's no need for cygwin or Python or anything like that. -I have such a task running on my machine which pokes my Wordpress blog every few hours. The script is just a .bat file which calls wget. The task is configured to ""Run whether user is logged on or not"" which ensures that it runs when I'm not logged on. There's no ""black cmd window"". -You didn't say which version of Windows you are on and if you are on XP (unlucky for you if you are) then the configuration is probably different since the scheduled task interface changed quite a bit when Vista came out.",0.1352210990936997,False,2,1057 +Thanks for any additional ideas or hints on how to best implement it.","If you have cygwin, you probably have cron - run a python script from your crontab.",0.2655860252697744,False,2,1057 2011-02-08 16:08:48.393,Detecting Type of Video Stream,"I have 2 video streams (1) VLC Generated Compressed MP4 UDP stream (2) DV Uncompressed UDP Stream @@ -12102,9 +12102,9 @@ the multiprocessing module (which uses a similar interface to threading) All of these are available in the Python standard library (2.6 and later), and you can get the multiprocessing module for earlier versions as well (it just wasn't packaged with Python yet).",0.0,False,1,1064 2011-02-10 20:21:47.337,Python - Dijkstra's Algorithm,"I need to implement Dijkstra's Algorithm in Python. However, I have to use a 2D array to hold three pieces of information - predecessor, length and unvisited/visited. -I know in C a Struct can be used, though I am stuck on how I can do a similar thing in Python, I am told it's possible but I have no idea to be honest",Encapsulate that information in a Python object and you should be fine.,0.0814518047658113,False,2,1065 -2011-02-10 20:21:47.337,Python - Dijkstra's Algorithm,"I need to implement Dijkstra's Algorithm in Python. However, I have to use a 2D array to hold three pieces of information - predecessor, length and unvisited/visited. I know in C a Struct can be used, though I am stuck on how I can do a similar thing in Python, I am told it's possible but I have no idea to be honest",Python is object oriented language. So think of it like moving from Structs in C to Classes of C++. You can use the same class structure in Python as well.,0.0,False,2,1065 +2011-02-10 20:21:47.337,Python - Dijkstra's Algorithm,"I need to implement Dijkstra's Algorithm in Python. However, I have to use a 2D array to hold three pieces of information - predecessor, length and unvisited/visited. +I know in C a Struct can be used, though I am stuck on how I can do a similar thing in Python, I am told it's possible but I have no idea to be honest",Encapsulate that information in a Python object and you should be fine.,0.0814518047658113,False,2,1065 2011-02-11 07:16:03.690,creating Python classes with arbitrarily substituted attribute name,"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. I have defined a class with an attribute 'spam': @@ -12148,18 +12148,18 @@ It is a bit long to write the skeleton, but I think it is faster (I mean at runt The typical way I've seen this done is some variant of an undo stack and each action will need to know how to undo itself, and then if a child action is cancelled the undo's cascade their way up. Sometimes writing undo methods are tricky and there isn't always enough information in context to properly know how to undo an action in an isolated manner. I just thought of a (potentially) easier way which is to just pickle the state of the (relevant parts of) program, and then the cancel would just restore to it's former state, without needing to create separate undo logic for each action. Has anyone tried this? Any gotchas to watch out for? Any reason not to do this? -Edit: The dependent actions must happen after the parent action (and even whether there are dependent actions may depend on the result of the parent action), so just checking all the dependencies before doing anything isn't an option. I guess you could say an action triggers other actions, but if one of the triggered actions cannot be performed, then none of it happened.","Well, as you mentioned the data design is loosely coupled, so you I don't think you need to pickle it if it's in memory. Just take a copy of all the relevant variables, and the transaction.abort() would just copy them back, and transaction.commit() would then just remove the copy of the data. -There are issues, but none that you don't have with the pickle solution.",1.2,True,2,1069 -2011-02-13 19:50:26.027,"Using pickle for in-memory ""transaction""?","A user can perform an action, which may trigger dependent actions (which themselves may have dependent actions) and I want to be able to cancel the whole thing if the user cancels a dependent action. -The typical way I've seen this done is some variant of an undo stack and each action will need to know how to undo itself, and then if a child action is cancelled the undo's cascade their way up. Sometimes writing undo methods are tricky and there isn't always enough information in context to properly know how to undo an action in an isolated manner. -I just thought of a (potentially) easier way which is to just pickle the state of the (relevant parts of) program, and then the cancel would just restore to it's former state, without needing to create separate undo logic for each action. -Has anyone tried this? Any gotchas to watch out for? Any reason not to do this? Edit: The dependent actions must happen after the parent action (and even whether there are dependent actions may depend on the result of the parent action), so just checking all the dependencies before doing anything isn't an option. I guess you could say an action triggers other actions, but if one of the triggered actions cannot be performed, then none of it happened.","You can use pickle to store your state if all elements of state are serializable (usually they are). The only reasons for not doing so: if you have to store pointers to any objects that are not saved in state, you will have problems with these pointers after performing undo operation. this method could be expensive, depending on the size of your state. Also you can use zip() to lower memory usage in exchange of raising CPU usage.",0.2012947653214861,False,2,1069 +2011-02-13 19:50:26.027,"Using pickle for in-memory ""transaction""?","A user can perform an action, which may trigger dependent actions (which themselves may have dependent actions) and I want to be able to cancel the whole thing if the user cancels a dependent action. +The typical way I've seen this done is some variant of an undo stack and each action will need to know how to undo itself, and then if a child action is cancelled the undo's cascade their way up. Sometimes writing undo methods are tricky and there isn't always enough information in context to properly know how to undo an action in an isolated manner. +I just thought of a (potentially) easier way which is to just pickle the state of the (relevant parts of) program, and then the cancel would just restore to it's former state, without needing to create separate undo logic for each action. +Has anyone tried this? Any gotchas to watch out for? Any reason not to do this? +Edit: The dependent actions must happen after the parent action (and even whether there are dependent actions may depend on the result of the parent action), so just checking all the dependencies before doing anything isn't an option. I guess you could say an action triggers other actions, but if one of the triggered actions cannot be performed, then none of it happened.","Well, as you mentioned the data design is loosely coupled, so you I don't think you need to pickle it if it's in memory. Just take a copy of all the relevant variables, and the transaction.abort() would just copy them back, and transaction.commit() would then just remove the copy of the data. +There are issues, but none that you don't have with the pickle solution.",1.2,True,2,1069 2011-02-14 15:39:10.450,PyObjC tutorial without Xcode,"I'm writing a small cross-platform wxPython app, however on every platform I need to use some platform-specific API. On Mac OS it can be done using PyObjC. I'm searching for tutorial on how to use PyObjC. However, all I found so far were tutorials with Xcode. I want my app to be able to run on mac/win/lin, without changes, and I don't want to develop it in Xcode. Is there a way? UPD. To be more specific I need to access some pen-tablet events from Mac OS X and I wanted to use PyObjC for that (I don't see any other ways).","What do you need Xcode for? If you need it for the windows/gui (*.nib, *.xib files), then you should perhaps search for 'creating *.nib, *xib without Xcode'. @@ -12206,7 +12206,7 @@ Browser has Form(s) (used to be mechanize-handled) Now, 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. So 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. Part 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. -Much 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.","Have you considered Twisted, the asynchronous library, for at least doing interaction with users?",0.0,False,2,1074 +Much 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.","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.",1.2,True,2,1074 2011-02-15 11:22:29.520,Python web-scraping threaded performance,"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). The basic layout of what I'm trying to do is as follows. All are objects. @@ -12217,7 +12217,7 @@ Browser has Form(s) (used to be mechanize-handled) Now, 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. So 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. Part 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. -Much 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.","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.",1.2,True,2,1074 +Much 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.","Have you considered Twisted, the asynchronous library, for at least doing interaction with users?",0.0,False,2,1074 2011-02-15 16:30:05.647,How do I find text features and print them?,"I have just started using Natural Language Toolkit (NLTK) as a part of my Engineering college project. Can anybody please tell me how do I read an input paragraph text and 1) break it down into textual components i.e into number of sentences, number of words, number of characters and number of polysyllabic or complex words in the given paragraph and @@ -12225,15 +12225,15 @@ and For the rest, look at the nltk.tokenize module & nltk.probability.FreqDist.",0.0,False,1,1075 2011-02-15 20:26:47.033,How does the nosetests sqlalchemy plugin work?,"The python unit testing framework called nosetest has a plugin for sqlalchemy, however there is no documentation for it that I can find. I'd like to know how it works, and if possible, see a code example.","It is my understanding that this plugin is only meant for unit testing SQLAlchemy itself and not as a general tool. Perhaps that is why there are no examples or documentation? Posting to the SQLAlchemy mailing list is likely to give you a better answer ""straight from the horse's mouth"".",0.0,False,1,1076 2011-02-16 00:25:38.887,python tornado setup,"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) -Tornado 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?","Use Django. -I'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.",1.2,True,4,1077 -2011-02-16 00:25:38.887,python tornado setup,"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) Tornado 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?","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. It's highly recomended to use nginx for serving static files and proxying dynamic requests to the tornado application instance.",0.0,False,4,1077 2011-02-16 00:25:38.887,python tornado setup,"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) -Tornado 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?",if you using tornado for websockets you can use ha-proxy for proxying socket request to tornado (ngnix not support this),0.0814518047658113,False,4,1077 +Tornado 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?","Use Django. +I'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.",1.2,True,4,1077 2011-02-16 00:25:38.887,python tornado setup,"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) Tornado 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?",If you are using tornado follow nginx.,0.0,False,4,1077 +2011-02-16 00:25:38.887,python tornado setup,"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) +Tornado 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?",if you using tornado for websockets you can use ha-proxy for proxying socket request to tornado (ngnix not support this),0.0814518047658113,False,4,1077 2011-02-16 03:31:32.177,Simple wxPython Frame Contents Resizing - Ratio?,"I have a wxPython app with one frame and one panel. On that panel are a number of static boxes, each of which has buttons and textboxes. I have just begun reading about sizers, but they seem like they might be more than what I need, or it could that they are exactly what I need but I don't know how to use them correctly! The frame currently opens at 1920 x 1080. If the user drags the bottom right corner to resize the app, I just want everything to get smaller or larger as needed to keep the same size ratio. @@ -12318,12 +12318,12 @@ However, I do have the Start Menu short cut and all the program files installed. 2011-02-21 08:17:47.070,Correct way of implementing database-wide functionality,"I'm creating a small website with Django, and I need to calculate statistics with data taken from several tables in the database. For example (nothing to do with my actual models), for a given user, let's say I want all birthday parties he has attended, and people he spoke with in said parties. For this, I would need a wide query, accessing several tables. Now, from the object-oriented perspective, it would be great if the User class implemented a method that returned that information. From a database model perspective, I don't like at all the idea of adding functionality to a ""row instance"" that needs to query other tables. I would like to keep all properties and methods in the Model classes relevant to that single row, so as to avoid scattering the business logic all over the place. -How should I go about implementing database-wide queries that, from an object-oriented standpoint, belong to a single object? Should I have an external kinda God-object that knows how to collect and organize this information? Or is there a better, more elegant solution?","I recommend extending Django's Model-Template-View approach with a controller. I usually have a controller.py within my apps which is the only interface to the data sources. So in your above case I'd have something like get_all_parties_and_people_for_user(user). -This is especially useful when your ""data taken from several tables in the database"" becomes ""data taken from several tables in SEVERAL databases"" or even ""data taken from various sources, e.g. databases, cache backends, external apis, etc."".",1.2,True,2,1090 +How should I go about implementing database-wide queries that, from an object-oriented standpoint, belong to a single object? Should I have an external kinda God-object that knows how to collect and organize this information? Or is there a better, more elegant solution?","User.get_attended_birthday_parties() or Event.get_attended_parties(user) work fine: it's an interface that makes sense when you use it. Creating an additional ""all-purpose"" object will not make your code cleaner or easier to maintain.",0.0,False,2,1090 2011-02-21 08:17:47.070,Correct way of implementing database-wide functionality,"I'm creating a small website with Django, and I need to calculate statistics with data taken from several tables in the database. For example (nothing to do with my actual models), for a given user, let's say I want all birthday parties he has attended, and people he spoke with in said parties. For this, I would need a wide query, accessing several tables. Now, from the object-oriented perspective, it would be great if the User class implemented a method that returned that information. From a database model perspective, I don't like at all the idea of adding functionality to a ""row instance"" that needs to query other tables. I would like to keep all properties and methods in the Model classes relevant to that single row, so as to avoid scattering the business logic all over the place. -How should I go about implementing database-wide queries that, from an object-oriented standpoint, belong to a single object? Should I have an external kinda God-object that knows how to collect and organize this information? Or is there a better, more elegant solution?","User.get_attended_birthday_parties() or Event.get_attended_parties(user) work fine: it's an interface that makes sense when you use it. Creating an additional ""all-purpose"" object will not make your code cleaner or easier to maintain.",0.0,False,2,1090 +How should I go about implementing database-wide queries that, from an object-oriented standpoint, belong to a single object? Should I have an external kinda God-object that knows how to collect and organize this information? Or is there a better, more elegant solution?","I recommend extending Django's Model-Template-View approach with a controller. I usually have a controller.py within my apps which is the only interface to the data sources. So in your above case I'd have something like get_all_parties_and_people_for_user(user). +This is especially useful when your ""data taken from several tables in the database"" becomes ""data taken from several tables in SEVERAL databases"" or even ""data taken from various sources, e.g. databases, cache backends, external apis, etc."".",1.2,True,2,1090 2011-02-21 13:28:07.667,Pylons - how to use an old project in a new environment?,"I have an old project, it written under Python 2.5/2.6, Windows. We had Python 2.6/Win7/x64 now, and I tried to start it. I got the old project that running nondebug mode in a server, and @@ -12425,9 +12425,9 @@ In other words, if total_values in database are 5,8,10,25 and a user enters a to Thanks!","You could get the count of number of entities that have total_value less than or equal to the current users total_value. You could use the count() method to do so (on a Query object).",0.1352210990936997,False,1,1100 2011-02-24 16:43:51.370,async http request on Google App Engine Python,"Does anybody know how to make http request from Google App Engine without waiting a response? -It should be like a push data with http without latency for response.","I've done this before by setting doing a URLFetch and setting a very low value for the deadline parameter. I put 0.1 as my value, so 100ms. You need to wrap the URLFetch in a try/catch also since the request will timeout.",0.0,False,2,1101 -2011-02-24 16:43:51.370,async http request on Google App Engine Python,"Does anybody know how to make http request from Google App Engine without waiting a response? It should be like a push data with http without latency for response.","Use the taskqueue. If you're just pushing data, there's no sense in waiting for the response.",0.2012947653214861,False,2,1101 +2011-02-24 16:43:51.370,async http request on Google App Engine Python,"Does anybody know how to make http request from Google App Engine without waiting a response? +It should be like a push data with http without latency for response.","I've done this before by setting doing a URLFetch and setting a very low value for the deadline parameter. I put 0.1 as my value, so 100ms. You need to wrap the URLFetch in a try/catch also since the request will timeout.",0.0,False,2,1101 2011-02-25 00:26:11.083,Python RGB array to HSL and back,"well i've seen some code to convert RGB to HSL; but how to do it fast in python. Its strange to me, that for example photoshop does this within a second on a image, while in python this often takes forever. Well at least the code i use; so think i'm using wrong code to do it In my case my image is a simple but big raw array [r,g,b,r,g,b,r,g,b ....] @@ -12444,6 +12444,19 @@ cannot use taskkill, as it is not available in some Windows installs e.g. home e tskill also doesn't work win32api.TerminateProcess(handle, 0) works, but i'm concerned it may cause memory leaks because i won't have the opportunity to close the handle (program immediately stops after calling TerminateProcess). note: Yup, I am force quitting it so there are bound to be some unfreed resources, but I want to minimize this as much as possible (as I will only do it only if it is taking an unbearable amount of time, for better user experience) but i don't think python will handle gc if it's force-quit. +I'm currently doing the last one, as it just works. I'm concerned though about the unfreed handle. Any thoughts/suggestions would be very much appreciated!","TerminateProcess and taskkill /f do not free resources and will result in memory leaks. +Here is the MS quote on terminateProcess: +{ ... Terminating a process does not cause child processes to be terminated. +Terminating a process does not necessarily remove the process object from the system. A process object is deleted when the last handle to the process is closed. ... } + MS heavily uses COM and DCOM, which share handles and resources the OS does not and can not track. ExitProcess should then be used instead, if you do not intend to reboot often. That allows a process to properly free the resources it used. Linux does not have this problem because it does not use COM or DCOM.",0.1352210990936997,False,2,1103 +2011-02-25 04:57:42.480,"In Windows using Python, how do I kill my process?","Edit: Looks like a duplicate, but I assure you, it's not. I'm looking to kill the current running process cleanly, not to kill a separate process. +The problem is the process I'm killing isn't spawned by subprocess or exec. It's basically trying to kill itself. +Here's the scenario: The program does cleanup on exit, but sometimes this takes too long. I am sure that I can terminate the program, because the first step in the quit saves the Database. How do I go about doing this? + +cannot use taskkill, as it is not available in some Windows installs e.g. home editions of XP +tskill also doesn't work +win32api.TerminateProcess(handle, 0) works, but i'm concerned it may cause memory leaks because i won't have the opportunity to close the handle (program immediately stops after calling TerminateProcess). note: Yup, I am force quitting it so there are bound to be some unfreed resources, but I want to minimize this as much as possible (as I will only do it only if it is taking an unbearable amount of time, for better user experience) but i don't think python will handle gc if it's force-quit. + I'm currently doing the last one, as it just works. I'm concerned though about the unfreed handle. Any thoughts/suggestions would be very much appreciated!","win32api.TerminateProcess(handle, 0) works, but i'm concerned it may cause memory leaks because i won't have the @@ -12461,22 +12474,9 @@ I'm currently doing the last one, as it just works. I'm concerned though about t If a process self-terminates, then you don't need to worry about garbage collection. The OS will automatically clean up all memory resources used by that process, so you don't have to worry about memory leaks. Memory leaks are when a process is running and using more and more memory as time goes by. So yes terminating your process this way isn't very ""clean"", but there wont be any ill side-effects.",1.2,True,2,1103 -2011-02-25 04:57:42.480,"In Windows using Python, how do I kill my process?","Edit: Looks like a duplicate, but I assure you, it's not. I'm looking to kill the current running process cleanly, not to kill a separate process. -The problem is the process I'm killing isn't spawned by subprocess or exec. It's basically trying to kill itself. -Here's the scenario: The program does cleanup on exit, but sometimes this takes too long. I am sure that I can terminate the program, because the first step in the quit saves the Database. How do I go about doing this? - -cannot use taskkill, as it is not available in some Windows installs e.g. home editions of XP -tskill also doesn't work -win32api.TerminateProcess(handle, 0) works, but i'm concerned it may cause memory leaks because i won't have the opportunity to close the handle (program immediately stops after calling TerminateProcess). note: Yup, I am force quitting it so there are bound to be some unfreed resources, but I want to minimize this as much as possible (as I will only do it only if it is taking an unbearable amount of time, for better user experience) but i don't think python will handle gc if it's force-quit. - -I'm currently doing the last one, as it just works. I'm concerned though about the unfreed handle. Any thoughts/suggestions would be very much appreciated!","TerminateProcess and taskkill /f do not free resources and will result in memory leaks. -Here is the MS quote on terminateProcess: -{ ... Terminating a process does not cause child processes to be terminated. -Terminating a process does not necessarily remove the process object from the system. A process object is deleted when the last handle to the process is closed. ... } - MS heavily uses COM and DCOM, which share handles and resources the OS does not and can not track. ExitProcess should then be used instead, if you do not intend to reboot often. That allows a process to properly free the resources it used. Linux does not have this problem because it does not use COM or DCOM.",0.1352210990936997,False,2,1103 +2011-02-25 17:31:22.673,Set ZipInfo mime type,"When creating zip archive using python ZipFile, how can i set file mime types?",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.,0.0,False,2,1104 2011-02-25 17:31:22.673,Set ZipInfo mime type,"When creating zip archive using python ZipFile, how can i set file mime types?","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. The 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.",1.2,True,2,1104 -2011-02-25 17:31:22.673,Set ZipInfo mime type,"When creating zip archive using python ZipFile, how can i set file mime types?",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.,0.0,False,2,1104 2011-02-25 22:22:41.010,How do I calculate the length of an x/y coordinate in Python?,"I'm constructing a program where the user clicks two points in the graphics window and the length of x and y must be shown. I've creating a clone and multiplying it by itself, but no luck. Any ideas? Thanks! Edit: My program is supposed to create a 'money bin' based off the users data and 2 point clicks in the graphics window. I need help figuring out how to get the 'length in x direction' after the user clicks 2 points on the graphics window. @@ -12528,13 +12528,8 @@ based on the output from that python script, a javascript script will perform so ive studied the replies to my previous posts and have found that what i want to accomplish is more or less accomplished by json. it is my understanding that json transforms 'program-specific' variables into a format that is more 'standard or general or global'. two different programs therefore now have the means to 'talk' with each other because they are now speaking the same 'language'. the problem is then this, how do i actually facilitate their communication? what is the 'cellphone' between these server side scripts? do they even need one? -thank you!","This probably isn't the answer that you are looking for, and without links to your previous posts, I don't have much to go on, but nonetheless... -javascript is client side. I can interpret your question 2 different ways... - -Your python script is running on your computer, and you want a script to actually alter your current browser window. -Not too sure, but writing a browser plugin may be the answer here. -Your python script is running on the server, and as a result of the script running, you want the display of your site to be changed for viewing persons. -In this case, you will could use ajax polling (or similar) on your site. Have your site be polling the server with ajax, call a server method that checks the output of the script (maybe written to a file?), and see if it has changed.",0.0,False,3,1108 +thank you!","I don't know Javascript or json, but... +if you've ever seen an Unix-like operating system, you know about pipes. Like program1 | program2 | program3 ... Why don't you just connect Python and Javascript programs with pipes? The first one writes to stdout, and the next one reads from stdin.",0.0,False,3,1108 2011-02-26 17:18:14.270,is json the answer to this: python program will talk and javascript will listen?,"the same problem haunting me a month ago is still haunting me now. i know ive asked several questions regarding this on this site and i am truly sorry for that. your suggestions have all been excellent but the answer is still elusive. i now realize that this is a direct result of me not being able to phrase my question properly and for that i am sorry. to give you guys a generalized view of things, here i go: the situation is like this, i have 2 server side scripts that i want to run. @@ -12558,8 +12553,13 @@ based on the output from that python script, a javascript script will perform so ive studied the replies to my previous posts and have found that what i want to accomplish is more or less accomplished by json. it is my understanding that json transforms 'program-specific' variables into a format that is more 'standard or general or global'. two different programs therefore now have the means to 'talk' with each other because they are now speaking the same 'language'. the problem is then this, how do i actually facilitate their communication? what is the 'cellphone' between these server side scripts? do they even need one? -thank you!","I don't know Javascript or json, but... -if you've ever seen an Unix-like operating system, you know about pipes. Like program1 | program2 | program3 ... Why don't you just connect Python and Javascript programs with pipes? The first one writes to stdout, and the next one reads from stdin.",0.0,False,3,1108 +thank you!","This probably isn't the answer that you are looking for, and without links to your previous posts, I don't have much to go on, but nonetheless... +javascript is client side. I can interpret your question 2 different ways... + +Your python script is running on your computer, and you want a script to actually alter your current browser window. +Not too sure, but writing a browser plugin may be the answer here. +Your python script is running on the server, and as a result of the script running, you want the display of your site to be changed for viewing persons. +In this case, you will could use ajax polling (or similar) on your site. Have your site be polling the server with ajax, call a server method that checks the output of the script (maybe written to a file?), and see if it has changed.",0.0,False,3,1108 2011-02-26 22:05:11.370,Jython Gstreamer,Does anyone know where I can find a tutorial on how to use GStreamer with Jython? I have tried searching but with no luck. Using the Gstreamer-Python bindings I can get a python file to run with python but jython gives me ImportError: No module named pygst.,"I suspect that it uses c bindings so you can not use in jython, sorry.",1.2,True,1,1109 2011-02-27 10:26:43.750,Why do we need to use rabbitmq,"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. Could you please provide a scenario or an example using RabbitMQ? @@ -12646,14 +12646,14 @@ how find all post from category title","Post.objects.all(catagory__title=""My ca 2011-03-02 13:36:51.387,Best way to save availability of user over days of week in python/django,"I want to store users preferences for day(s) of week he might be available. e.g. A user can be available on saturday, sunday but not on other days. Currently I am using array of 7 checkboxes(values=1,2,...7) so that user can select individual days of his availability. Now the first question is how can i store this in database. I am thinking of using a string(length=7) and storing preferences like 1100010 where 1 will signify available and 0 not available. Is it good practice? -Second question, how can I convert POST data ([""1"",""2"",""7""]) into string (1100010)","One other option is the more-or-less obvious one: define a table of the days of the week, and have a ManyToManyField map one to the other. The admin would just work, you can do searches based on dates, and it works on SQLite unlike some of the functions in django-bitfield. Searches can be fast, since they're within the database and you don't have to use SQL's LIKE (which ignores indexes if there are wildcards at the start of the string, which would be the case for CommaSeparatedIntegerField or a seven-character string). -Sure, it takes more storage, but how many users do you have, anyway? Millions? -P.S. if you have an ordering field in your weekday table, you can also make the database sort by day of week for you with something like queryset.order_by('available__order').",0.0679224682270276,False,2,1116 +Second question, how can I convert POST data ([""1"",""2"",""7""]) into string (1100010)","I'd go for separate boolean columns. +It'll be a lot easier for you to then query, say, for users that are available on mondays; or to count the number of users that available through every weekday, or whatever.",0.0,False,2,1116 2011-03-02 13:36:51.387,Best way to save availability of user over days of week in python/django,"I want to store users preferences for day(s) of week he might be available. e.g. A user can be available on saturday, sunday but not on other days. Currently I am using array of 7 checkboxes(values=1,2,...7) so that user can select individual days of his availability. Now the first question is how can i store this in database. I am thinking of using a string(length=7) and storing preferences like 1100010 where 1 will signify available and 0 not available. Is it good practice? -Second question, how can I convert POST data ([""1"",""2"",""7""]) into string (1100010)","I'd go for separate boolean columns. -It'll be a lot easier for you to then query, say, for users that are available on mondays; or to count the number of users that available through every weekday, or whatever.",0.0,False,2,1116 +Second question, how can I convert POST data ([""1"",""2"",""7""]) into string (1100010)","One other option is the more-or-less obvious one: define a table of the days of the week, and have a ManyToManyField map one to the other. The admin would just work, you can do searches based on dates, and it works on SQLite unlike some of the functions in django-bitfield. Searches can be fast, since they're within the database and you don't have to use SQL's LIKE (which ignores indexes if there are wildcards at the start of the string, which would be the case for CommaSeparatedIntegerField or a seven-character string). +Sure, it takes more storage, but how many users do you have, anyway? Millions? +P.S. if you have an ordering field in your weekday table, you can also make the database sort by day of week for you with something like queryset.order_by('available__order').",0.0679224682270276,False,2,1116 2011-03-02 20:02:59.663,how do I use the facebook api to modify a video title or description?,How can I update the title/description of a previously updated video? I am using python and pyfacebook... but any starting point would be fine and I can write it in python.,"I don't think it's possible to edit a Video object at all with the Graph API at the moment. You can't create objects through the API, therefore I don't think you can edit or modify existing ones either.",1.2,True,1,1117 2011-03-02 22:22:27.807,Execute .sql files that are used to run in SQL Management Studio in python,"As part of artifacts delivery, our developers give the data and structure scripts in .sql files. I usually ""double click"" on these files to open in ""Microsoft SQL Server Management Studio"". Management studio will prompt me for entering database server and user/pwd. I enter them manually and click on Execute button to execute these scripts. These scripts contain structure and data sql commands. Each script may contain more than one data command (like select, insert, update, etc). Structure and data scripts are provided in separate .sql files. @@ -12692,8 +12692,6 @@ Song has a foreign key pointing to the album it belongs to. Now if I would delet Albums are kinda virtual in my database, only songs are actually represented on the filesystem and the albums are constructed according to the songs tags, therefore I can only know an album doesn't exist anymore if there are no more songs pointing to it (as they no longer exist in the filesystem). Or in short, how can I achieve a cascade in reverse, that means, if no more songs are pointing to an album, the album should be deleted as well?","I've had a similar problem and I've ended up adding a counter into the Album equivalent. If the count is 0 and the operation is delete(), then the album object is delete()d. Other solution os to overload the delete() method in the song model, or use post-delete to delete the album.",0.1016881243684853,False,1,1121 -2011-03-04 05:25:31.840,How do I create a line-break in Terminal?,"I'm using Python in Terminal on Mac OSX latest. When I press enter, it processes the code I've entered, and I am unable to figure out how to add an additional line of code e.g. for a basic loop.","The statements which represent a block of code below end with a colon(:) in Python. -By doing that way, you can add extra statements under a single block and execute them at once.",0.0,False,2,1122 2011-03-04 05:25:31.840,How do I create a line-break in Terminal?,"I'm using Python in Terminal on Mac OSX latest. When I press enter, it processes the code I've entered, and I am unable to figure out how to add an additional line of code e.g. for a basic loop.","The answer here is far more simple. If you want to continue in the next line after a loop like while b<1: when you press enter you get prompted with @@ -12703,20 +12701,22 @@ then you ""have to make an indent"" by space of tab and only then you can put mo then when you press enter the code is not going to be executed but you get another ... where you can keep typing you code by making the new indent keep the indent the same that is it",0.0679224682270276,False,2,1122 +2011-03-04 05:25:31.840,How do I create a line-break in Terminal?,"I'm using Python in Terminal on Mac OSX latest. When I press enter, it processes the code I've entered, and I am unable to figure out how to add an additional line of code e.g. for a basic loop.","The statements which represent a block of code below end with a colon(:) in Python. +By doing that way, you can add extra statements under a single block and execute them at once.",0.0,False,2,1122 2011-03-04 13:30:25.860,how to install multiple python versions on snow leopard?,"whats is the current best practice for installing multiple versions of python on snow leopard? have setup python 2.7.1 via Homebrew, very easy process, all great. but now I need to setup python 2.5 to develop an appengine project.. Initially created a new virtualenv against system python2.5 .. but finding I have all kinds of PATH issues. Seems at this point it would be better not to use Homebrew and go with a more standard setup? -any thoughts ?","Snow leopard already contains python 2.5 and python 2.6, no issues there. -If you require obscure modifications to the python installations, just compile your own, and put it in some place where it won't conflict with the system python. (I suggest /opt/your-pythonx.y). -As an aside, check: ""man python"" on mac to see how to use the 32-bit, or 64-bit options if that turns out to be neccessary. (Sometimes it is for c modules)",1.2,True,2,1123 +any thoughts ?","I use the python_select utility to switch between versions (it takes care of all the paths and links). It's easy to install with MacPorts or fink, so I would guess you can install the same utility with Homebrew.",0.0,False,2,1123 2011-03-04 13:30:25.860,how to install multiple python versions on snow leopard?,"whats is the current best practice for installing multiple versions of python on snow leopard? have setup python 2.7.1 via Homebrew, very easy process, all great. but now I need to setup python 2.5 to develop an appengine project.. Initially created a new virtualenv against system python2.5 .. but finding I have all kinds of PATH issues. Seems at this point it would be better not to use Homebrew and go with a more standard setup? -any thoughts ?","I use the python_select utility to switch between versions (it takes care of all the paths and links). It's easy to install with MacPorts or fink, so I would guess you can install the same utility with Homebrew.",0.0,False,2,1123 +any thoughts ?","Snow leopard already contains python 2.5 and python 2.6, no issues there. +If you require obscure modifications to the python installations, just compile your own, and put it in some place where it won't conflict with the system python. (I suggest /opt/your-pythonx.y). +As an aside, check: ""man python"" on mac to see how to use the 32-bit, or 64-bit options if that turns out to be neccessary. (Sometimes it is for c modules)",1.2,True,2,1123 2011-03-06 06:00:17.163,Performing multiple searches of a term in Twitter,"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: I 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. next 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). @@ -12751,12 +12751,21 @@ i hope it helps ..",0.0740755660660223,False,5,1127 2011-03-06 23:52:56.820,Python vs Matlab,"I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read). Is there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)? I've read good things about Spyder, but does it have a profiler? -When you change a function on the path in MATLAB, it is automatically reloaded. Do you have to manually re-import libraries when you change them, or can this been done automatically? This is a minor thing, but actually greatly improves my productivity.","I've been getting on very well with the Spyder IDE in the Python(x,y) distribution. I'm a long term user of Matlab and have known of the existence of Python for 10 years or so but it's only since I installed Python(x,y) that I've started using Python regularly.",0.4180023825831897,False,5,1127 -2011-03-06 23:52:56.820,Python vs Matlab,"I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read). +When you change a function on the path in MATLAB, it is automatically reloaded. Do you have to manually re-import libraries when you change them, or can this been done automatically? This is a minor thing, but actually greatly improves my productivity.","I've been in the engineering field for a while now and I've always used MATLAB for high-complexity math calculations. I never really had an major problems with it, but I wasn't super enthusiastic about it either. A few months ago I found out I was going to be a TA for a numerical methods class and that it would be taught using Python, so I would have to learn the language. + What I at first thought would be extra work turned out to be an awesome hobby. I can't even begin to describe how bad MATLAB is compared to Python! What used to to take me all day to code in Matlab takes me only a few hours to write in Python. My code looks infinitely more appealing as well. Python's performance and flexibility really surprised me. With Python I can literally do anything I used to do in MATLAB and I can do it a lot better. +If anyone else is thinking about switching, I suggest you do it. It made my life a lot easier. I'll quote ""Python Scripting for Computational Science"" because they describe the pros of Python over MATLAB better than I do: -Is there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)? I've read good things about Spyder, but does it have a profiler? -When you change a function on the path in MATLAB, it is automatically reloaded. Do you have to manually re-import libraries when you change them, or can this been done automatically? This is a minor thing, but actually greatly improves my productivity.","I have recently switched from MATLAB to Python (I am about 2 months into the transition), and am getting on fairly well using Sublime Text 2, using the SublimeRope and SublimeLinter plugins to provide some IDE-like capabilities, as well as pudb to provide some graphical interactive debugging capabilities. -I have not yet explored profilers or variable editors. (I never really used the MATLAB variable editor, anyway).",0.0370887312438237,False,5,1127 + +the python programming language is more powerful +the python environment is completely open and made for integration + with external tools, +a complete toolbox/module with lots of functions and classes can be contained in a single file (in contrast to a bunch of M-files), +transferring functions as arguments to functions is simpler, +nested, heterogeneous data structures are simple to construct and use, +object-oriented programming is more convenient, +interfacing C, C++, and fortran code is better supported and therefore simpler, +scalar functions work with array arguments to a larger extent (without modifications of arithmetic operators), +the source is free and runs on more platforms.",0.2190276265948034,False,5,1127 2011-03-06 23:52:56.820,Python vs Matlab,"I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read). Is there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)? I've read good things about Spyder, but does it have a profiler? @@ -12774,30 +12783,21 @@ but from what i see, numpy and matplotlib are similar to matplotlib concepts (pr 2011-03-06 23:52:56.820,Python vs Matlab,"I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read). Is there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)? I've read good things about Spyder, but does it have a profiler? -When you change a function on the path in MATLAB, it is automatically reloaded. Do you have to manually re-import libraries when you change them, or can this been done automatically? This is a minor thing, but actually greatly improves my productivity.","I've been in the engineering field for a while now and I've always used MATLAB for high-complexity math calculations. I never really had an major problems with it, but I wasn't super enthusiastic about it either. A few months ago I found out I was going to be a TA for a numerical methods class and that it would be taught using Python, so I would have to learn the language. - What I at first thought would be extra work turned out to be an awesome hobby. I can't even begin to describe how bad MATLAB is compared to Python! What used to to take me all day to code in Matlab takes me only a few hours to write in Python. My code looks infinitely more appealing as well. Python's performance and flexibility really surprised me. With Python I can literally do anything I used to do in MATLAB and I can do it a lot better. -If anyone else is thinking about switching, I suggest you do it. It made my life a lot easier. I'll quote ""Python Scripting for Computational Science"" because they describe the pros of Python over MATLAB better than I do: - +When you change a function on the path in MATLAB, it is automatically reloaded. Do you have to manually re-import libraries when you change them, or can this been done automatically? This is a minor thing, but actually greatly improves my productivity.","I've been getting on very well with the Spyder IDE in the Python(x,y) distribution. I'm a long term user of Matlab and have known of the existence of Python for 10 years or so but it's only since I installed Python(x,y) that I've started using Python regularly.",0.4180023825831897,False,5,1127 +2011-03-06 23:52:56.820,Python vs Matlab,"I'm considering making the switch from MATLAB to Python. The application is quantitative trading and cost is not really an issue. There are a few things I love about MATLAB and am wondering how Python stacks up (could not find any answers in the reviews I've read). -the python programming language is more powerful -the python environment is completely open and made for integration - with external tools, -a complete toolbox/module with lots of functions and classes can be contained in a single file (in contrast to a bunch of M-files), -transferring functions as arguments to functions is simpler, -nested, heterogeneous data structures are simple to construct and use, -object-oriented programming is more convenient, -interfacing C, C++, and fortran code is better supported and therefore simpler, -scalar functions work with array arguments to a larger extent (without modifications of arithmetic operators), -the source is free and runs on more platforms.",0.2190276265948034,False,5,1127 +Is there an IDE for Python that is as good as MATLAB's (variable editor, debugger, profiler)? I've read good things about Spyder, but does it have a profiler? +When you change a function on the path in MATLAB, it is automatically reloaded. Do you have to manually re-import libraries when you change them, or can this been done automatically? This is a minor thing, but actually greatly improves my productivity.","I have recently switched from MATLAB to Python (I am about 2 months into the transition), and am getting on fairly well using Sublime Text 2, using the SublimeRope and SublimeLinter plugins to provide some IDE-like capabilities, as well as pudb to provide some graphical interactive debugging capabilities. +I have not yet explored profilers or variable editors. (I never really used the MATLAB variable editor, anyway).",0.0370887312438237,False,5,1127 2011-03-07 04:38:19.297,Lettuce BDD : How to refer scenarios?,"I am using Lettuce BDD framework for python, and I am wondering how to run one scenario from within another scenario.. For example, say there is a ""registration"" scenario that establishes some pre-conditions which will be used by a subsequent scenario (say ""action"" scenario"") - how do I refer and call the ""registration"" scenario from ""action"" scenario?","There is a ""behave_as"" feature for Lettuce which should do this. Though there were some bugs with it last time I tried to use it. May be fixed now. I opened a bug on it with Gabriel, the author.",1.2,True,1,1128 2011-03-07 07:34:49.657,Change system date,"I need to change my computer's local date to an earlier date (e.g. 2010). I couldnt do that in BIOS. Does anybody know how to do this task, for example by writing a Python snippet? +Thanks.","If you are not permitted to do this via the operating system, then you will not be permitted to do it from a scripting language like Python, either.",0.2012947653214861,False,2,1129 +2011-03-07 07:34:49.657,Change system date,"I need to change my computer's local date to an earlier date (e.g. 2010). I couldnt do that in BIOS. Does anybody know how to do this task, for example by writing a Python snippet? Thanks.","If you use Windows, you should be able to do that in the time and date control panel (should be self explaining). If you use Linux, use the date command, and maybe hwclock (more info in the man pages). If you use AmigaOS, use the appropriate settings window in the system Preferences folder. If you use any other OS, you should have mentioned here which one you use...",0.2012947653214861,False,2,1129 -2011-03-07 07:34:49.657,Change system date,"I need to change my computer's local date to an earlier date (e.g. 2010). I couldnt do that in BIOS. Does anybody know how to do this task, for example by writing a Python snippet? -Thanks.","If you are not permitted to do this via the operating system, then you will not be permitted to do it from a scripting language like Python, either.",0.2012947653214861,False,2,1129 2011-03-07 16:12:48.327,Limit amount of writes to database using memcache,"I am trying to modify the guestbook example webapp to reduce the amount of database writes. What I am trying to achieve is to load all the guestbook entries into memcache which I have done. However I want to be able to directly update the memcache with new guestbook entries and then write all changes to the database as a batch put.() every 30 seconds. @@ -12860,11 +12860,11 @@ That will only work however if the masses are all integers. In general you have a binary linear programming problem. Those are very hard in general (NP-complete). However, both ways lead to algorithms which I wouldn't consider to be beginners material. You might be better of with trial and error (as you suggested) or simply try every possible combination.",0.1352210990936997,False,1,1142 2011-03-16 08:00:11.940,gevent multiple StreamServer listeners,"I have daemon which has connection pool to handlerSocket. I have 2 types of clients and their protocol differs. I want to setup 2 listeners which handles each protocol and shares connection pool between them. In twisted this is relatively easy to accomplish, but couldn't find out how to do this in gevent. +Thanks!",first instance of StreamServer could be started with: server.start() and second with server2.serve_forever(),1.2,True,2,1143 +2011-03-16 08:00:11.940,gevent multiple StreamServer listeners,"I have daemon which has connection pool to handlerSocket. I have 2 types of clients and their protocol differs. I want to setup 2 listeners which handles each protocol and shares connection pool between them. In twisted this is relatively easy to accomplish, but couldn't find out how to do this in gevent. Thanks!","I think the problem will come from the StreamServer's stop() method. It kills the pool, so, finishing one of listeners will drop all connections, from both listeners. If this is does not frighten you, you can simply pass the same Pool object to both StreamServers, running each of them in the separate greenlet.",0.0,False,2,1143 -2011-03-16 08:00:11.940,gevent multiple StreamServer listeners,"I have daemon which has connection pool to handlerSocket. I have 2 types of clients and their protocol differs. I want to setup 2 listeners which handles each protocol and shares connection pool between them. In twisted this is relatively easy to accomplish, but couldn't find out how to do this in gevent. -Thanks!",first instance of StreamServer could be started with: server.start() and second with server2.serve_forever(),1.2,True,2,1143 2011-03-17 06:57:13.417,django autoconverting datetime property,"my datetime property is saving in mysql in this format 2011-03-17 00:00:00 but after fetchind the data with filter function it is giving March 17,2011 midnight but i have not say to do any this type of task. My question is how can i insist django to stic to show same value what is saved in MYSQL.","I have a feeling your database schema knows this is a date, right? In that case it's not being stored in the format you describe, but as some representation such as seconds since the era. This means that when you retreave it your code has to do something with it to make it look right. If you don't tell it how to look it'll default to the format you see, but if you use strftime in your python code and a filter in your templates you can make it look however you like, including the original format how you saw it. Of course the easy way out is to store it in the db as text...",0.0,False,1,1144 @@ -12966,10 +12966,7 @@ I must to create a database table called ""Genders"", but this is a generic database table and could be used in other App. My question... how to deal with this kind of situation in Django? And in wich model I shuld put this database table? -Best Regards,","In django, you don't (generally) create database tables. You create models, and let the django ORM create tables for you. -To prevent having two tables in your database called gender, django will prefix the model name with the name of the app. Thus, if your app was called foo, your model class was Gender, you would have foo_gender. But, you don't need to know this. -As for the specific case of Gender: I wouldn't bother storing this in the database in a special table. They don't make new genders anymore. If you need to store a field containing a gender, then just use django.db.models.CharField, with a choices=(('M',""Male""),('F',""Female"")). Or if you do it lots, then create a new field. -If it is something you do need to be able to add dynamically to the database, then either abstract it out into a reusable app, or as someone else mentioned, create a sundry/project/utils app.",0.2012947653214861,False,2,1158 +Best Regards,","Django doesn't really offer you place where things that are commonly used all over the project can live. I think the most common approach to solve this is to create a 'project'-app, which holds such project-relevant things like models, templatetags or widgets for example...",1.2,True,2,1158 2011-03-23 09:02:04.983,Where to put generic Database Tables on Django?,"I'm trying to start with Django. I'm developing an App. This App is called ""Directory"" and will store info about websites. @@ -12977,7 +12974,10 @@ I must to create a database table called ""Genders"", but this is a generic database table and could be used in other App. My question... how to deal with this kind of situation in Django? And in wich model I shuld put this database table? -Best Regards,","Django doesn't really offer you place where things that are commonly used all over the project can live. I think the most common approach to solve this is to create a 'project'-app, which holds such project-relevant things like models, templatetags or widgets for example...",1.2,True,2,1158 +Best Regards,","In django, you don't (generally) create database tables. You create models, and let the django ORM create tables for you. +To prevent having two tables in your database called gender, django will prefix the model name with the name of the app. Thus, if your app was called foo, your model class was Gender, you would have foo_gender. But, you don't need to know this. +As for the specific case of Gender: I wouldn't bother storing this in the database in a special table. They don't make new genders anymore. If you need to store a field containing a gender, then just use django.db.models.CharField, with a choices=(('M',""Male""),('F',""Female"")). Or if you do it lots, then create a new field. +If it is something you do need to be able to add dynamically to the database, then either abstract it out into a reusable app, or as someone else mentioned, create a sundry/project/utils app.",0.2012947653214861,False,2,1158 2011-03-23 15:30:11.787,Tab/spaces indention issues in IDE's vs vim,"For a python project I am trying an IDE, coming from vim but I have troube how my code is shown resp. indentation. Many lines should be indented because they are inside if-then-else statements. In SPE and netbeans there are many lines where the indention-space (four) are collapsed. But I checked the files with tabnanny and pylint and cant see indention problems. ANd the code has been running up to now. @@ -13006,14 +13006,14 @@ I understand that I should do this in urls.py, but I have to because of certain Please answer how I would match it this way. I have to because a iPhone client (which cannot be changed) hardcoded it this way. I know it's not ideal, but I have to match it this way now.","Don't ever send passwords in the URL. They belong in the POST body, which is not stored by browsers (you can repeat POSTs in browsers, but POST data is not stored in the history).",0.5457054096481145,False,1,1163 2011-03-27 05:42:59.230,How a framework development works without a debugger?,"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? Thank you very much. --Stefan-","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",0.0,False,3,1164 +-Stefan-","python -m pdb foo.py +And 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.",0.0,False,3,1164 2011-03-27 05:42:59.230,How a framework development works without a debugger?,"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? Thank you very much. --Stefan-","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.",0.1618299653758019,False,3,1164 +-Stefan-","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",0.0,False,3,1164 2011-03-27 05:42:59.230,How a framework development works without a debugger?,"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? Thank you very much. --Stefan-","python -m pdb foo.py -And 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.",0.0,False,3,1164 +-Stefan-","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.",0.1618299653758019,False,3,1164 2011-03-27 10:38:00.527,how to have google apps engine send mail- not send a copy of the mail to the sender,"I'm using GAE send mail- but I dont want the sender of the mail to get a coppy of the mail. as for now, when a user is sending mail he gets a mail saying that he sent a mail to someone and the body of the sent mail, how do I disable that?","You can't. Sending email from someone without their knowledge isn't permitted by App Engine. You can send email from any administrator address; you could add a ""donotreply@yourapp.com"" type address as an administrator and send email from that address.",1.2,True,1,1165 @@ -13147,14 +13147,6 @@ So, actually you were interested in three letters: CGI. However I still doubt you will get any good from it.",-0.9051482536448664,False,1,1186 2011-04-09 02:22:07.540,Random picks from permutation generator?,"How to randomly pick all the results, one by one (no repeats) from itertools.permutations(k)? Or this: how to build a generator of randomized permutations? Something like shuffle(permutations(k)). I’m using Python 2.6. Yeah, shuffle(r) could be used if r = list(permutations(k)), but such a list will take up too much time and memory when len(k) raises above 10. -Thanks.","I don't know how python implements its shuffle algorithm, but the following scales in linear time, so I don't see why a length of 10 is such a big deal (unless I misunderstand your question?): - -start with the list of items; -go through each index in the list in turn, swapping the item at that index it for an item at a random index (including the item itself) in the remainder of the list. - -For a different permutation, just run the same algorithm again.",0.1352210990936997,False,2,1187 -2011-04-09 02:22:07.540,Random picks from permutation generator?,"How to randomly pick all the results, one by one (no repeats) from itertools.permutations(k)? Or this: how to build a generator of randomized permutations? Something like shuffle(permutations(k)). I’m using Python 2.6. -Yeah, shuffle(r) could be used if r = list(permutations(k)), but such a list will take up too much time and memory when len(k) raises above 10. Thanks.","There's no way of doing what you have asked for without writing your own version of permutations. Consider this: @@ -13164,6 +13156,14 @@ We then pick an entries at random between the beginning of the list and the end. Since I have a generator if the random function picks an entry near the end of the list the only way to get to it will be to go through all the prior entries and either throw them away, which is bad, or store them in a list, which you have pointed out is problematic when you have a lot of options. Are you going to loop through every permutation or use just a few? If it's the latter it would make more sense to generate each new permutation at random and store then ones you've seen before in a set. If you don't use that many the overhead of having to create a new permutation each time you have a collision will be pretty low.",0.1352210990936997,False,2,1187 +2011-04-09 02:22:07.540,Random picks from permutation generator?,"How to randomly pick all the results, one by one (no repeats) from itertools.permutations(k)? Or this: how to build a generator of randomized permutations? Something like shuffle(permutations(k)). I’m using Python 2.6. +Yeah, shuffle(r) could be used if r = list(permutations(k)), but such a list will take up too much time and memory when len(k) raises above 10. +Thanks.","I don't know how python implements its shuffle algorithm, but the following scales in linear time, so I don't see why a length of 10 is such a big deal (unless I misunderstand your question?): + +start with the list of items; +go through each index in the list in turn, swapping the item at that index it for an item at a random index (including the item itself) in the remainder of the list. + +For a different permutation, just run the same algorithm again.",0.1352210990936997,False,2,1187 2011-04-10 14:24:45.883,Google-App Engine logging problem,"I'm wondering if anyone has experienced problems with Google-App Engine's logging facility. Everything was working fine for me until this morning, I ran my local server and no logging messages were being displayed (well, none of my logging messages, the server GET messages etc.. are being displayed). Even errors are not being reported. I have no idea what is going on. If this has happened to anyone, can you please advise on how to fix it?",Thanks Abdul you made me realize what the problem is. I had changed a URL in my application to point to the application that I had deployed to Google-App Engine. It should have been pointing to my local application. I had myapp.appspot.com/move instead of localhost/move,1.2,True,1,1188 2011-04-10 20:07:22.550,How to change a strings encoding as utf 8 in C,"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? @@ -13179,18 +13179,18 @@ The ALLOCATE keyword is how you create heap allocated data in Fortran 90. Howev tcl/tk 8.5.9 was also installed and this is not the default. There was no verbose mode during installation, so I don't know whether it replaced the default one. If it did how bad can it be for the OS? and hence 2. If the above is really bad, how do i downgrade to the old version of tcl/tk? In short, how do i bring my machine back to its original state? If anyone knows all the paths to the directories and files I can do it manually. -Thanks","I did the same (3.2 on a mac 10.6) and: --Moved both the Python 3.2 folder and the ActiveState ActiveTcl folder from the Applications Folder to the Trash. --Moved the Python.framework folder from the Library/Frameworks folder to the Trash. -Running System profiler shows only the 2.6 version of Python. -Marcos",0.4961739557460144,False,2,1191 +Thanks","just uninstall 3x version of python if you have already installed it. Eclipse has that option when you click ""see whats already installed"". +Install later 2.7 version. It works for me on my OS X 10.9.2 with Eclipse Juno.",0.0,False,2,1191 2011-04-11 13:20:53.353,Uninstall python 3.2 on mac os x 10.6.7,"According to the documentation from python.org, python 3.2 install on mac os requires an upgrade to tcl/tk 8.5.9 (for use of IDLE). In my haste, I have done both. Now my friend told me that python 3 is not recommended yet because only the built-ins and a few modules have been released for 3. The stable one so far is 2.7 (especially if one wants to make extensive use of a variety of modules). My machine has both 2.6.1 and 3.2 (because some OS services make use of 2.6.1 that comes as default with the OS). 1. How do i remove 3.2 completely to avoid any compatibility issues? tcl/tk 8.5.9 was also installed and this is not the default. There was no verbose mode during installation, so I don't know whether it replaced the default one. If it did how bad can it be for the OS? and hence 2. If the above is really bad, how do i downgrade to the old version of tcl/tk? In short, how do i bring my machine back to its original state? If anyone knows all the paths to the directories and files I can do it manually. -Thanks","just uninstall 3x version of python if you have already installed it. Eclipse has that option when you click ""see whats already installed"". -Install later 2.7 version. It works for me on my OS X 10.9.2 with Eclipse Juno.",0.0,False,2,1191 +Thanks","I did the same (3.2 on a mac 10.6) and: +-Moved both the Python 3.2 folder and the ActiveState ActiveTcl folder from the Applications Folder to the Trash. +-Moved the Python.framework folder from the Library/Frameworks folder to the Trash. +Running System profiler shows only the 2.6 version of Python. +Marcos",0.4961739557460144,False,2,1191 2011-04-11 19:46:56.183,Test specific models in Django,"Is it possible to have a set of models just for testing purposes? The idea is that I've written an app that contains some helper abstract model HelperBase. Now I'd like to provide some models that would inherit from it in order to test it, say DerivedTest1, DerivedTest2. However I wouldn't really like those test models to appear in the production database in the end. I just want their tables to be constructed in the test database. Is it possible and if so - how to do it? I've already tried creating models in the tests.py file but this doesn't seem to work.","You could try creating a whole new app that you only use on your development server. E.g., if your app is called myapp you would call your testing app myapp_test. Then in myapp_test's models.py you would from myapp import models and then subclass your models in there. @@ -13394,7 +13394,6 @@ UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 2: \xfc is the escaped value 252, which corresponds to the latin1 encoding of ""ü"". Somehow this gets embedded in the unicode string in a way python can't handle on its own. How do i convert this back a normal or unicode string that contains the original ""Glück""? I tried playing around with the decode/encode methods, but either got a UnicodeEncodeError, or a string containing the sequence \xfc.","Do not str() cast to string what you've got from model fields, as long as it is an unicode string already. (oops I have totally missed that it is not django-related)",0.0,False,1,1207 -2011-04-24 17:03:26.210,python: how to get notifications for mysql database changes?,"In Python, is there a way to get notified that a specific table in a MySQL database has changed?",Not possible with standard SQL functionality.,0.0814518047658113,False,2,1208 2011-04-24 17:03:26.210,python: how to get notifications for mysql database changes?,"In Python, is there a way to get notified that a specific table in a MySQL database has changed?","It's theoretically possible but I wouldn't recommend it: Essentially you have a trigger on the the table the calls a UDF which communicates with your Python app in some way. Pitfalls include what happens if there's an error? @@ -13403,6 +13402,7 @@ What if it's inside a transaction that gets rolled back? I'm sure there are many other problems that I haven't thought of as well. A better way if possible is to have your data access layer notify the rest of your app. If you're looking for when a program outside your control modifies the database, then you may be out of luck. Another way that's less ideal but imo better than calling an another program from within a trigger is to set some kind of ""LastModified"" table that gets updated by triggers with triggers. Then in your app just check whether that datetime is greater than when you last checked.",0.6730655149877884,False,2,1208 +2011-04-24 17:03:26.210,python: how to get notifications for mysql database changes?,"In Python, is there a way to get notified that a specific table in a MySQL database has changed?",Not possible with standard SQL functionality.,0.0814518047658113,False,2,1208 2011-04-25 16:17:38.767,How to use Django-filer(asset file manager)?,"Can someone point me in the right direction on how to use Django-filer? I have installed the necessary tools for the filer to work and I get the Filer tab in the admin interface, but when I upload an image to the app I am not able to get the preview thumbimage. The image is also uploaded to the Media_root path(Public files default path). What else have I missed?","Had a similar problem. I had missed that when easy_thumbnails is automatically pulled in by pip, you still have to explicitly add it to your INSTALLED_APPS in settings.py. I spotted this because when I was uploading images, they weren't appearing in the clipboard, and when inspecting the response from the upload, there was an internal server error complaining that an easy_thumbnails table wasn't available. tl;dr; check you added easy_thumbnails to your settings and did a migration / syncdb",0.0,False,1,1209 @@ -13524,14 +13524,14 @@ But the input inside a loop and keep looping until you get what you want.",0.067 Database A resides on server server1, while database B resides on server server2. Both servers {A, B} are physically close to each other, but are on different machines and have different connection parameters (different username, different password etc). In such a case, is it possible to perform a join between a table that is in database A, to a table that is in database B? -If so, how do I go about it, programatically, in python? (I am using python's MySQLDB to separately interact with each one of the databases).","No. It is not possible to do the join as you would like. But you may be able to sort something out by replicating one of the servers to the other for the individual database. -One data set is under the control of one copy of MySQL and the other dataset is under the control of the other copy of MySQL. The query can only be processed by one of the (MySQL) servers. -If you create a copy of the second database on the first server or vice versa (the one that gets the fewest updates is best) you can set up replication to keep the copy up to date. You will then be able to run the query as you want.",0.3869120172231254,False,2,1219 +If so, how do I go about it, programatically, in python? (I am using python's MySQLDB to separately interact with each one of the databases).","It is very simple - select data from one server, select data from another server and aggregate using Python. If you would like to have SQL query with JOIN - put result from both servers into separate tables in local SQLite database and write SELECT with JOIN.",0.4961739557460144,False,2,1219 2011-04-29 13:36:26.650,MySQL -- Joins Between Databases On Different Servers Using Python?,"In MySQL, I have two different databases -- let's call them A and B. Database A resides on server server1, while database B resides on server server2. Both servers {A, B} are physically close to each other, but are on different machines and have different connection parameters (different username, different password etc). In such a case, is it possible to perform a join between a table that is in database A, to a table that is in database B? -If so, how do I go about it, programatically, in python? (I am using python's MySQLDB to separately interact with each one of the databases).","It is very simple - select data from one server, select data from another server and aggregate using Python. If you would like to have SQL query with JOIN - put result from both servers into separate tables in local SQLite database and write SELECT with JOIN.",0.4961739557460144,False,2,1219 +If so, how do I go about it, programatically, in python? (I am using python's MySQLDB to separately interact with each one of the databases).","No. It is not possible to do the join as you would like. But you may be able to sort something out by replicating one of the servers to the other for the individual database. +One data set is under the control of one copy of MySQL and the other dataset is under the control of the other copy of MySQL. The query can only be processed by one of the (MySQL) servers. +If you create a copy of the second database on the first server or vice versa (the one that gets the fewest updates is best) you can set up replication to keep the copy up to date. You will then be able to run the query as you want.",0.3869120172231254,False,2,1219 2011-04-30 17:39:02.163,PyObjC on Xcode 4,"Xcode 3 had templates for building Cocoa subclasses in Python. I've recently upgraded to Xcode 4 but I cannot find out how I can use other languages besides the C family (C, C++, Obj-C) in Xcode 4. Does anyone know?","I've successfully built a MacRuby GUI app in XCode 4.2 on Lion today following a MacRuby tutorial on Apple's site. MacRuby also includes a template in XCode 4.2. I'm a Python programmer and really hoped to use it, but at this point I've given up on PyObjC. I use Tk in Python for quick little apps and maybe switch to MacRuby, but will likely just switch to Objective-c. Ruby is a pretty nice language though. Maybe MacRuby will interest you.",0.2655860252697744,False,1,1220 2011-04-30 21:56:28.983,Comprehensive beginner's virtualenv tutorial?,"I've been hearing the buzz about virtualenv lately, and I'm interested. But all I've heard is a smattering of praise, and don't have a clear understanding of what it is or how to use it. @@ -13663,9 +13663,9 @@ Is there a way to directly call the method? or Is there a way to indirectly call the method say via a button's onClick and a mimic screen tap? Thanks.",You'll need to wait for a refresh event (this would be a custom event) in your JavaScript that is waiting for an event posted from your Python script. The only communication layer between JavaScript and Python is via events.,1.2,True,1,1235 -2011-05-10 17:02:23.633,Python path help,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.,"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.",0.0,False,3,1236 -2011-05-10 17:02:23.633,Python path help,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.,You can tell your friend to make *.py files to be executed by the interpreter. Change it from Explorer:Tools:Folder Options:File Types.,0.0,False,3,1236 2011-05-10 17:02:23.633,Python path help,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.,"f = open(os.path.join(os.environ['USERPROFILE'], 'DESKTOP', my_filename))",1.2,True,3,1236 +2011-05-10 17:02:23.633,Python path help,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.,You can tell your friend to make *.py files to be executed by the interpreter. Change it from Explorer:Tools:Folder Options:File Types.,0.0,False,3,1236 +2011-05-10 17:02:23.633,Python path help,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.,"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.",0.0,False,3,1236 2011-05-10 17:27:37.027,Python: Read large file in chunks,"Hey there, I have a rather large file that I want to process using Python and I'm kind of stuck as to how to do it. The format of my file is like this: 0 xxx xxxx xxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx @@ -13732,9 +13732,6 @@ Did you evaluate the function when you changed the above line? Btw, opening the interpreter in another window is a feature, not a bug, IMHO. We want to be able to see the interpreter when we evaluate a region of code using C-c | or the buffer using C-c C-c.",0.0,False,1,1245 2011-05-17 11:29:48.453,How to run a code in an Amazone's EC2 instance?,"I understand nearly nothing to the functioning of EC2. I created an Amazon Web Service (AWS) account. Then I launched an EC2 instance. And 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? -Where 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.",simply add your code to Github and take clone on EC2 instance and run that code.,0.0,False,2,1246 -2011-05-17 11:29:48.453,How to run a code in an Amazone's EC2 instance?,"I understand nearly nothing to the functioning of EC2. I created an Amazon Web Service (AWS) account. Then I launched an EC2 instance. -And 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? Where 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.","Launch your instance through Amazon's Management Console -> Instance Actions -> Connect (More details in the getting started guide) Launch the Java based SSH CLient @@ -13744,6 +13741,9 @@ run your files in the background (with '&' at the end or use nohup) Be sure to select an AMI with python included, you can check by typing 'python' in the shell. If your app require any unorthodox packages you'll have to install them.",0.3153999413393242,False,2,1246 +2011-05-17 11:29:48.453,How to run a code in an Amazone's EC2 instance?,"I understand nearly nothing to the functioning of EC2. I created an Amazon Web Service (AWS) account. Then I launched an EC2 instance. +And 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? +Where 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.",simply add your code to Github and take clone on EC2 instance and run that code.,0.0,False,2,1246 2011-05-18 06:14:19.250,How to render DOT file using only pos attributes,"I have taken an initial DOT file and modified the pos attributes of some nodes using pydot. Now I want to render an image file that shows the nodes in their new positions. The catch is, I don't want a layout program to mess with the positions! I just want to see the nodes exactly where the pos attribute indicates. I don't care about how the edges look. I can produce a DOT file with my positions easily using pydot, but I can't figure out how to make an image file, either in pydot or on the command line with dot. Help would be really appreciated! Thanks!","dot.write_png('filename.png')? Or is there something I'm missing? Also, the neato command-line program has a -n option for graph files that already have layout. The program description says it is for undirected graphs, but I tried it with a digraph and it produced the correct result.",1.2,True,1,1247 @@ -13787,14 +13787,14 @@ genbitmaptogglebuttons: for some reason, these buttons kill my tooltips (I poste toolbar buttons: can't add a drop down menu to a button. I would make a separate button for the drop down menu, but the toolbar has to be oriented vertically, and I don't know how to get the drop down button to show up beside its corresponding button, rather than beneath it with vertical a toolbar orientation. bitmap buttons: won't toggle Am I missing something obvious? If not I'm just going to resort to faking a toggle by changing the border/background color, unless someone has a better suggestion. -Thanks.","I don't see a pre-built button with all those features. I would think that you can use the generic toggle button or maybe the ShapedButton for your bitmap toggle functionality and attach a right-click popup menu. I'm not really sure what you mean by a menu, so that may not work. If you're talking about a menu implementation similar to the one that the PlateButton has, then you'll probably have to roll your own button. The guys on the wxPython mailing list can tell you how to do that.",0.0,False,2,1250 +Thanks.","Per Mark's suggestion, if you have wx 2.8.12 you can use a plate button to get the toggle/bitmap/menu functionality. Since it is not easy for me to update to the newer wx at this point, I'll use a bitmap button and fake the toggle.",0.0,False,2,1250 2011-05-19 19:46:03.587,wx python bitmap/toggle/menu button,"I need a button that has a bitmap, toggles, and to which I can add a menu (I realize this is asking a lot). I can't figure out a way to do this in wx python. Here are the things I've tried and why they don't work: plate buttons: don't toggle genbitmaptogglebuttons: for some reason, these buttons kill my tooltips (I posted this problem earlier and never got an answer) toolbar buttons: can't add a drop down menu to a button. I would make a separate button for the drop down menu, but the toolbar has to be oriented vertically, and I don't know how to get the drop down button to show up beside its corresponding button, rather than beneath it with vertical a toolbar orientation. bitmap buttons: won't toggle Am I missing something obvious? If not I'm just going to resort to faking a toggle by changing the border/background color, unless someone has a better suggestion. -Thanks.","Per Mark's suggestion, if you have wx 2.8.12 you can use a plate button to get the toggle/bitmap/menu functionality. Since it is not easy for me to update to the newer wx at this point, I'll use a bitmap button and fake the toggle.",0.0,False,2,1250 +Thanks.","I don't see a pre-built button with all those features. I would think that you can use the generic toggle button or maybe the ShapedButton for your bitmap toggle functionality and attach a right-click popup menu. I'm not really sure what you mean by a menu, so that may not work. If you're talking about a menu implementation similar to the one that the PlateButton has, then you'll probably have to roll your own button. The guys on the wxPython mailing list can tell you how to do that.",0.0,False,2,1250 2011-05-20 18:11:06.307,Force repaint in wxPython Canvas,"I've got a Canvas which manipulates objects in the mouse event handler. After modifying the objects, I want to trigger the OnPaint() event for the same Canvas to show (rerender) the changes. What is the right way to do this? It doesn't let me call OnPaint() directly. Also, is triggering an event from another event ""wrong"" in some sense, or likely to lead to trouble?",I would just call self.Refresh() or maybe RefreshRect() and pass the area that needs to be repainted.,1.2,True,1,1251 2011-05-22 00:27:21.680,how to upload files to PHP server with use of Python?,"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? Edited @@ -13836,16 +13836,16 @@ I would like to know : 1) Is the Greenplum DB the same as vanilla [PostgresSQL]? (I've worked on Postgres AS 8.3) 2) Are there any (free) tools available for this task (extract and import) 3) I have some knowledge of Python. Is it feasible, even easy to do this in a resonable amount of time? -I have no idea how to do this. Any advice, tips and suggestions will be hugely welcome.","Many of Greenplum's utilities are written in python and the current DBMS distribution comes with python 2.6.2 installed, including the pygresql module which you can use to work inside the GPDB. -For data transfer into greenplum, I've written python scripts that connect to the source (Oracle) DB using cx_Oracle and then dumping that output either to flat files or named pipes. gpfdist can read from either sort of source and load the data into the system.",0.0,False,2,1257 +I have no idea how to do this. Any advice, tips and suggestions will be hugely welcome.","Generally, it is really slow if you use SQL insert or merge to import big bulk data. +The recommended way is to use the external tables you define to use file-based, web-based or gpfdist protocol hosted files. +And also greenplum has a utility named gpload, which can be used to define your transferring jobs, like source, output, mode(inert, update or merge).",0.0,False,2,1257 2011-05-24 12:28:24.503,Transferring data from a DB2 DB to a greenplum DB,"My company has decided to implement a datamart using [Greenplum] and I have the task of figuring out how to go on about it. A ballpark figure of the amount of data to be transferred from the existing [DB2] DB to the Greenplum DB is about 2 TB. I would like to know : 1) Is the Greenplum DB the same as vanilla [PostgresSQL]? (I've worked on Postgres AS 8.3) 2) Are there any (free) tools available for this task (extract and import) 3) I have some knowledge of Python. Is it feasible, even easy to do this in a resonable amount of time? -I have no idea how to do this. Any advice, tips and suggestions will be hugely welcome.","Generally, it is really slow if you use SQL insert or merge to import big bulk data. -The recommended way is to use the external tables you define to use file-based, web-based or gpfdist protocol hosted files. -And also greenplum has a utility named gpload, which can be used to define your transferring jobs, like source, output, mode(inert, update or merge).",0.0,False,2,1257 +I have no idea how to do this. Any advice, tips and suggestions will be hugely welcome.","Many of Greenplum's utilities are written in python and the current DBMS distribution comes with python 2.6.2 installed, including the pygresql module which you can use to work inside the GPDB. +For data transfer into greenplum, I've written python scripts that connect to the source (Oracle) DB using cx_Oracle and then dumping that output either to flat files or named pipes. gpfdist can read from either sort of source and load the data into the system.",0.0,False,2,1257 2011-05-24 18:50:43.853,Problem with reading pasted text in terminal,"I'm reading text in terminal with description = raw_input() It works if I write the text and press enter. The problem is when I paste the text from somewhere with Ctrl+Shift+V or with right click + paste. My program immediately ends, description contains only part of the text (I can see it in database). @@ -13886,13 +13886,13 @@ I would add that the problem arose after the reinstallation of the system and se Is there maybe something I forgot? Has anyone come up with such a problem before? Does anyone have an idea of ​​how to deal with this problem? The current configuration / libraries: -python 2.7, numpy, selenium.py","There are several possibilities. If none of your tests can listen on some port (you don't say what port) then perhaps your Windows machine is running something on a port that you previously had open; this new service may have appeared during the reinstall. If, on the other hand, it's only a problem for some tests, or it's a little sporadic, then it may be either a programming issue (forgetting to close a socket in an early test which interferes with a later one) or a timing issue (the earlier test's socket isn't quite through closing before the new one tries to open up). Obviously there are different ways to address each of these problems, but I don't think we can help more than this without more details.",0.0,False,2,1266 +python 2.7, numpy, selenium.py","Maybe there is a software on your Windows that already use port 4444, can you try set Selenium to another port and try again?",0.0,False,2,1266 2011-05-30 12:44:13.693,problem: Socket error [Address already in use] in python/selenium,"I have a troublesome problem socket.error error: [Errno 10048]: Address already in use. Only one usage of each socket address (protocol/IP address/port) is normally permitted during automated tests using Selenium with Python. The problem is so interesting that it runs on one machine (Linux) works correctly, but on another machine (WindowsXP) generates this error. I would add that the problem arose after the reinstallation of the system and set up all over again - with the previous configuration everything worked properly. Is there maybe something I forgot? Has anyone come up with such a problem before? Does anyone have an idea of ​​how to deal with this problem? The current configuration / libraries: -python 2.7, numpy, selenium.py","Maybe there is a software on your Windows that already use port 4444, can you try set Selenium to another port and try again?",0.0,False,2,1266 +python 2.7, numpy, selenium.py","There are several possibilities. If none of your tests can listen on some port (you don't say what port) then perhaps your Windows machine is running something on a port that you previously had open; this new service may have appeared during the reinstall. If, on the other hand, it's only a problem for some tests, or it's a little sporadic, then it may be either a programming issue (forgetting to close a socket in an early test which interferes with a later one) or a timing issue (the earlier test's socket isn't quite through closing before the new one tries to open up). Obviously there are different ways to address each of these problems, but I don't think we can help more than this without more details.",0.0,False,2,1266 2011-05-31 13:39:13.827,pydev - call a function with only self as argument,"I am new to PyDev, written scripts using mainly notepad++ and jedit where I never had these issues. In a module, I have defined a function - get_user_inputs(self). I used the argument self as PyDev would not let me define the function othewise (and apparently it is the right thing to do). Now my question is how do I call this function and what argument should I pass? @@ -13936,10 +13936,7 @@ I can run the application without cron without problems. Cron 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. my crontab: */1 * * * * /home/xralf/pythonsrc/app -thank you","I don't see any problem in cron job with pynotify? What is the error you are getting? -Can you run your python code separately to check whether your python code is working really well but only fails with cron? -Celery is distributed job queue & task manager written in Python but it may be too much for your needs. -Supervisord 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.",0.0,False,2,1269 +thank you","If the cron job runs as ""you"", and if you set the DISPLAY var (export DISPLAY=:0) you should have no issues.",0.1016881243684853,False,2,1269 2011-05-31 18:06:19.590,Notification as a cron job,"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. Do you know some alternative how to run this application every five minutes? I'm using Xubuntu. @@ -13949,7 +13946,10 @@ I can run the application without cron without problems. Cron 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. my crontab: */1 * * * * /home/xralf/pythonsrc/app -thank you","If the cron job runs as ""you"", and if you set the DISPLAY var (export DISPLAY=:0) you should have no issues.",0.1016881243684853,False,2,1269 +thank you","I don't see any problem in cron job with pynotify? What is the error you are getting? +Can you run your python code separately to check whether your python code is working really well but only fails with cron? +Celery is distributed job queue & task manager written in Python but it may be too much for your needs. +Supervisord 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.",0.0,False,2,1269 2011-06-01 22:14:58.253,How can I automate antivirus/WSUS patch testing of my Windows driver and binary?,"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. We 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!). I'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. @@ -14019,6 +14019,13 @@ I let the user input the years to pay it back, BUT, if the length of time is und I'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. From all accounts that I've read, nginx's mod_wsgi isn't suitable. That 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. +Are there any caveats or benefits to using lighttpd over apache? I really want to hear all the information you can possibly bore me with!","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. +Now 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. +In 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.",0.2012947653214861,False,2,1284 +2011-06-12 01:31:03.800,Apache + mod_wsgi / Lighttpd + wsgi - am I going to see differences in performance?,"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.) +I'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. +From all accounts that I've read, nginx's mod_wsgi isn't suitable. +That 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. Are there any caveats or benefits to using lighttpd over apache? I really want to hear all the information you can possibly bore me with!","Apache... Apache 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. Pros @@ -14050,13 +14057,6 @@ If you were running a static website, then you would use nginx. you are correct Conclusion Benefits? 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. Also, 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.",1.2,True,2,1284 -2011-06-12 01:31:03.800,Apache + mod_wsgi / Lighttpd + wsgi - am I going to see differences in performance?,"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.) -I'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. -From all accounts that I've read, nginx's mod_wsgi isn't suitable. -That 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. -Are there any caveats or benefits to using lighttpd over apache? I really want to hear all the information you can possibly bore me with!","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. -Now 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. -In 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.",0.2012947653214861,False,2,1284 2011-06-12 01:33:48.493,Return well-formed numbers,"I found this in an interview questions forum: Write a function to return well formed @@ -14098,21 +14098,21 @@ Craig","1) You are trying to return well formed numbers 'up to' n digits in your I'd like for the items in the game to descend from one base Item class, containing some attributes that every item has, such as damage and weight. My problems begin when I try to add some functionality to these items. When an item's damage gets past a threshold, it should be destroyed. And there lies my problem: I don't really know how to accomplish that. Since del self won't work for a million different reasons, (Edit: I am intentionally providing the use of 'del' as something that I know is wrong. I know what garbage collection is, and how it is not what I want.) how should I do this (And other similar tasks)? Should each item contain some kind of reference to it's container (The player, I guess) and 'ask' for itself to be deleted? The first thing that comes to mind is a big dictionary containing every item in the game, and each object would have a reference to this list, and both have and know it's own unique ID. I don't like this solution at all and I don't think that it's the right way to go at all. Does anybody have any suggestions? -EDIT: I'm seeing a lot of people thinking that I'm worried about garbage collection. What I'm talking about is not garbage collection, but actually removing the object from gameplay. I'm not sure about what objects should initiate the removal, etc.","Assuming you call a method when the item is used, you could always return a boolean value indicating whether it's broken.",0.0,False,3,1286 +EDIT: I'm seeing a lot of people thinking that I'm worried about garbage collection. What I'm talking about is not garbage collection, but actually removing the object from gameplay. I'm not sure about what objects should initiate the removal, etc.","at first: i don't have any python experience, so think about this in a more general way +your item should neither know or care ... your Item should have an interface that says it is something destroyable. containers and other objects that care about things that can be destroyed, can make use of that interface +that destroyable interface could have some option for consuming objects to register a callback or event, triggered when the item gets destroyed",-0.0679224682270276,False,3,1286 2011-06-13 01:02:59.147,Managing Items in an Object Oriented game,"Every once in a while I like to take a break from my other projects to try to make a classic adventure text-based-game (in Python, this time) as a fun project, but I always have design issues implementing the item system. I'd like for the items in the game to descend from one base Item class, containing some attributes that every item has, such as damage and weight. My problems begin when I try to add some functionality to these items. When an item's damage gets past a threshold, it should be destroyed. And there lies my problem: I don't really know how to accomplish that. Since del self won't work for a million different reasons, (Edit: I am intentionally providing the use of 'del' as something that I know is wrong. I know what garbage collection is, and how it is not what I want.) how should I do this (And other similar tasks)? Should each item contain some kind of reference to it's container (The player, I guess) and 'ask' for itself to be deleted? The first thing that comes to mind is a big dictionary containing every item in the game, and each object would have a reference to this list, and both have and know it's own unique ID. I don't like this solution at all and I don't think that it's the right way to go at all. Does anybody have any suggestions? -EDIT: I'm seeing a lot of people thinking that I'm worried about garbage collection. What I'm talking about is not garbage collection, but actually removing the object from gameplay. I'm not sure about what objects should initiate the removal, etc.","You're conflating two meanings of the ""destroying"" idea. The Item should get destroyed in a ""gameplay"" sense. Let the garbage collector worry about when to destroy it as an object. -Who has a reference to the Item? Perhaps the player has it in his inventory, or it is in a room in the game. In either case your Inventory or Room objects know about the Item. Tell them the Item has been destroyed (in a gameplay sense) and let them handle that. Perhaps they'll now keep a reference to a ""broken"" Item. Perhaps they'll keep track of it, but not display it to the user. Perhaps they'll delete all references to it, in which case the object in memory will soon be deleted. -The beauty of object-oriented programming is that you can abstract these processes away from the Item itself: pass the messages to whoever needs to know, and let them implement in their own way what it means for the Item to be destroyed.",0.0679224682270276,False,3,1286 +EDIT: I'm seeing a lot of people thinking that I'm worried about garbage collection. What I'm talking about is not garbage collection, but actually removing the object from gameplay. I'm not sure about what objects should initiate the removal, etc.","Assuming you call a method when the item is used, you could always return a boolean value indicating whether it's broken.",0.0,False,3,1286 2011-06-13 01:02:59.147,Managing Items in an Object Oriented game,"Every once in a while I like to take a break from my other projects to try to make a classic adventure text-based-game (in Python, this time) as a fun project, but I always have design issues implementing the item system. I'd like for the items in the game to descend from one base Item class, containing some attributes that every item has, such as damage and weight. My problems begin when I try to add some functionality to these items. When an item's damage gets past a threshold, it should be destroyed. And there lies my problem: I don't really know how to accomplish that. Since del self won't work for a million different reasons, (Edit: I am intentionally providing the use of 'del' as something that I know is wrong. I know what garbage collection is, and how it is not what I want.) how should I do this (And other similar tasks)? Should each item contain some kind of reference to it's container (The player, I guess) and 'ask' for itself to be deleted? The first thing that comes to mind is a big dictionary containing every item in the game, and each object would have a reference to this list, and both have and know it's own unique ID. I don't like this solution at all and I don't think that it's the right way to go at all. Does anybody have any suggestions? -EDIT: I'm seeing a lot of people thinking that I'm worried about garbage collection. What I'm talking about is not garbage collection, but actually removing the object from gameplay. I'm not sure about what objects should initiate the removal, etc.","at first: i don't have any python experience, so think about this in a more general way -your item should neither know or care ... your Item should have an interface that says it is something destroyable. containers and other objects that care about things that can be destroyed, can make use of that interface -that destroyable interface could have some option for consuming objects to register a callback or event, triggered when the item gets destroyed",-0.0679224682270276,False,3,1286 +EDIT: I'm seeing a lot of people thinking that I'm worried about garbage collection. What I'm talking about is not garbage collection, but actually removing the object from gameplay. I'm not sure about what objects should initiate the removal, etc.","You're conflating two meanings of the ""destroying"" idea. The Item should get destroyed in a ""gameplay"" sense. Let the garbage collector worry about when to destroy it as an object. +Who has a reference to the Item? Perhaps the player has it in his inventory, or it is in a room in the game. In either case your Inventory or Room objects know about the Item. Tell them the Item has been destroyed (in a gameplay sense) and let them handle that. Perhaps they'll now keep a reference to a ""broken"" Item. Perhaps they'll keep track of it, but not display it to the user. Perhaps they'll delete all references to it, in which case the object in memory will soon be deleted. +The beauty of object-oriented programming is that you can abstract these processes away from the Item itself: pass the messages to whoever needs to know, and let them implement in their own way what it means for the Item to be destroyed.",0.0679224682270276,False,3,1286 2011-06-13 19:53:01.430,Python Time Problem,"I'm having trouble figuring out how to do this. I'm trying to run a python script for a set duration. And every 1/10 of the duration I need it to run something. The problem is this step can take any amount of time to complete. I cannot go over the maximum duration set at the start. Example: @@ -14155,23 +14155,23 @@ I'm curious about this in both Python and Perl, and felt silly asking basically If you can include some example operation costs with your answer, that would make it even more helpful.","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. If 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. The initial offset allows O(1) removal of data from the beginning of the string.",0.9950547536867304,False,1,1292 -2011-06-16 11:30:35.540,Python CGI how to save requested information securely?,"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.",Store it outside the document root.,0.0,False,2,1293 2011-06-16 11:30:35.540,Python CGI how to save requested information securely?,"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.","Definitely the wrong tool. Multiple times. Store the file outside of the document root. Store a key to the file in the user's session. Use a web framework. Use WSGI.",1.2,True,2,1293 +2011-06-16 11:30:35.540,Python CGI how to save requested information securely?,"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.",Store it outside the document root.,0.0,False,2,1293 2011-06-16 14:43:07.333,How to access linkedin from python command,"I want to access my linkedin account from command prompt and then i wanted to send mails from my account using command. Also, I need the delivery reports of the mails. Can anyone knows how can use that?","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. This 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.",1.2,True,1,1294 2011-06-17 18:49:28.007,Matplotlib make tick labels font size smaller,"In a matplotlib figure, how can I make the font size for the tick labels using ax1.set_xticklabels() smaller? -Further, how can one rotate it from horizontal to vertical?","In current versions of Matplotlib, you can do axis.set_xticklabels(labels, fontsize='small').",0.7346591565771661,False,2,1295 -2011-06-17 18:49:28.007,Matplotlib make tick labels font size smaller,"In a matplotlib figure, how can I make the font size for the tick labels using ax1.set_xticklabels() smaller? Further, how can one rotate it from horizontal to vertical?","For smaller font, I use ax1.set_xticklabels(xticklabels, fontsize=7) and it works!",0.573727155831378,False,2,1295 +2011-06-17 18:49:28.007,Matplotlib make tick labels font size smaller,"In a matplotlib figure, how can I make the font size for the tick labels using ax1.set_xticklabels() smaller? +Further, how can one rotate it from horizontal to vertical?","In current versions of Matplotlib, you can do axis.set_xticklabels(labels, fontsize='small').",0.7346591565771661,False,2,1295 2011-06-18 03:13:57.857,Split string with caret character in python,"I have a huge text file, each line seems like this: Some sort of general menu^a_sub_menu_title^^pagNumber @@ -14185,6 +14185,11 @@ is there any command i can send to the server to get its version?","I know this 2011-06-21 12:54:25.070,Decoupling Domain classes from Django Model Classes,"So I have completed my OO analysis and design of a web application that I am building and am now getting into implementation. Design decisions have been made to implement the system using Python and the web development framework Django. I want to start implementing some of my domain entity classes which need persistence. It seems that Django would have me implement these as classes that are inherited from the Django models class in order to use the Django ORM for persistence. However, this seems like far too strong coupling between my class entities and the persistence mechanism. What happens if at some stage I want to ditch Django and use another web development framework, or just ditch Django’s ORM for an alternative? Now I have to re-write my domain entity classes from scratch. So it would be better to implement my domain classes as standalone Python classes, encapsulating all my business logic in these, and then use some mechanism (design pattern such as bridge or adapter or ???) to delegate persistence storage of these domain classes to the Django ORM, for example through a Django model class that has been appropriately set up for this. +Does anyone have suggestion on how to go about doing this? It seems from all I have read that people simply implement their domain classes as classes inherited from the Django model class and have business logic mixed within this class. This does not seem a good idea for down line changes, maintenance, reusability etc.","You would not have to ""rewrite your models from scratch"" if you wanted a different persistence mechanism. The whole point of an activerecord-style persistence system is that it imposes minimal constraints on the model classes, and acts largely transparently. +If you're really worried, abstract out any code that relies on queries into their own methods.",0.0,False,4,1298 +2011-06-21 12:54:25.070,Decoupling Domain classes from Django Model Classes,"So I have completed my OO analysis and design of a web application that I am building and am now getting into implementation. Design decisions have been made to implement the system using Python and the web development framework Django. +I want to start implementing some of my domain entity classes which need persistence. It seems that Django would have me implement these as classes that are inherited from the Django models class in order to use the Django ORM for persistence. However, this seems like far too strong coupling between my class entities and the persistence mechanism. What happens if at some stage I want to ditch Django and use another web development framework, or just ditch Django’s ORM for an alternative? Now I have to re-write my domain entity classes from scratch. +So it would be better to implement my domain classes as standalone Python classes, encapsulating all my business logic in these, and then use some mechanism (design pattern such as bridge or adapter or ???) to delegate persistence storage of these domain classes to the Django ORM, for example through a Django model class that has been appropriately set up for this. Does anyone have suggestion on how to go about doing this? It seems from all I have read that people simply implement their domain classes as classes inherited from the Django model class and have business logic mixed within this class. This does not seem a good idea for down line changes, maintenance, reusability etc.","Well, the way to go with Django is to inherit from Django's base model classes. This is the 'active record' pattern. Your django models will have all CRUD and query methods along with you business logic (if you decide to add it of course). This is seen as an anti-pattern in the java world, but the cool thing about it is that it can speed up development really really fast.",0.296905446847765,False,4,1298 2011-06-21 12:54:25.070,Decoupling Domain classes from Django Model Classes,"So I have completed my OO analysis and design of a web application that I am building and am now getting into implementation. Design decisions have been made to implement the system using Python and the web development framework Django. I want to start implementing some of my domain entity classes which need persistence. It seems that Django would have me implement these as classes that are inherited from the Django models class in order to use the Django ORM for persistence. However, this seems like far too strong coupling between my class entities and the persistence mechanism. What happens if at some stage I want to ditch Django and use another web development framework, or just ditch Django’s ORM for an alternative? Now I have to re-write my domain entity classes from scratch. @@ -14195,25 +14200,20 @@ This sort of up-front over-analysis to be avoided. Django is a RAD tool, and is 2011-06-21 12:54:25.070,Decoupling Domain classes from Django Model Classes,"So I have completed my OO analysis and design of a web application that I am building and am now getting into implementation. Design decisions have been made to implement the system using Python and the web development framework Django. I want to start implementing some of my domain entity classes which need persistence. It seems that Django would have me implement these as classes that are inherited from the Django models class in order to use the Django ORM for persistence. However, this seems like far too strong coupling between my class entities and the persistence mechanism. What happens if at some stage I want to ditch Django and use another web development framework, or just ditch Django’s ORM for an alternative? Now I have to re-write my domain entity classes from scratch. So it would be better to implement my domain classes as standalone Python classes, encapsulating all my business logic in these, and then use some mechanism (design pattern such as bridge or adapter or ???) to delegate persistence storage of these domain classes to the Django ORM, for example through a Django model class that has been appropriately set up for this. -Does anyone have suggestion on how to go about doing this? It seems from all I have read that people simply implement their domain classes as classes inherited from the Django model class and have business logic mixed within this class. This does not seem a good idea for down line changes, maintenance, reusability etc.","You would not have to ""rewrite your models from scratch"" if you wanted a different persistence mechanism. The whole point of an activerecord-style persistence system is that it imposes minimal constraints on the model classes, and acts largely transparently. -If you're really worried, abstract out any code that relies on queries into their own methods.",0.0,False,4,1298 -2011-06-21 12:54:25.070,Decoupling Domain classes from Django Model Classes,"So I have completed my OO analysis and design of a web application that I am building and am now getting into implementation. Design decisions have been made to implement the system using Python and the web development framework Django. -I want to start implementing some of my domain entity classes which need persistence. It seems that Django would have me implement these as classes that are inherited from the Django models class in order to use the Django ORM for persistence. However, this seems like far too strong coupling between my class entities and the persistence mechanism. What happens if at some stage I want to ditch Django and use another web development framework, or just ditch Django’s ORM for an alternative? Now I have to re-write my domain entity classes from scratch. -So it would be better to implement my domain classes as standalone Python classes, encapsulating all my business logic in these, and then use some mechanism (design pattern such as bridge or adapter or ???) to delegate persistence storage of these domain classes to the Django ORM, for example through a Django model class that has been appropriately set up for this. Does anyone have suggestion on how to go about doing this? It seems from all I have read that people simply implement their domain classes as classes inherited from the Django model class and have business logic mixed within this class. This does not seem a good idea for down line changes, maintenance, reusability etc.","I think that there's no implemented solution for decoupling Django models and the domain classes, at least I haven't found any. In fact, the only ORM with such decoupling that I know exists only in Smalltalk world and it's called GLORP. It allows you to persist your domain model in a relational DB without having to modify domain classes. I'm currently trying to implement similar ideas to decouple from Django ORM. My motivation is that current strong coupling between DB tables and domain classes hurts software evolution badly. I'll post again if I succeed :)",0.0,False,4,1298 2011-06-21 21:56:45.850,How to do weighted random sample of categories in python,"Given a list of tuples where each tuple consists of a probability and an item I'd like to sample an item according to its probability. For example, give the list [ (.3, 'a'), (.4, 'b'), (.3, 'c')] I'd like to sample 'b' 40% of the time. What's the canonical way of doing this in python? I've looked at the random module which doesn't seem to have an appropriate function and at numpy.random which although it has a multinomial function doesn't seem to return the results in a nice form for this problem. I'm basically looking for something like mnrnd in matlab. Many thanks. -Thanks for all the answers so quickly. To clarify, I'm not looking for explanations of how to write a sampling scheme, but rather to be pointed to an easy way to sample from a multinomial distribution given a set of objects and weights, or to be told that no such function exists in a standard library and so one should write one's own.","Howabout creating 3 ""a"", 4 ""b"" and 3 ""c"" in a list an then just randomly select one. With enough iterations you will get the desired probability.",0.0453204071731508,False,2,1299 -2011-06-21 21:56:45.850,How to do weighted random sample of categories in python,"Given a list of tuples where each tuple consists of a probability and an item I'd like to sample an item according to its probability. For example, give the list [ (.3, 'a'), (.4, 'b'), (.3, 'c')] I'd like to sample 'b' 40% of the time. -What's the canonical way of doing this in python? -I've looked at the random module which doesn't seem to have an appropriate function and at numpy.random which although it has a multinomial function doesn't seem to return the results in a nice form for this problem. I'm basically looking for something like mnrnd in matlab. -Many thanks. Thanks for all the answers so quickly. To clarify, I'm not looking for explanations of how to write a sampling scheme, but rather to be pointed to an easy way to sample from a multinomial distribution given a set of objects and weights, or to be told that no such function exists in a standard library and so one should write one's own.","I'm not sure if this is the pythonic way of doing what you ask, but you could use random.sample(['a','a','a','b','b','b','b','c','c','c'],k) where k is the number of samples you want. For a more robust method, bisect the unit interval into sections based on the cumulative probability and draw from the uniform distribution (0,1) using random.random(). In this case the subintervals would be (0,.3)(.3,.7)(.7,1). You choose the element based on which subinterval it falls into.",0.0,False,2,1299 +2011-06-21 21:56:45.850,How to do weighted random sample of categories in python,"Given a list of tuples where each tuple consists of a probability and an item I'd like to sample an item according to its probability. For example, give the list [ (.3, 'a'), (.4, 'b'), (.3, 'c')] I'd like to sample 'b' 40% of the time. +What's the canonical way of doing this in python? +I've looked at the random module which doesn't seem to have an appropriate function and at numpy.random which although it has a multinomial function doesn't seem to return the results in a nice form for this problem. I'm basically looking for something like mnrnd in matlab. +Many thanks. +Thanks for all the answers so quickly. To clarify, I'm not looking for explanations of how to write a sampling scheme, but rather to be pointed to an easy way to sample from a multinomial distribution given a set of objects and weights, or to be told that no such function exists in a standard library and so one should write one's own.","Howabout creating 3 ""a"", 4 ""b"" and 3 ""c"" in a list an then just randomly select one. With enough iterations you will get the desired probability.",0.0453204071731508,False,2,1299 2011-06-22 19:48:22.617,"Hijacking, redirecting, display output with Python 2.7","I am a new programmer with little experience but I am in the process of learning Python 2.7. I use Python(x,y) or Spydar as the programs are called on Windows 7. The main packages I'm using are numpy, pil and potentially win32gui. I am currently trying to write a program to mine information from a 3rd-party software. This is against their wishes and they have made it difficult. I'm using ImageGrab and then numpy to get some results. This however, or so i belive, forces me to keep the window I want to read in focus, which is not optimal. @@ -14372,17 +14372,16 @@ If you would like me to extend any part of these, simply ask about it.",0.201294 I 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. I 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? I 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. -I would be very thankful if someone with experience with Java, or I also heard python, would comment on my post.",I think you can use PHP or Java Web.,0.0,False,2,1319 +I would be very thankful if someone with experience with Java, or I also heard python, would comment on my post.","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.",0.0,False,2,1319 2011-07-04 18:04:47.947,"Math Intensive, Calculation Based Website - Which Language Should I Use?","I am very new to programming. I am familiar with HTML, C++ and learning PHP to start a database. I 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. I 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? I 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. -I would be very thankful if someone with experience with Java, or I also heard python, would comment on my post.","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.",0.0,False,2,1319 +I would be very thankful if someone with experience with Java, or I also heard python, would comment on my post.",I think you can use PHP or Java Web.,0.0,False,2,1319 2011-07-05 03:49:15.300,matplotlib.pyplot how to add labels with .clabel?,"How can I use pyplot.clabel to attach the file names to the lines being plotted? plt.clabel(data) line gives the error","You may use plt.annotate or plt.text. And, as an aside, 1) you probably want to use different variables for the file names and numpy arrays you're loading your data into (what is data in data=plb.loadtxt(data)), 2) you probably want to move the label positioning into the loop (in your code, what is data in the plt.clabel(data)).",0.0,False,1,1320 -2011-07-05 05:59:58.130,how to encrypt python source code?,"we have a business-critical program implemented in Python. Our boss don't want others, especially our rivals to know how it is designed and implemented. So I have to find a way to encrypt it. I first thought of pyc and pyo, but soon I found that they are likely to be disassembled. I wanna encrypt our source codes, but i don't know how to do it? Could you guys please help me with this? Any guidance would be highly appreciated.","separate confidential functionality in C functions and develop SWIG wrappers. If you are using C++, you can consider boost python.",0.4961739557460144,False,3,1321 2011-07-05 05:59:58.130,how to encrypt python source code?,"we have a business-critical program implemented in Python. Our boss don't want others, especially our rivals to know how it is designed and implemented. So I have to find a way to encrypt it. I first thought of pyc and pyo, but soon I found that they are likely to be disassembled. I wanna encrypt our source codes, but i don't know how to do it? Could you guys please help me with this? Any guidance would be highly appreciated.","I would suggest you go back into thinking about this, considering: Use the right tool for the job @@ -14393,6 +14392,7 @@ Firstly, Python was not designed to be obfuscated. Every aspect of the language Secondly, everything (literally) can be reverse-engineered eventually, so do not assume you'll be able to fully protect any piece of code. You must be able to understand the tradeoff between the importance of hiding a piece of code (for an estimate amount X of resources) versus how useful hiding it actually is (also in terms of effort). Try and realistically evaluate how important your ""design and implementation"" really is, to justify all this. Consider having legal requirements. If you expect people will misuse your code, maybe it would be more useful if you could easily discover the ones that do and turn this into a legal issue.",0.999655594805762,False,3,1321 +2011-07-05 05:59:58.130,how to encrypt python source code?,"we have a business-critical program implemented in Python. Our boss don't want others, especially our rivals to know how it is designed and implemented. So I have to find a way to encrypt it. I first thought of pyc and pyo, but soon I found that they are likely to be disassembled. I wanna encrypt our source codes, but i don't know how to do it? Could you guys please help me with this? Any guidance would be highly appreciated.","separate confidential functionality in C functions and develop SWIG wrappers. If you are using C++, you can consider boost python.",0.4961739557460144,False,3,1321 2011-07-05 05:59:58.130,how to encrypt python source code?,"we have a business-critical program implemented in Python. Our boss don't want others, especially our rivals to know how it is designed and implemented. So I have to find a way to encrypt it. I first thought of pyc and pyo, but soon I found that they are likely to be disassembled. I wanna encrypt our source codes, but i don't know how to do it? Could you guys please help me with this? Any guidance would be highly appreciated.","Anything can be reverse engineered. It is not possible to give a user's machine information without the possibility for the user to examine that information. All you can do is make it take more effort. Python is particularly bad if you have this requirement, because Python bytecode is much easier to read than fully assembled machine code. Ultimately whatever you do to make it more obfuscated, the user's computer will have to be able to de-obfuscate it to turn it into normal Python bytecode in order for the Python interpreter to exectute it. Therefore a motivated user is going to be able to de-obfuscate whatever you give them into Python bytecode as well. If you really have rivals who are likely to want to figure out how your programs work, you must assume that any code you release to end users in any form will be fully understood by your rivals. There is no possible way to absolutely guard against this. @@ -14453,11 +14453,11 @@ Has anyone modified this code to behave reproducibly? Is there some form of call I apologize for not posting an example, but the code is obviously not mine (I'm adding only the call to seed and changing how random is called in the code) and this doesn't appear to be a simple issue with random (I've read all the entries on Python random here and many on the web in general). Thanks. Mark L.","I had the same problem just now with some completely unrelated code. I believe my solution was similar to that in eryksun's answer, though I didn't have any trees. What I did have were some sets, and I was doing random.choice(list(set)) to pick values from them. Sometimes my results (the items picked) were diverging even with the same seed each time and I was close to pulling my hair out. After seeing eryksun's answer here I tried random.choice(sorted(set)) instead, and the problem appears to have disappeared. I don't know enough about the inner workings of Python to explain it.",0.5916962662253621,False,1,1329 +2011-07-08 04:17:45.480,how to disable the window close button in pygame?,"In a pygame application window, the minimize, resize and close buttons are present. Is there a way to disable the close(X) button?","I don't think there is, because some window managers don't give you the ability to remove the close button. But you can write an event handler such that the close button does whatever you want, including nothing. +Why do you want to prevent the user from closing? If it's just a matter that you would rather provide an in-game ""quit"" button that confirms and/or saves before quitting, you can perform the same task when the user hits the close button.",1.2,True,2,1330 2011-07-08 04:17:45.480,how to disable the window close button in pygame?,"In a pygame application window, the minimize, resize and close buttons are present. Is there a way to disable the close(X) button?","Just for the record, another option would be to pass the following argument to the set_mode() method call: pygame.display.set_mode(..., flags = pygame.NOFRAME) This however makes the whole frame go away, including the top strip to move the window around and the other buttons, such as minimize, so it's rather overkill for just getting rid of the X button.",0.0,False,2,1330 -2011-07-08 04:17:45.480,how to disable the window close button in pygame?,"In a pygame application window, the minimize, resize and close buttons are present. Is there a way to disable the close(X) button?","I don't think there is, because some window managers don't give you the ability to remove the close button. But you can write an event handler such that the close button does whatever you want, including nothing. -Why do you want to prevent the user from closing? If it's just a matter that you would rather provide an in-game ""quit"" button that confirms and/or saves before quitting, you can perform the same task when the user hits the close button.",1.2,True,2,1330 2011-07-08 18:05:39.537,Running a Disco map-reduce job on data stored in Discodex,"I have a large amount of static data that needs to offer random access. Since, I'm using Disco to digest it, I'm using the very impressive looking Discodex (key, value) store on top of the Disco Distributed File System. However, Disco's documentation is rather sparse, so I can't figure out how to use my Discodex indices as an input into a Disco job. Is this even possible? If so, how do I do this? Alternatively, I am thinking about this incorrectly? Would it be better to just store that data as a text file on DDFS?","Never mind, it appears that what I'm doing isn't really meant to be done. It might be possible, but it would be far better to merely use semantic DDFS tags to refer to blobs of data. @@ -14470,21 +14470,21 @@ if you want to install it on your windows machine i dont know any package manage Is this even a plausible strategy? Or is this the way they do it: When a page loads, it takes the end datetime from the server and runs a javascript countdown clock against it on the user machine? -If so, how do you do the countdown clock with javascript? And how would I be able to delete/move data once the time limit is over without a user page load? Or is it absolutely necessary for the user to load the page to check the time limit to create an efficient countdown clock?","I don't think this question has anything to do with SQL, really--except that you might retrieve an expiration time from SQL. What you really care about is just how to display the timeout real-time in the browser, right? -Obviously the easiest way is just to send a ""seconds remaining"" counter to the page, either on the initial load, or as part of an AJAX request, then use Javascript to display the timer, and update it every second with the current value. I would opt for using a ""seconds remaining"" counter rather than an ""end datetime"", because you can't trust a browser's clock to be set correctly--but you probably can trust it to count down seconds correctly. -If you don't trust Javascript, or the client's clock, to be accurate, you could periodically re-send the current ""seconds remaining"" value to the browser via AJAX. I wouldn't do this every second, maybe every 15 or 60 seconds at most. -As for deleting/moving data when the clock expires, you'll need to do all of that in Javascript. -I'm not 100% sure I answered all of your questions, but your questions seem a bit scattered anyway. If you need more clarification on the theory of operation, please ask.",0.3869120172231254,False,2,1333 -2011-07-10 04:52:28.137,Live countdown clock with django and sql?,"If I make a live countdown clock like ebay, how do I do this with django and sql? I'm assuming running a function in django or in sql over and over every second to check the time would be horribly inefficient. -Is this even a plausible strategy? -Or is this the way they do it: -When a page loads, it takes the end datetime from the server and runs a javascript countdown clock against it on the user machine? If so, how do you do the countdown clock with javascript? And how would I be able to delete/move data once the time limit is over without a user page load? Or is it absolutely necessary for the user to load the page to check the time limit to create an efficient countdown clock?","I have also encountered the same problem a while ago. First of all your problem is not related neither django nor sql. It is a general concept and it is not very easy to implement because of overhead in server. One solution come into my mind is keeping start time of the process in the database. When someone request you to see remaingn time, read it from database, subtract the current time and server that time and in your browser initialize your javascript function with that value and countdown like 15 sec. After that do the same operation with AJAX without waiting user's request. However, there would be other implementations depending your application. If you explain your application in detail there could be other solutions. For example, if you implement a questionnaire with limited time, then for every answer submit, you should pass the calculated javascript value for that second.",0.0,False,2,1333 +2011-07-10 04:52:28.137,Live countdown clock with django and sql?,"If I make a live countdown clock like ebay, how do I do this with django and sql? I'm assuming running a function in django or in sql over and over every second to check the time would be horribly inefficient. +Is this even a plausible strategy? +Or is this the way they do it: +When a page loads, it takes the end datetime from the server and runs a javascript countdown clock against it on the user machine? +If so, how do you do the countdown clock with javascript? And how would I be able to delete/move data once the time limit is over without a user page load? Or is it absolutely necessary for the user to load the page to check the time limit to create an efficient countdown clock?","I don't think this question has anything to do with SQL, really--except that you might retrieve an expiration time from SQL. What you really care about is just how to display the timeout real-time in the browser, right? +Obviously the easiest way is just to send a ""seconds remaining"" counter to the page, either on the initial load, or as part of an AJAX request, then use Javascript to display the timer, and update it every second with the current value. I would opt for using a ""seconds remaining"" counter rather than an ""end datetime"", because you can't trust a browser's clock to be set correctly--but you probably can trust it to count down seconds correctly. +If you don't trust Javascript, or the client's clock, to be accurate, you could periodically re-send the current ""seconds remaining"" value to the browser via AJAX. I wouldn't do this every second, maybe every 15 or 60 seconds at most. +As for deleting/moving data when the clock expires, you'll need to do all of that in Javascript. +I'm not 100% sure I answered all of your questions, but your questions seem a bit scattered anyway. If you need more clarification on the theory of operation, please ask.",0.3869120172231254,False,2,1333 2011-07-10 21:15:08.507,"Given a bunch of ranges of numbers, get all the numbers within those ranges?","In Python, you can get the numbers in a range by calling range(x,y). But given two ranges, say 5-15, and 10-20 how can you get all the numbers 5-20 without duplicates? The ranges may also be disjoint. I could concat all the results and then uniquify the list, but is that the fastest solution?","Sort the ranges (x, y) by increasing x values. Now, for each range, if it overlaps the previous range, set your current ""big range""'s y value to the current range's y value. If it doesn't, start a new ""big range"": this one won't overlap any of the previous ones. If the current range is completely included in the current big one, ignore it.",0.1016881243684853,False,1,1334 2011-07-11 21:22:00.500,Simplest way to get initial text input in pygame,"So, Iv'e got a pygame application. Right now, it takes a command line argument to specify which display to show the main screen on. However, I'm running it on windows, where it's hard to specify command line input to a graphical application. @@ -14541,11 +14541,6 @@ In the example above, the function I would call would tell me that a and b are ~ 2011-07-15 15:56:07.887,Batch converting Corel Paradox 4.0 Tables to CSV/SQL -- via PHP or other scripts,"Recently I've begun working on exploring ways to convert about 16k Corel Paradox 4.0 database tables (my client has been using a legacy platform over 20 years mainly due to massive logistical matters) to more modern formats (i.e.CSV, SQL, etc.) en mass and so far I've been looking at PHP since it has a library devoted to Paradox data processing however while I'm fairly confident in how to write the conversion code (i.e. simply calling a few file open, close, and write functions) I'm concerned about error detection and ensuring that when running the script, I don't spend hours waiting for it to run only to see 16k corrupt files exported. Also, I'm not fully sure about the logic loop for calling the files. I'm thinking of having the program generate a list of all the files with the appropriate extension and then looping through the list, however I'm not sure if that's ideal for a directory of this size. This is being run on a local Windows 7 x64 system with XAMPP setup (the database is all internal use) so I'm not sure if pure PHP is the best idea -- so I've been wondering if Python or some other lightweight scripting language might be better for handling this. -Thanks very much in advance for any insights and assistance,","If you intend to just convert the data which I guess is a process you do only once you will run the script locally as a command script. For that you don't need a web site and thus XAMPP. What language you take is secondary except you say that PHP has a library. Does python or others have one? -About your concern of error detection why not test your script with only one file first. If that conversion is successful you can build your loop and test this on maybe five files, i.e. have a counter that ends the process after that number. It that is still okay you can go on with the rest. You can also write log data and dump a result for every 100 files processed. This way you can see if your script is doing something or idling.",1.2,True,2,1343 -2011-07-15 15:56:07.887,Batch converting Corel Paradox 4.0 Tables to CSV/SQL -- via PHP or other scripts,"Recently I've begun working on exploring ways to convert about 16k Corel Paradox 4.0 database tables (my client has been using a legacy platform over 20 years mainly due to massive logistical matters) to more modern formats (i.e.CSV, SQL, etc.) en mass and so far I've been looking at PHP since it has a library devoted to Paradox data processing however while I'm fairly confident in how to write the conversion code (i.e. simply calling a few file open, close, and write functions) I'm concerned about error detection and ensuring that when running the script, I don't spend hours waiting for it to run only to see 16k corrupt files exported. -Also, I'm not fully sure about the logic loop for calling the files. I'm thinking of having the program generate a list of all the files with the appropriate extension and then looping through the list, however I'm not sure if that's ideal for a directory of this size. -This is being run on a local Windows 7 x64 system with XAMPP setup (the database is all internal use) so I'm not sure if pure PHP is the best idea -- so I've been wondering if Python or some other lightweight scripting language might be better for handling this. Thanks very much in advance for any insights and assistance,","This is doubtless far too late to help you, but for posterity... If one has a Corel Paradox working environment, one can just use it to ease the transition. We moved the Corel Paradox 9 tables we had into an Oracle schema we built by connecting to the schema (using an alias such as SCHEMA001) then writing this Procedure in a script from inside Paradox: @@ -14572,6 +14567,11 @@ method run(var eventInfo Event) ""That's all, folks!"" ) return endMethod",0.2012947653214861,False,2,1343 +2011-07-15 15:56:07.887,Batch converting Corel Paradox 4.0 Tables to CSV/SQL -- via PHP or other scripts,"Recently I've begun working on exploring ways to convert about 16k Corel Paradox 4.0 database tables (my client has been using a legacy platform over 20 years mainly due to massive logistical matters) to more modern formats (i.e.CSV, SQL, etc.) en mass and so far I've been looking at PHP since it has a library devoted to Paradox data processing however while I'm fairly confident in how to write the conversion code (i.e. simply calling a few file open, close, and write functions) I'm concerned about error detection and ensuring that when running the script, I don't spend hours waiting for it to run only to see 16k corrupt files exported. +Also, I'm not fully sure about the logic loop for calling the files. I'm thinking of having the program generate a list of all the files with the appropriate extension and then looping through the list, however I'm not sure if that's ideal for a directory of this size. +This is being run on a local Windows 7 x64 system with XAMPP setup (the database is all internal use) so I'm not sure if pure PHP is the best idea -- so I've been wondering if Python or some other lightweight scripting language might be better for handling this. +Thanks very much in advance for any insights and assistance,","If you intend to just convert the data which I guess is a process you do only once you will run the script locally as a command script. For that you don't need a web site and thus XAMPP. What language you take is secondary except you say that PHP has a library. Does python or others have one? +About your concern of error detection why not test your script with only one file first. If that conversion is successful you can build your loop and test this on maybe five files, i.e. have a counter that ends the process after that number. It that is still okay you can go on with the rest. You can also write log data and dump a result for every 100 files processed. This way you can see if your script is doing something or idling.",1.2,True,2,1343 2011-07-15 18:08:34.853,how to copy python modules into python lib directory,"I have some python modules to copy into my Linux computer. I found out that I need to copy them into one of the directory that python searches or else show a new path for it. 1. when I tried to copy files into /usr/bin/..../python2.6 .. its not allowing me. @@ -14636,16 +14636,7 @@ Preferably it should take advantage of http keep-alive to maximize the transfer Please don't suggest how I may go about implementing the above requirements. I'm looking for a ready-made, battle-tested solution. I guess I should describe what I want it for too... I have about 300 different data feeds as xml formatted files served from 50 data providers. Each file is between 100kb and 5mb in size. I need to poll them frequently (as in once every few minutes) to determine if any of them has new data I need to process. So it is important that the downloader uses http caching to minimize the amount of data to fetch. It also uses gzip compression obviously. -Then the big problem is how to use the bandwidth in an as efficient manner as possible without overstepping any boundaries. For example, one data provider may consider it abuse if you open 20 simultaneous connections to their data feeds. Instead it may be better to use one or two connections that are reused for multiple files. Or your own connection may be limited in strange ways.. My isp limits the number of dns lookups you can do so some kind of dns caching would be nice.","There are lots of options but it will be hard to find one which fits all your needs. -In your case, try this approach: - -Create a queue. -Put URLs to download into this queue (or ""config objects"" which contain the URL and other data like the user name, the destination file, etc). -Create a pool of threads -Each thread should try to fetch a URL (or a config object) from the queue and process it. - -Use another thread to collect the results (i.e. another queue). When the number of result objects == number of puts in the first queue, then you're finished. -Make sure that all communication goes via the queue or the ""config object"". Avoid accessing data structures which are shared between threads. This should save you 99% of the problems.",0.2012947653214861,False,4,1350 +Then the big problem is how to use the bandwidth in an as efficient manner as possible without overstepping any boundaries. For example, one data provider may consider it abuse if you open 20 simultaneous connections to their data feeds. Instead it may be better to use one or two connections that are reused for multiple files. Or your own connection may be limited in strange ways.. My isp limits the number of dns lookups you can do so some kind of dns caching would be nice.","I used the standard libs for that, urllib.urlretrieve to be precise. downloaded podcasts this way, via a simple thread pool, each using its own retrieve. I did about 10 simultanous connections, more should not be a problem. Continue a interrupted download, maybe not. Ctrl-C could be handled, I guess. Worked on Windows, installed a handler for progress bars. All in all 2 screens of code, 2 screens for generating the URLs to retrieve.",0.0,False,4,1350 2011-07-19 16:28:11.523,Library or tool to download multiple files in parallel,"I'm looking for a python library or a command line tool for downloading multiple files in parallel. My current solution is to download the files sequentially which is slow. I know you can easily write a half-assed threaded solution in python, but I always run into annoying problem when using threading. It is for polling a large number of xml feeds from websites. My requirements for the solution are: @@ -14660,8 +14651,13 @@ Preferably it should take advantage of http keep-alive to maximize the transfer Please don't suggest how I may go about implementing the above requirements. I'm looking for a ready-made, battle-tested solution. I guess I should describe what I want it for too... I have about 300 different data feeds as xml formatted files served from 50 data providers. Each file is between 100kb and 5mb in size. I need to poll them frequently (as in once every few minutes) to determine if any of them has new data I need to process. So it is important that the downloader uses http caching to minimize the amount of data to fetch. It also uses gzip compression obviously. -Then the big problem is how to use the bandwidth in an as efficient manner as possible without overstepping any boundaries. For example, one data provider may consider it abuse if you open 20 simultaneous connections to their data feeds. Instead it may be better to use one or two connections that are reused for multiple files. Or your own connection may be limited in strange ways.. My isp limits the number of dns lookups you can do so some kind of dns caching would be nice.","Threading isn't ""half-assed"" unless you're a bad programmer. The best general approach to this problem is the producer / consumer model. You have one dedicated URL producer, and N dedicated download threads (or even processes if you use the multiprocessing model). -As for all of your requirements, ALL of them CAN be done with the normal python threaded model (yes, even catching Ctrl+C -- I've done it).",-0.0407936753323291,False,4,1350 +Then the big problem is how to use the bandwidth in an as efficient manner as possible without overstepping any boundaries. For example, one data provider may consider it abuse if you open 20 simultaneous connections to their data feeds. Instead it may be better to use one or two connections that are reused for multiple files. Or your own connection may be limited in strange ways.. My isp limits the number of dns lookups you can do so some kind of dns caching would be nice.","You can try pycurl, though the interface is not easy at first, but once you look at examples, its not hard to understand. I have used it to fetch 1000s of web pages in parallel on meagre linux box. + +You don't have to deal with threads, so it terminates gracefully, and there are no processes left behind +It provides options for timeout, and http status handling. +It works on both linux and windows. + +The only problem is that it provides a basic infrastructure (basically just a python layer above the excellent curl library). You will have to write few lines to achieve the features as you want.",0.2781854903257024,False,4,1350 2011-07-19 16:28:11.523,Library or tool to download multiple files in parallel,"I'm looking for a python library or a command line tool for downloading multiple files in parallel. My current solution is to download the files sequentially which is slow. I know you can easily write a half-assed threaded solution in python, but I always run into annoying problem when using threading. It is for polling a large number of xml feeds from websites. My requirements for the solution are: @@ -14676,13 +14672,8 @@ Preferably it should take advantage of http keep-alive to maximize the transfer Please don't suggest how I may go about implementing the above requirements. I'm looking for a ready-made, battle-tested solution. I guess I should describe what I want it for too... I have about 300 different data feeds as xml formatted files served from 50 data providers. Each file is between 100kb and 5mb in size. I need to poll them frequently (as in once every few minutes) to determine if any of them has new data I need to process. So it is important that the downloader uses http caching to minimize the amount of data to fetch. It also uses gzip compression obviously. -Then the big problem is how to use the bandwidth in an as efficient manner as possible without overstepping any boundaries. For example, one data provider may consider it abuse if you open 20 simultaneous connections to their data feeds. Instead it may be better to use one or two connections that are reused for multiple files. Or your own connection may be limited in strange ways.. My isp limits the number of dns lookups you can do so some kind of dns caching would be nice.","You can try pycurl, though the interface is not easy at first, but once you look at examples, its not hard to understand. I have used it to fetch 1000s of web pages in parallel on meagre linux box. - -You don't have to deal with threads, so it terminates gracefully, and there are no processes left behind -It provides options for timeout, and http status handling. -It works on both linux and windows. - -The only problem is that it provides a basic infrastructure (basically just a python layer above the excellent curl library). You will have to write few lines to achieve the features as you want.",0.2781854903257024,False,4,1350 +Then the big problem is how to use the bandwidth in an as efficient manner as possible without overstepping any boundaries. For example, one data provider may consider it abuse if you open 20 simultaneous connections to their data feeds. Instead it may be better to use one or two connections that are reused for multiple files. Or your own connection may be limited in strange ways.. My isp limits the number of dns lookups you can do so some kind of dns caching would be nice.","Threading isn't ""half-assed"" unless you're a bad programmer. The best general approach to this problem is the producer / consumer model. You have one dedicated URL producer, and N dedicated download threads (or even processes if you use the multiprocessing model). +As for all of your requirements, ALL of them CAN be done with the normal python threaded model (yes, even catching Ctrl+C -- I've done it).",-0.0407936753323291,False,4,1350 2011-07-19 16:28:11.523,Library or tool to download multiple files in parallel,"I'm looking for a python library or a command line tool for downloading multiple files in parallel. My current solution is to download the files sequentially which is slow. I know you can easily write a half-assed threaded solution in python, but I always run into annoying problem when using threading. It is for polling a large number of xml feeds from websites. My requirements for the solution are: @@ -14697,7 +14688,16 @@ Preferably it should take advantage of http keep-alive to maximize the transfer Please don't suggest how I may go about implementing the above requirements. I'm looking for a ready-made, battle-tested solution. I guess I should describe what I want it for too... I have about 300 different data feeds as xml formatted files served from 50 data providers. Each file is between 100kb and 5mb in size. I need to poll them frequently (as in once every few minutes) to determine if any of them has new data I need to process. So it is important that the downloader uses http caching to minimize the amount of data to fetch. It also uses gzip compression obviously. -Then the big problem is how to use the bandwidth in an as efficient manner as possible without overstepping any boundaries. For example, one data provider may consider it abuse if you open 20 simultaneous connections to their data feeds. Instead it may be better to use one or two connections that are reused for multiple files. Or your own connection may be limited in strange ways.. My isp limits the number of dns lookups you can do so some kind of dns caching would be nice.","I used the standard libs for that, urllib.urlretrieve to be precise. downloaded podcasts this way, via a simple thread pool, each using its own retrieve. I did about 10 simultanous connections, more should not be a problem. Continue a interrupted download, maybe not. Ctrl-C could be handled, I guess. Worked on Windows, installed a handler for progress bars. All in all 2 screens of code, 2 screens for generating the URLs to retrieve.",0.0,False,4,1350 +Then the big problem is how to use the bandwidth in an as efficient manner as possible without overstepping any boundaries. For example, one data provider may consider it abuse if you open 20 simultaneous connections to their data feeds. Instead it may be better to use one or two connections that are reused for multiple files. Or your own connection may be limited in strange ways.. My isp limits the number of dns lookups you can do so some kind of dns caching would be nice.","There are lots of options but it will be hard to find one which fits all your needs. +In your case, try this approach: + +Create a queue. +Put URLs to download into this queue (or ""config objects"" which contain the URL and other data like the user name, the destination file, etc). +Create a pool of threads +Each thread should try to fetch a URL (or a config object) from the queue and process it. + +Use another thread to collect the results (i.e. another queue). When the number of result objects == number of puts in the first queue, then you're finished. +Make sure that all communication goes via the queue or the ""config object"". Avoid accessing data structures which are shared between threads. This should save you 99% of the problems.",0.2012947653214861,False,4,1350 2011-07-19 23:18:53.013,Check the exit status of last command in ipython,Does anybody know how to check the status of the last executed command (exit code) in ipython?,It should be stored as _exit_code after you run the command (at least in the upcoming v0.11 release).,0.9999533828843172,False,1,1351 2011-07-20 15:21:05.050,Optimizing your PyQt applications,"For those of you who have written fairly complex PyQt applications, what tips and tricks would you offer for speeding up your applications? I have a few examples of where my program begins to slow down as it grows larger: @@ -14705,18 +14705,18 @@ I have a 'dashboard' written that is destroyed and re-created when a user clicks Each dashboard also loads an image from a network location. This creates some slowdown as one navigates around the application, but after it's loaded into memory, 'going back to that same dash' is faster. Is there a good method or way to run a thread on program load that maybe pre-loads the images into memory? If so, how do you implement that? When you have a large variety of dashboard items and data that gets loaded into them, do you guys normally thread the data load and load it back in which each thread completes? Is this viable when somebody is browsing around quickly? Would implementing a kill-switch for the threads such that when a user changes dashboards, the threads die work? Or would the constant creation and killing of threads cause some sort of, well, meltdown. -Sorry for the huge barrage of questions, but they seemed similar enough to warrant bundling them together.","Are you using QNetworkAccessManager to load you images? It has cache support. Also it loads everything in background with finishing callbacks. -I don't really understand what your dashboard is doing. Have you think about using QWebkit? Maybe your dashboard content is easy to be implemented in HTML? -PS. I don't like threads in Python and don't think they are good idea. Deferred jobs delegated to Qt core is better.",0.2012947653214861,False,2,1352 +Sorry for the huge barrage of questions, but they seemed similar enough to warrant bundling them together.","I'm not sure if this is exactly the same thing you are doing, but it sounds similar to something I have in some apps, where there is some list of custom widget. And it does significantly slow down when you are creating and destroying tons of widgets. +If its an issue of lesser amounts of total widgets, but just being created and deleted a lot, you can just create the widgets once, and only change the data of those widgets as information needs to be updated... as opposed to creating new widgets each time the information changes. That way you can even change the data from threads without having to worry about creating widgets. +Another situation is where you are displaying a list with custom widgets and there are a TON of results. I notice it always slows down when you have 1000's of custom widgets in a list. A trick my co-worker came up with was to have a fake kind of list where it is using a static number of slots in the display. Say, it shows 10 slots in the view. The scrollbar doesn't really scroll down across MORE widget...what it does is scrolls the DATA through the 10 visible widgets. You can a crazy performance increase doing that. But only if it is an acceptable display style for your application.",1.2,True,2,1352 2011-07-20 15:21:05.050,Optimizing your PyQt applications,"For those of you who have written fairly complex PyQt applications, what tips and tricks would you offer for speeding up your applications? I have a few examples of where my program begins to slow down as it grows larger: I have a 'dashboard' written that is destroyed and re-created when a user clicks on an item in a TreeWidget. What would be a better way to have a modular interface where clicking an item in the TreeWidget changes the dashboard, but doesn't require destroying a widget and recreating it. Each dashboard also loads an image from a network location. This creates some slowdown as one navigates around the application, but after it's loaded into memory, 'going back to that same dash' is faster. Is there a good method or way to run a thread on program load that maybe pre-loads the images into memory? If so, how do you implement that? When you have a large variety of dashboard items and data that gets loaded into them, do you guys normally thread the data load and load it back in which each thread completes? Is this viable when somebody is browsing around quickly? Would implementing a kill-switch for the threads such that when a user changes dashboards, the threads die work? Or would the constant creation and killing of threads cause some sort of, well, meltdown. -Sorry for the huge barrage of questions, but they seemed similar enough to warrant bundling them together.","I'm not sure if this is exactly the same thing you are doing, but it sounds similar to something I have in some apps, where there is some list of custom widget. And it does significantly slow down when you are creating and destroying tons of widgets. -If its an issue of lesser amounts of total widgets, but just being created and deleted a lot, you can just create the widgets once, and only change the data of those widgets as information needs to be updated... as opposed to creating new widgets each time the information changes. That way you can even change the data from threads without having to worry about creating widgets. -Another situation is where you are displaying a list with custom widgets and there are a TON of results. I notice it always slows down when you have 1000's of custom widgets in a list. A trick my co-worker came up with was to have a fake kind of list where it is using a static number of slots in the display. Say, it shows 10 slots in the view. The scrollbar doesn't really scroll down across MORE widget...what it does is scrolls the DATA through the 10 visible widgets. You can a crazy performance increase doing that. But only if it is an acceptable display style for your application.",1.2,True,2,1352 +Sorry for the huge barrage of questions, but they seemed similar enough to warrant bundling them together.","Are you using QNetworkAccessManager to load you images? It has cache support. Also it loads everything in background with finishing callbacks. +I don't really understand what your dashboard is doing. Have you think about using QWebkit? Maybe your dashboard content is easy to be implemented in HTML? +PS. I don't like threads in Python and don't think they are good idea. Deferred jobs delegated to Qt core is better.",0.2012947653214861,False,2,1352 2011-07-22 15:00:33.983,put stream from tcpdump into an array - which python version should i use?,"i want to use python in combination with tcpdump to put the generated stream from tcpdump into a more readable way. There are some fields in the streams with interesting values. I found some stuff here at stackoverflow regarding python and tcpdump but in my mind the best way is to put it in an array. After this is done i want to read some fields out of the array, and than it can be cleared and used for the next network frame. @@ -14724,23 +14724,23 @@ Can somebody give me some hints, how this can be done?","You can try using Scapy 2011-07-22 20:20:08.850,"Numpy: arr[...,0,:] works. But how do I store the data contained in the slice command (..., 0, :)?","In Numpy (and Python in general, I suppose), how does one store a slice-index, such as (...,0,:), in order to pass it around and apply it to various arrays? It would be nice to, say, be able to pass a slice-index to and from functions.","I think you want to just do myslice = slice(1,2) to for example define a slice that will return the 2nd element (i.e. myarray[myslice] == myarray[1:2])",0.0,False,1,1354 2011-07-23 17:35:15.290,Pylint - distinguish new errors from old ones,"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? I'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. +As 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.","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. +If 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. +If 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.",1.2,True,2,1355 +2011-07-23 17:35:15.290,Pylint - distinguish new errors from old ones,"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? +I'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. As 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.","Run pylint on dev branch, get x errors Run pylint on master branch, get y errors If y > x, which means you have new errors You can do above things in CI process, before code is merged to master",0.0,False,2,1355 -2011-07-23 17:35:15.290,Pylint - distinguish new errors from old ones,"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? -I'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. -As 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.","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. -If 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. -If 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.",1.2,True,2,1355 2011-07-23 19:06:22.023,Best way to do email scheduling on a python web application?,"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). The 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. Other than implementing this myself (probably with a DB and a worker), is there an existing solution to email queue and scheduling? -Thanks!","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.",0.0,False,2,1356 +Thanks!","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.",0.0,False,2,1356 2011-07-23 19:06:22.023,Best way to do email scheduling on a python web application?,"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). The 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. Other than implementing this myself (probably with a DB and a worker), is there an existing solution to email queue and scheduling? -Thanks!","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.",0.0,False,2,1356 +Thanks!","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.",0.0,False,2,1356 2011-07-24 10:30:37.580,git-python get commit feed from a repository,"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. Can someone advice? regards,","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 :)",0.1016881243684853,False,1,1357 @@ -14772,6 +14772,24 @@ I need the button to automate it). Specs: +Python 2.7.1 +Tkinter +Windows 7","You can use right-anchored geometry specifications by using a minus sign in the right place: +123x467-78+9 +However, I don't know if this will work on Windows (the above is an X11 trick, and I don't know if it is implemented in the platform-compatibility layer or not); you might have to just calculate the new position given the projected size of the left side and use that.",0.2655860252697744,False,2,1361 +2011-07-29 07:51:12.170,Resize Tkinter Window FROM THE RIGHT (python),"I'm not sure on how to articulate this... +I have a Tkinter window, and I need to hide half of this window when a button is pressed. +However, I need the left-most side to be hidden, so that the window is now half the size it originally was, +and shows the right half of the original window. +All of Tkinter's resize functions span from the left side of the window. +Changing the geometry values can only show the left side whilst hiding the right; +I need the inverse. +Does anybody know how to go about doing this? +(I don't want the user to have to drag the window border, +I need the button to automate it). + +Specs: + Python 2.7.1 Tkinter Windows 7","My IT teacher had a suggestion: @@ -14786,52 +14804,34 @@ I'm not sure if there's a function to set the current position of the scrollbar but I'd imagine there is. Have yet to implement this, but it looks promising. Thanks for the suggestions!",0.0,False,2,1361 -2011-07-29 07:51:12.170,Resize Tkinter Window FROM THE RIGHT (python),"I'm not sure on how to articulate this... -I have a Tkinter window, and I need to hide half of this window when a button is pressed. -However, I need the left-most side to be hidden, so that the window is now half the size it originally was, -and shows the right half of the original window. -All of Tkinter's resize functions span from the left side of the window. -Changing the geometry values can only show the left side whilst hiding the right; -I need the inverse. -Does anybody know how to go about doing this? -(I don't want the user to have to drag the window border, -I need the button to automate it). - -Specs: - -Python 2.7.1 -Tkinter -Windows 7","You can use right-anchored geometry specifications by using a minus sign in the right place: -123x467-78+9 -However, I don't know if this will work on Windows (the above is an X11 trick, and I don't know if it is implemented in the platform-compatibility layer or not); you might have to just calculate the new position given the projected size of the left side and use that.",0.2655860252697744,False,2,1361 2011-07-29 13:52:54.413,How to get pylint warnings to be marked in the Pydev Eclipse editor margin?,"I have pylint installed (works fine on the command line) and set up within Pydev in Eclipse. Pylint is being triggered OK when I edit files, and is outputting to the Eclipse console. But, the pylint warnings don't appear as marks in the editor margin (in the same way as compiler warnings and errors) Newly-generated warnings don't appear in the Problems view either - there are some old ones showing, but they disappear if I re-save the relevant module. I know this is possible as I've had it working previously - but how do I set this up? -Ticking or unticking ""Redirect Pylint output to console?"" doesn't seem to make any difference.",have you tried rebuilding your project?,0.0,False,4,1362 +Ticking or unticking ""Redirect Pylint output to console?"" doesn't seem to make any difference.","I had this exact problem today, on a brand new system. I tracked down the cause, and it seems that PyDev refuses to pick up the messages from pylint 0.24.0, which was released on July 20, 2011. +Reverting to the previous version (pylint 0.23.0) seems to have solved the problem. For me, that involved removing everything from Python's Lib/site-packages directory that was related to pylint, and then running python setup.py install from the directory I'd extracted pylint 0.23.0 into. (Without deleting those files in the site-packages directory first, it kept using the new version.) But after both those steps, the messages started showing up in PyDev as expected. +You can check your pylint version with pylint --version from a shell prompt; if it shows 0.23.0 you're good to go.",1.2,True,4,1362 2011-07-29 13:52:54.413,How to get pylint warnings to be marked in the Pydev Eclipse editor margin?,"I have pylint installed (works fine on the command line) and set up within Pydev in Eclipse. Pylint is being triggered OK when I edit files, and is outputting to the Eclipse console. But, the pylint warnings don't appear as marks in the editor margin (in the same way as compiler warnings and errors) Newly-generated warnings don't appear in the Problems view either - there are some old ones showing, but they disappear if I re-save the relevant module. I know this is possible as I've had it working previously - but how do I set this up? -Ticking or unticking ""Redirect Pylint output to console?"" doesn't seem to make any difference.","Only modules reachable through PYTHONPATH are passed to pylint, so you need to set your PYTHONPATH correctly in the project options.",-0.0814518047658113,False,4,1362 +Ticking or unticking ""Redirect Pylint output to console?"" doesn't seem to make any difference.","I was having the same problem, and it turned out to be my pylint configuration file (~/.pylintrc by default). Be sure the output-format field is correct. It is under the [REPORTS] section, and the line should be: +output-format=text +If you've ever used pylint with another application (I do with emacs), it might say output-format=parseable.",0.1618299653758019,False,4,1362 2011-07-29 13:52:54.413,How to get pylint warnings to be marked in the Pydev Eclipse editor margin?,"I have pylint installed (works fine on the command line) and set up within Pydev in Eclipse. Pylint is being triggered OK when I edit files, and is outputting to the Eclipse console. But, the pylint warnings don't appear as marks in the editor margin (in the same way as compiler warnings and errors) Newly-generated warnings don't appear in the Problems view either - there are some old ones showing, but they disappear if I re-save the relevant module. I know this is possible as I've had it working previously - but how do I set this up? -Ticking or unticking ""Redirect Pylint output to console?"" doesn't seem to make any difference.","I was having the same problem, and it turned out to be my pylint configuration file (~/.pylintrc by default). Be sure the output-format field is correct. It is under the [REPORTS] section, and the line should be: -output-format=text -If you've ever used pylint with another application (I do with emacs), it might say output-format=parseable.",0.1618299653758019,False,4,1362 +Ticking or unticking ""Redirect Pylint output to console?"" doesn't seem to make any difference.","Only modules reachable through PYTHONPATH are passed to pylint, so you need to set your PYTHONPATH correctly in the project options.",-0.0814518047658113,False,4,1362 2011-07-29 13:52:54.413,How to get pylint warnings to be marked in the Pydev Eclipse editor margin?,"I have pylint installed (works fine on the command line) and set up within Pydev in Eclipse. Pylint is being triggered OK when I edit files, and is outputting to the Eclipse console. But, the pylint warnings don't appear as marks in the editor margin (in the same way as compiler warnings and errors) Newly-generated warnings don't appear in the Problems view either - there are some old ones showing, but they disappear if I re-save the relevant module. I know this is possible as I've had it working previously - but how do I set this up? -Ticking or unticking ""Redirect Pylint output to console?"" doesn't seem to make any difference.","I had this exact problem today, on a brand new system. I tracked down the cause, and it seems that PyDev refuses to pick up the messages from pylint 0.24.0, which was released on July 20, 2011. -Reverting to the previous version (pylint 0.23.0) seems to have solved the problem. For me, that involved removing everything from Python's Lib/site-packages directory that was related to pylint, and then running python setup.py install from the directory I'd extracted pylint 0.23.0 into. (Without deleting those files in the site-packages directory first, it kept using the new version.) But after both those steps, the messages started showing up in PyDev as expected. -You can check your pylint version with pylint --version from a shell prompt; if it shows 0.23.0 you're good to go.",1.2,True,4,1362 +Ticking or unticking ""Redirect Pylint output to console?"" doesn't seem to make any difference.",have you tried rebuilding your project?,0.0,False,4,1362 2011-07-29 15:41:35.683,With python socketserver how can I pass a variable to the constructor of the handler class,"I would like to pass my database connection to the EchoHandler class, however I can't figure out how to do that or access the EchoHandler class at all. @@ -14870,9 +14870,7 @@ I'm also looking to learn and develop with the language that will be most benefi I'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? I 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. Basically - 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? -Thanks","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 -php 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 -which 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",0.1352210990936997,False,3,1368 +Thanks",I would recomend looking at asp.net mvc and scaffolding. That way you can create good applications quick and effective.,0.0,False,3,1368 2011-08-01 10:10:52.030,Python + Django vs. ASP.NET + C#/VB vs PHP?,"I know similar questions to this have been asked before, but I'm looking for a more specific answer so here it goes: I'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.. I'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. @@ -14889,7 +14887,9 @@ I'm also looking to learn and develop with the language that will be most benefi I'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? I 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. Basically - 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? -Thanks",I would recomend looking at asp.net mvc and scaffolding. That way you can create good applications quick and effective.,0.0,False,3,1368 +Thanks","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 +php 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 +which 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",0.1352210990936997,False,3,1368 2011-08-01 20:28:58.750,Copying files recursively with skipping some directories in Python?,"I want to copy a directory to another directory recursively. I also want to ignore some files (eg. all hidden files; everything starting with ""."") and then run a function on all the other files (after copying them). This is simple to do in the shell, but I need a Python script. I tried using shutil.copytree, which has ignore support, but I don't know how to have it do a function on each file copied. I might also need to check some other condition when copying so I can't just run the function on all the files once they are copied over. I also tried looking at os.walk but I couldn't figure it out.","If you're on Python 2.6 or higher, you can simply use shutil.copytree and its ignore argument. Since it gets passed all the files and directories, you can call your function from there, unless you want it to be called right after the file is copied. If that is the case, the easiest thing is to copy and modify the copytree code.",0.6730655149877884,False,1,1369 @@ -14930,12 +14930,12 @@ in pyudev, class Device has some general attributes, but not uuid or mount node. how to do it thanks help","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'].",0.5457054096481145,False,1,1374 2011-08-04 04:37:41.810,Checking the status of a sent email in django,"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? -if so how can i do it?","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. -If 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.",0.3869120172231254,False,2,1375 -2011-08-04 04:37:41.810,Checking the status of a sent email in django,"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? if so how can i do it?","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. There is no way you can do it and know it's a live e-mail for sure... Besides 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.",0.1352210990936997,False,2,1375 +2011-08-04 04:37:41.810,Checking the status of a sent email in django,"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? +if so how can i do it?","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. +If 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.",0.3869120172231254,False,2,1375 2011-08-04 12:15:27.427,how to split pdf file into multiple pdf files by specific word?,"I have one pdf file. I want to split that file into multiple pdf files by some specific word from that file. how can i do that in python ?",Have a look at pdftk. It is a toolbox for working with pdf files. You can integrate it into python with the subprocess module.,0.3869120172231254,False,1,1376 2011-08-06 13:22:56.023,Python private class variables that aren't class variables,"When trying to access __variables from a class, the parser assumes the 2 underscores are private relative to the current class. Notice how an unrelated function gets a ""private"" variable. @@ -15020,17 +15020,17 @@ I don't know if I should: Monkey patch pdb from settings.py (dependding on DEBUG boolean). Make a pdb wrapper for our project which expose set_trace or print basic log if DEBUG = True -Dissalow comitting brakpoints on git hooks... (if you think it's the best idea how would you do that?).","The third one. You have to enforce some commit rules. For example, run a serie of tests before a commit, etc. This way, developpers have a simple way to check if a pdb break remain. If someone commit a set_trace, he has to bake a cake for the rest of the team. -This works fine in my company :-) -edit: you may present this method to your boss as CDD (Cake Driven Developpement)",1.2,True,2,1384 +Dissalow comitting brakpoints on git hooks... (if you think it's the best idea how would you do that?).","The best option would be to have an extensive test suite, and to run the tests before pushing to production. Extraneous pdb breakpoints will prevent the tests from passing. +If you can't do that, then option 2 is the best: write a utility to break into the debugger, and make it sensitive to the state of the settings. You still have to solve the problem of how to be sure people use the wrapper rather than a raw pdb call though.",0.1352210990936997,False,2,1384 2011-08-11 14:37:30.293,How to ensure there are no pdb calls out of debugging configuration?,"What do you suggest to get rid of pdb calls on production software? In my case, I'm developing a django website. I don't know if I should: Monkey patch pdb from settings.py (dependding on DEBUG boolean). Make a pdb wrapper for our project which expose set_trace or print basic log if DEBUG = True -Dissalow comitting brakpoints on git hooks... (if you think it's the best idea how would you do that?).","The best option would be to have an extensive test suite, and to run the tests before pushing to production. Extraneous pdb breakpoints will prevent the tests from passing. -If you can't do that, then option 2 is the best: write a utility to break into the debugger, and make it sensitive to the state of the settings. You still have to solve the problem of how to be sure people use the wrapper rather than a raw pdb call though.",0.1352210990936997,False,2,1384 +Dissalow comitting brakpoints on git hooks... (if you think it's the best idea how would you do that?).","The third one. You have to enforce some commit rules. For example, run a serie of tests before a commit, etc. This way, developpers have a simple way to check if a pdb break remain. If someone commit a set_trace, he has to bake a cake for the rest of the team. +This works fine in my company :-) +edit: you may present this method to your boss as CDD (Cake Driven Developpement)",1.2,True,2,1384 2011-08-11 22:11:38.230,"How do generate random numbers, while avoiding numbers already used","How do i generate random numbers but have the numbers avoid numbers already used. I have a TXT file with thousands of sets of numbers and i need to generate a series of random numbers while avoiding these. IE, TXT - 0102030405 @@ -15087,9 +15087,9 @@ I want the messages also be stored on the database, so do I need any special con to prevent my application blocking when writing to the database? Will running a chat server with Django have any impact on my ability to serve files from Apache?","Instead of Apache + X-Sendfile you could use Nginx + X-Accel-Redirect. That way you can run a gevent/wsgi/django server behind Nginx with views that provide long-polling. No need for a separate websockets server. I've used both Apache + X-Sendfile and Nginx + X-Accel-Redirect to serve (access-protected) content on Webfaction without any problems.",0.2012947653214861,False,1,1393 -2011-08-15 14:50:49.363,Using Non-Standard Python Install,"I recently attempted to upgrade our Python install on a CentOS server from 2.4.3 to 2.7, however it lists 2.4.3 as the newest stable release. This is a problem because I have a Python program that requires at least 2.7 to run properly. After contacting support they installed Python 2.7 in a separate directory, however I'm not sure how to access this version. Anytime I try to run the python program it uses the 2.4.3 version. I have looked into changing the PythonHome variable, but can't get it to work correctly. Is there anything I can do via the command line or inside the program itself to specify which Python version I want to use?","Try specifying the full path to the python executable (i.e. /opt/python27/python) rather than using a bare python command. Alternatively, place /opt/python27/ on your PATH earlier than /usr/local/bin (where the python command is presumably already present, you can check with which python).",1.2,True,2,1394 2011-08-15 14:50:49.363,Using Non-Standard Python Install,"I recently attempted to upgrade our Python install on a CentOS server from 2.4.3 to 2.7, however it lists 2.4.3 as the newest stable release. This is a problem because I have a Python program that requires at least 2.7 to run properly. After contacting support they installed Python 2.7 in a separate directory, however I'm not sure how to access this version. Anytime I try to run the python program it uses the 2.4.3 version. I have looked into changing the PythonHome variable, but can't get it to work correctly. Is there anything I can do via the command line or inside the program itself to specify which Python version I want to use?","I'd suggest you ask your support team to build a separate RPM for Python2.7 and have it installed in a separate location and not conflicting with the OS version. I've done this before it was great to have a consistent Python released across my RHEL3, 4, and 5 systems. Next, I'd suggest you use the following for your sh-bang (first line) ""#!/bin/env python2.7"" and then ensure your PATH includes the supplemental Python install path. This way, your script stays the same as you run it on your workstation, with it's own unique path to python2.7, and the production environment as well.",0.3869120172231254,False,2,1394 +2011-08-15 14:50:49.363,Using Non-Standard Python Install,"I recently attempted to upgrade our Python install on a CentOS server from 2.4.3 to 2.7, however it lists 2.4.3 as the newest stable release. This is a problem because I have a Python program that requires at least 2.7 to run properly. After contacting support they installed Python 2.7 in a separate directory, however I'm not sure how to access this version. Anytime I try to run the python program it uses the 2.4.3 version. I have looked into changing the PythonHome variable, but can't get it to work correctly. Is there anything I can do via the command line or inside the program itself to specify which Python version I want to use?","Try specifying the full path to the python executable (i.e. /opt/python27/python) rather than using a bare python command. Alternatively, place /opt/python27/ on your PATH earlier than /usr/local/bin (where the python command is presumably already present, you can check with which python).",1.2,True,2,1394 2011-08-15 16:30:15.863,linked list in python,"there are huge number of data, there are various groups. i want to check whether the new data fits in any group and if it does i want to put that data into that group. If datum doesn't fit to any of the group, i want to create new group. So, i want to use linked list for the purpose or is there any other way to doing so?? P.S. i have way to check the similarity between data and group representative(lets not go that in deatil for now) but i dont know how to add the data to group (each group may be list) or create new one if required. i guess what i needis linked list implementation in python, isn't it?",This sounds like a perfect use for a dictionary.,0.9981778976111988,False,1,1395 2011-08-16 17:42:56.027,Python: Infinite loop and GUI,"I'm trying to write a python program with wxPython GUI. Program must to collect some information in background (infinite loop), but GUI should be active at this time. Like, if I click on the some button, some variable or another information must change, and at the new cycle this variable should be used instead of the old. @@ -15115,11 +15115,11 @@ I appreciate any constructive feedback. Insults, chides, and arrogance will be s 2011-08-19 09:31:25.710,"In Python, how can I get the file system of a given file path","In python, given a directory or file path like /usr/local, I need to get the file system where its available. In some systems it could be / (root) itself and in some others it could be /usr. I tried os.statvfs it doesnt help. Do I have to run the df command with the path name and extract the file system from the output? Is there a better solution? Its for linux/unix platforms only. -Thanks","Use os.stat to obtain device number of the file/directory in question (st_dev field), and then iterate through system mounts (/etc/mtab or /proc/mounts), comparing st_dev of each mount point with this number.",0.4961739557460144,False,2,1401 +Thanks","As df itself opens and parses /etc/mtab, you could either go this way and parse this file as well (an alternative would be /proc/mounts), or you indeed parse the df output.",0.2655860252697744,False,2,1401 2011-08-19 09:31:25.710,"In Python, how can I get the file system of a given file path","In python, given a directory or file path like /usr/local, I need to get the file system where its available. In some systems it could be / (root) itself and in some others it could be /usr. I tried os.statvfs it doesnt help. Do I have to run the df command with the path name and extract the file system from the output? Is there a better solution? Its for linux/unix platforms only. -Thanks","As df itself opens and parses /etc/mtab, you could either go this way and parse this file as well (an alternative would be /proc/mounts), or you indeed parse the df output.",0.2655860252697744,False,2,1401 +Thanks","Use os.stat to obtain device number of the file/directory in question (st_dev field), and then iterate through system mounts (/etc/mtab or /proc/mounts), comparing st_dev of each mount point with this number.",0.4961739557460144,False,2,1401 2011-08-19 14:51:46.213,Should I create pipeline to save files with scrapy?,"I need to save a file (.pdf) but I'm unsure how to do it. I need to save .pdfs and store them in such a way that they are organized in a directories much like they are stored on the site I'm scraping them off. From what I can gather I need to make a pipeline, but from what I understand pipelines save ""Items"" and ""items"" are just basic data like strings/numbers. Is saving files a proper use of pipelines, or should I save file in spider instead?","It's a perfect tool for the job. The way Scrapy works is that you have spiders that transform web pages into structured data(items). Pipelines are postprocessors, but they use same asynchronous infrastructure as spiders so it's perfect for fetching media files. In your case, you'd first extract location of PDFs in spider, fetch them in pipeline and have another pipeline to save items.",0.4961739557460144,False,1,1402 @@ -15157,8 +15157,8 @@ if not value vs if value is [] And so goes the list... The question is, how far do you go with the principle? Where to draw the line, while keeping your code safe? -Should I always use the if value is None style no matter what?","My answer is simple, as it applies to most coding problems: Don't try to write something that just works. Try to express your intent as clearly as possible. If you want to check if a value is false, use if not value. If you want to check for None, write it down. It always depends on the situation and your judgement. -You should not try to find rules which can be applied without thinking. If you find those rules, it's a job for a computer, not for a human! ;-)",0.5164076551851798,False,3,1408 +Should I always use the if value is None style no matter what?","Your use of the is operator is a little problematic. if value is [] will always be false, for example, because no two active lists have the same identity. It works great with None because None is a singleton (all references to None are the same object) but for other comparisons, use ==. +However, if value and if not value are perfectly readable and useful. IMHO there's no need to be more specific, unless you need to treat various types of truthy or falsy values differently, as, for example, distinguishing between 0 and None.",0.3869120172231254,False,3,1408 2011-08-22 19:20:25.057,"Python: if not val, vs if val is None","I've always coded in the style of if not value, however, a few guides have brought to my attention that while this style works, it seems to have 2 potential problems: It's not completely readable; if value is None is surely more understandable. @@ -15171,8 +15171,8 @@ if not value vs if value is [] And so goes the list... The question is, how far do you go with the principle? Where to draw the line, while keeping your code safe? -Should I always use the if value is None style no matter what?","Your use of the is operator is a little problematic. if value is [] will always be false, for example, because no two active lists have the same identity. It works great with None because None is a singleton (all references to None are the same object) but for other comparisons, use ==. -However, if value and if not value are perfectly readable and useful. IMHO there's no need to be more specific, unless you need to treat various types of truthy or falsy values differently, as, for example, distinguishing between 0 and None.",0.3869120172231254,False,3,1408 +Should I always use the if value is None style no matter what?","No. If you want to run code when the value is false but isn't None, this would fail horribly. +Use is None if you're checking for identity with the None object. Use not value if you just want the value to be False.",0.9999975190129178,False,3,1408 2011-08-22 19:20:25.057,"Python: if not val, vs if val is None","I've always coded in the style of if not value, however, a few guides have brought to my attention that while this style works, it seems to have 2 potential problems: It's not completely readable; if value is None is surely more understandable. @@ -15185,8 +15185,8 @@ if not value vs if value is [] And so goes the list... The question is, how far do you go with the principle? Where to draw the line, while keeping your code safe? -Should I always use the if value is None style no matter what?","No. If you want to run code when the value is false but isn't None, this would fail horribly. -Use is None if you're checking for identity with the None object. Use not value if you just want the value to be False.",0.9999975190129178,False,3,1408 +Should I always use the if value is None style no matter what?","My answer is simple, as it applies to most coding problems: Don't try to write something that just works. Try to express your intent as clearly as possible. If you want to check if a value is false, use if not value. If you want to check for None, write it down. It always depends on the situation and your judgement. +You should not try to find rules which can be applied without thinking. If you find those rules, it's a job for a computer, not for a human! ;-)",0.5164076551851798,False,3,1408 2011-08-23 09:10:09.230,How can my HTML file pass JavaScript results back to a Python script that calls it?,"I have a python script and this python script shall call an html-file (i.e. a web page) stored locally on the computer. The html-file does some calculations (jquery,javascript and so on) and should pass the result back to the python script. I don't want to change the setting (python script calls html-file and result is passed back to python-script) so please don't ask why. Could anyone tell me how to solve this? How can I pass the result from html-file to the calling python function? That troubles me since 2 weeks. @@ -15275,8 +15275,15 @@ abort: couldn't find mercurial libraries in /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC - /Library/Python/2.7/site-packages] (check your install and PYTHONPATH)","Nobody answered me, but I figured out the answer. Maybe it will help someone. -I 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.",0.5457054096481145,False,2,1420 + /Library/Python/2.7/site-packages] (check your install and PYTHONPATH)","I had two installation of mercurial in mac. +One was installed directly and another using macport. +Removing the direct installation solved the problem. + +Remove the direct installation using +easy_install -m mercurial +Update ""Mercurial Executable"" path to ""/opt/local/bin/hg"" +Eclipse->Preference->Team->Mercurial-> +Restart eclipse",0.0,False,2,1420 2011-08-31 18:12:01.933,Mercurial plugin for Eclipse can't find Python--how to fix?,"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: abort: couldn't find mercurial libraries in [...assorted Python directories...]. @@ -15298,32 +15305,14 @@ abort: couldn't find mercurial libraries in /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC - /Library/Python/2.7/site-packages] (check your install and PYTHONPATH)","I had two installation of mercurial in mac. -One was installed directly and another using macport. -Removing the direct installation solved the problem. - -Remove the direct installation using -easy_install -m mercurial -Update ""Mercurial Executable"" path to ""/opt/local/bin/hg"" -Eclipse->Preference->Team->Mercurial-> -Restart eclipse",0.0,False,2,1420 + /Library/Python/2.7/site-packages] (check your install and PYTHONPATH)","Nobody answered me, but I figured out the answer. Maybe it will help someone. +I 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.",0.5457054096481145,False,2,1420 2011-09-01 09:26:41.493,eclipse+pydev how to rename module?,"I'm using eclipse + pydev. I want to refactor and change the name of my module. I clicked on my module in the package explorer, but no refactoring (other than 'rename') in the context menu. Similarly, the refactoring on the top navigation menu is greyed out. So how do i change my module name and have it reflected across my project.?",Did you try rename? it seems to work in other language plugins.(make sure to right click on the module),0.2012947653214861,False,2,1421 2011-09-01 09:26:41.493,eclipse+pydev how to rename module?,"I'm using eclipse + pydev. I want to refactor and change the name of my module. I clicked on my module in the package explorer, but no refactoring (other than 'rename') in the context menu. Similarly, the refactoring on the top navigation menu is greyed out. So how do i change my module name and have it reflected across my project.?","This feature is still not properly integrated in the pydev package explorer, so, for now, you have to find a place that uses the module you want in the code and rename that reference in the editor (you don't need to report that as a bug as that's already known and should be fixed soon).",1.2,True,2,1421 2011-09-02 06:05:00.727,Should I use complex SQL queries or process results in the application?,"I am dealing with an application with huge SQL queries. They are so complex that when I finish understanding one I have already forgotten how it all started. I was wondering if it will be a good practice to pull more data from database and make the final query in my code, let's say, with Python. Am I nuts? Would it be that bad for performance? -Note, results are huge too, I am talking about an ERP in production developed by other people.","Let the DB figure out how best to retrieve the information that you want, else you'll have to duplicate the functionality of the RDBMS in your code, and that will be way more complex than your SQL queries. -Plus, you'll waste time transferring all that unneeded information from the DB to your app, so that you can filter and process it in code. -All this is true because you say you're dealing with large data.",0.5164076551851798,False,3,1422 -2011-09-02 06:05:00.727,Should I use complex SQL queries or process results in the application?,"I am dealing with an application with huge SQL queries. They are so complex that when I finish understanding one I have already forgotten how it all started. -I was wondering if it will be a good practice to pull more data from database and make the final query in my code, let's say, with Python. Am I nuts? Would it be that bad for performance? -Note, results are huge too, I am talking about an ERP in production developed by other people.","I would have the business logic in the application, as much as possible. Complex business logic in queries are difficult to maintain. (when I finish understanding one I have already forgotten how it all started)Complex logic in stored procedures are ok. But with a typical python application, you would want your business logic to be in python. -Now, the database is way better in handling data than your application code. So if your logic involves huge amount of data, you may get better performance with the logic in the database. But this will be for complex reports, bookkeeping operations and such, that operate on a large volume of data. You may want to use stored procedures, or systems that specialize in such operations (a data warehouse for reports) for these types of operations. -Normal OLTP operations do not involve much of data. The database may be huge, but the data required for a typical transaction will be (typically) a very small part of it. Querying this in a large database may cause performance issues, but you can optimize this in several ways (indexes, full text searches, redundancy, summary tables... depends on your actual problem). -Every rule has exceptions, but as a general guideline, try to have your business logic in your application code. Stored procedures for complex logic. A separate data warehouse or a set of procedures for reporting.",1.2,True,3,1422 -2011-09-02 06:05:00.727,Should I use complex SQL queries or process results in the application?,"I am dealing with an application with huge SQL queries. They are so complex that when I finish understanding one I have already forgotten how it all started. -I was wondering if it will be a good practice to pull more data from database and make the final query in my code, let's say, with Python. Am I nuts? Would it be that bad for performance? Note, results are huge too, I am talking about an ERP in production developed by other people.","@Nivas is generally correct. These are pretty common patterns @@ -15333,6 +15322,17 @@ lack of smaller functions. Could the massive query be broken down into smaller So, in general, getting data out of the database - thats down to the database. But if a SQL query is too long its going to be hard for the RDBMS to optimise, and it probably means the query is spanning data, business logic and even presentation in one go. I would suggest a saner approach is usually to seperate out the ""get me the data"" portions into stored procedures or other controllable queries that populate staging tables. Then the business logic can be written into a scripting language sitting above and controlling the stored procedures. And presentation is left elsewhere. In essence solutions like cognos try to do this anyway. But if you are looking at an ERP in production, the constraints and the solutions above probably already exist - are you talking to the right people?",0.0814518047658113,False,3,1422 +2011-09-02 06:05:00.727,Should I use complex SQL queries or process results in the application?,"I am dealing with an application with huge SQL queries. They are so complex that when I finish understanding one I have already forgotten how it all started. +I was wondering if it will be a good practice to pull more data from database and make the final query in my code, let's say, with Python. Am I nuts? Would it be that bad for performance? +Note, results are huge too, I am talking about an ERP in production developed by other people.","I would have the business logic in the application, as much as possible. Complex business logic in queries are difficult to maintain. (when I finish understanding one I have already forgotten how it all started)Complex logic in stored procedures are ok. But with a typical python application, you would want your business logic to be in python. +Now, the database is way better in handling data than your application code. So if your logic involves huge amount of data, you may get better performance with the logic in the database. But this will be for complex reports, bookkeeping operations and such, that operate on a large volume of data. You may want to use stored procedures, or systems that specialize in such operations (a data warehouse for reports) for these types of operations. +Normal OLTP operations do not involve much of data. The database may be huge, but the data required for a typical transaction will be (typically) a very small part of it. Querying this in a large database may cause performance issues, but you can optimize this in several ways (indexes, full text searches, redundancy, summary tables... depends on your actual problem). +Every rule has exceptions, but as a general guideline, try to have your business logic in your application code. Stored procedures for complex logic. A separate data warehouse or a set of procedures for reporting.",1.2,True,3,1422 +2011-09-02 06:05:00.727,Should I use complex SQL queries or process results in the application?,"I am dealing with an application with huge SQL queries. They are so complex that when I finish understanding one I have already forgotten how it all started. +I was wondering if it will be a good practice to pull more data from database and make the final query in my code, let's say, with Python. Am I nuts? Would it be that bad for performance? +Note, results are huge too, I am talking about an ERP in production developed by other people.","Let the DB figure out how best to retrieve the information that you want, else you'll have to duplicate the functionality of the RDBMS in your code, and that will be way more complex than your SQL queries. +Plus, you'll waste time transferring all that unneeded information from the DB to your app, so that you can filter and process it in code. +All this is true because you say you're dealing with large data.",0.5164076551851798,False,3,1422 2011-09-02 14:43:32.933,I have an Oracle Stack trace file Python cx_Oracle,"My python application is dying, this oracle trace file is being generated. I am using cx_Oracle, how do I go about using this trace file to resolve this crash? ora_18225_139690296567552.trc kpedbg_dmp_stack()+360<-kpeDbgCrash()+192<-kpureq2()+3194<-OCIStmtPrepare2()+157<-Cursor_InternalPrepare()+298<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010",Do you have an Oracle support contract? If I would file an SR and upload the trace to Oracle and have them tell you what it is complaining about. Those code calls are deep in their codebase from the looks of it.,1.2,True,1,1423 @@ -15347,6 +15347,7 @@ Usually Python globals only contain Setting variables set during the process initialization Cached data (session/user neutral)",0.0,False,1,1424 +2011-09-04 02:02:59.813,Python/Pygame transitioning from one file to another,"Sorry if this question is incredibly easy to answer, or I sound like an idiot. I'm wondering how I would execute a script in one file, pygame event loop, blits, etc, then switch to another file, SelectWorld.py, which has it's own event loop, and blits, and etc. If I just call it's main function, does it create any slowdown because I still have the original file open, or am I fine just doing that? SelectWorld.transition() sort of thing. Thanks in advance.","Turns out the answer to this was painfully simple, and I asked this back when I was just learning Python. There is no speed downgrade from just calling a function from another file and letting it do all the work. Thanks for all the answers, guys.",1.2,True,2,1425 2011-09-04 02:02:59.813,Python/Pygame transitioning from one file to another,"Sorry if this question is incredibly easy to answer, or I sound like an idiot. I'm wondering how I would execute a script in one file, pygame event loop, blits, etc, then switch to another file, SelectWorld.py, which has it's own event loop, and blits, and etc. If I just call it's main function, does it create any slowdown because I still have the original file open, or am I fine just doing that? SelectWorld.transition() sort of thing. Thanks in advance.","Here, what is wanted is to be able to share the variables between two different applications: 2 different scripts with event loops, blits, etc. So by definition, they should be on different process (if they must be running at the same time). There is two major ways of doing this: 1 - Client-Server Architecture (like a Game server would be) (the server and client can both run on the same machine) @@ -15357,7 +15358,6 @@ You have those alternatives: 2 - You can use Eclipse (with pyDev): Very good debugger (line by line) 3 - Unittest, Mock: Is something you should start to use, because it is useful, because you can easily see when you break some old code (with unittest) and/or testing new code... I hope it helps you :)",0.1352210990936997,False,2,1425 -2011-09-04 02:02:59.813,Python/Pygame transitioning from one file to another,"Sorry if this question is incredibly easy to answer, or I sound like an idiot. I'm wondering how I would execute a script in one file, pygame event loop, blits, etc, then switch to another file, SelectWorld.py, which has it's own event loop, and blits, and etc. If I just call it's main function, does it create any slowdown because I still have the original file open, or am I fine just doing that? SelectWorld.transition() sort of thing. Thanks in advance.","Turns out the answer to this was painfully simple, and I asked this back when I was just learning Python. There is no speed downgrade from just calling a function from another file and letting it do all the work. Thanks for all the answers, guys.",1.2,True,2,1425 2011-09-05 02:02:03.117,How do I get more locations?,"I am trying to get some locations in New York using FourSquare API using the following API call: https://api.foursquare.com/v2/venues/search?ll=40.7,-74&limit=50 @@ -15407,14 +15407,14 @@ I tried select count(*) from table, but that seems to access each row and is sup I also tried select max(rowid) from table. That's fast, but not really safe -- ids can be re-used, table can be empty etc. It's more of a hack. Any ideas on how to find the table size quickly and cleanly? -Using Python 2.5's sqlite3 version 2.3.2, which uses Sqlite engine 3.4.0.","Do you have any kind of index on a not-null column (for example a primary key)? If yes, the index can be scanned (which hopefully does not take that long). If not, a full table scan is the only way to count all rows.",0.1352210990936997,False,3,1430 +Using Python 2.5's sqlite3 version 2.3.2, which uses Sqlite engine 3.4.0.","Other way to get the rows number of a table is by using a trigger that stores the actual number of rows in other table (each insert operation will increment a counter). +In this way inserting a new record will be a little slower, but you can immediately get the number of rows.",0.1352210990936997,False,3,1430 2011-09-08 09:44:35.597,Fast number of rows in Sqlite,"I have a single table in an Sqlite DB, with many rows. I need to get the number of rows (total count of items in the table). I tried select count(*) from table, but that seems to access each row and is super slow. I also tried select max(rowid) from table. That's fast, but not really safe -- ids can be re-used, table can be empty etc. It's more of a hack. Any ideas on how to find the table size quickly and cleanly? -Using Python 2.5's sqlite3 version 2.3.2, which uses Sqlite engine 3.4.0.","Other way to get the rows number of a table is by using a trigger that stores the actual number of rows in other table (each insert operation will increment a counter). -In this way inserting a new record will be a little slower, but you can immediately get the number of rows.",0.1352210990936997,False,3,1430 +Using Python 2.5's sqlite3 version 2.3.2, which uses Sqlite engine 3.4.0.","Do you have any kind of index on a not-null column (for example a primary key)? If yes, the index can be scanned (which hopefully does not take that long). If not, a full table scan is the only way to count all rows.",0.1352210990936997,False,3,1430 2011-09-08 09:44:35.597,Fast number of rows in Sqlite,"I have a single table in an Sqlite DB, with many rows. I need to get the number of rows (total count of items in the table). I tried select count(*) from table, but that seems to access each row and is super slow. I also tried select max(rowid) from table. That's fast, but not really safe -- ids can be re-used, table can be empty etc. It's more of a hack. @@ -15496,14 +15496,12 @@ Does anyone know how to go about solving this sort of problem? I python simply n Many thanks for your attention. I look forward to seeing what the bright minds of stackoverflow can throw my way. Additional Details The sort of machine this problem is run on usually has 20+ cores and ~70G of RAM. The problem can be parallelised (à la MapReduce) in that separate vectors for one entity can be built from segments of the corpus and then added to obtain the vector that would have been built from the whole corpus. -Part of the question involves determining a limit on how much can be built in memory before disk-writes need to occur. Does python offer any mechanism to determine how much RAM is available?","From another comment I infer that your corpus fits into the memory, and you have some cores to throw at the problem, so I would try this: - -Find a method to have your corpus in memory. This might be a sort of ram disk with file system, or a database. No idea, which one is best for you. -Have a smallish shell script monitor ram usage, and spawn every second another process of the following, as long as there is x memory left (or, if you want to make things a bit more complex, y I/O bandwith to disk): +Part of the question involves determining a limit on how much can be built in memory before disk-writes need to occur. Does python offer any mechanism to determine how much RAM is available?","Two ideas: -iterate through the corpus and build and write some vectors +Use numpy arrays to represent vectors. They are much more memory-efficient, at the cost that they will force elements of the vector to be of the same type (all ints or all doubles...). +Do multiple passes, each with a different set of vectors. That is, choose first 1M vectors and do only the calculations involving them (you said they are independent, so I assume this is viable). Then another pass over all the data with second 1M vectors. -in the end you can collect and combine all vectors, if needed (this would be the reduce part)",0.0,False,4,1437 +It seems you're on the edge of what you can do with your hardware. It would help if you could describe what hardware (mostly, RAM) is available to you for this task. If there are 100k vectors, each of them with 1M ints, this gives ~370GB. If multiple passes method is viable and you've got a machine with 16GB RAM, then it is about ~25 passes -- should be easy to parallelize if you've got a cluster.",0.0740755660660223,False,4,1437 2011-09-11 21:08:11.620,Minimising reading from and writing to disk in Python for a memory-heavy operation,"Background I am working on a fairly computationally intensive project for a computational linguistics project, but the problem I have is quite general and hence I expect that a solution would be interesting to others as well. Requirements @@ -15542,10 +15540,14 @@ Does anyone know how to go about solving this sort of problem? I python simply n Many thanks for your attention. I look forward to seeing what the bright minds of stackoverflow can throw my way. Additional Details The sort of machine this problem is run on usually has 20+ cores and ~70G of RAM. The problem can be parallelised (à la MapReduce) in that separate vectors for one entity can be built from segments of the corpus and then added to obtain the vector that would have been built from the whole corpus. -Part of the question involves determining a limit on how much can be built in memory before disk-writes need to occur. Does python offer any mechanism to determine how much RAM is available?","Split the corpus evenly in size between parallel jobs (one per core) - process in parallel, ignoring any incomplete line (or if you cannot tell if it is incomplete, ignore the first and last line of that each job processes). -That's the map part. -Use one job to merge the 20+ sets of vectors from each of the earlier jobs - That's the reduce step. -You stand to loose information from 2*N lines where N is the number of parallel processes, but you gain by not adding complicated logic to try and capture these lines for processing.",0.0,False,4,1437 +Part of the question involves determining a limit on how much can be built in memory before disk-writes need to occur. Does python offer any mechanism to determine how much RAM is available?","From another comment I infer that your corpus fits into the memory, and you have some cores to throw at the problem, so I would try this: + +Find a method to have your corpus in memory. This might be a sort of ram disk with file system, or a database. No idea, which one is best for you. +Have a smallish shell script monitor ram usage, and spawn every second another process of the following, as long as there is x memory left (or, if you want to make things a bit more complex, y I/O bandwith to disk): + +iterate through the corpus and build and write some vectors + +in the end you can collect and combine all vectors, if needed (this would be the reduce part)",0.0,False,4,1437 2011-09-11 21:08:11.620,Minimising reading from and writing to disk in Python for a memory-heavy operation,"Background I am working on a fairly computationally intensive project for a computational linguistics project, but the problem I have is quite general and hence I expect that a solution would be interesting to others as well. Requirements @@ -15584,12 +15586,10 @@ Does anyone know how to go about solving this sort of problem? I python simply n Many thanks for your attention. I look forward to seeing what the bright minds of stackoverflow can throw my way. Additional Details The sort of machine this problem is run on usually has 20+ cores and ~70G of RAM. The problem can be parallelised (à la MapReduce) in that separate vectors for one entity can be built from segments of the corpus and then added to obtain the vector that would have been built from the whole corpus. -Part of the question involves determining a limit on how much can be built in memory before disk-writes need to occur. Does python offer any mechanism to determine how much RAM is available?","Two ideas: - -Use numpy arrays to represent vectors. They are much more memory-efficient, at the cost that they will force elements of the vector to be of the same type (all ints or all doubles...). -Do multiple passes, each with a different set of vectors. That is, choose first 1M vectors and do only the calculations involving them (you said they are independent, so I assume this is viable). Then another pass over all the data with second 1M vectors. - -It seems you're on the edge of what you can do with your hardware. It would help if you could describe what hardware (mostly, RAM) is available to you for this task. If there are 100k vectors, each of them with 1M ints, this gives ~370GB. If multiple passes method is viable and you've got a machine with 16GB RAM, then it is about ~25 passes -- should be easy to parallelize if you've got a cluster.",0.0740755660660223,False,4,1437 +Part of the question involves determining a limit on how much can be built in memory before disk-writes need to occur. Does python offer any mechanism to determine how much RAM is available?","Split the corpus evenly in size between parallel jobs (one per core) - process in parallel, ignoring any incomplete line (or if you cannot tell if it is incomplete, ignore the first and last line of that each job processes). +That's the map part. +Use one job to merge the 20+ sets of vectors from each of the earlier jobs - That's the reduce step. +You stand to loose information from 2*N lines where N is the number of parallel processes, but you gain by not adding complicated logic to try and capture these lines for processing.",0.0,False,4,1437 2011-09-11 21:08:11.620,Minimising reading from and writing to disk in Python for a memory-heavy operation,"Background I am working on a fairly computationally intensive project for a computational linguistics project, but the problem I have is quite general and hence I expect that a solution would be interesting to others as well. Requirements @@ -15636,8 +15636,8 @@ I don't see the need to otherwise retrieve the classname, since the log message 2011-09-12 14:25:00.273,WxWidget/WxPython; 3 column resizable layout,"I'm trying to figure out how i can have a 3 column layout where the (smaller) left and right columns are resizable with a draggable separator on each side of the center/main area. I've tried using splitwindow but that seems to only split in two parts. Hope someone can give me pointers on how it can be done.","I susggest that you create three panels, side by side. When one of the panels is resized by the user, you will have to adjust the size of the other panels to compensate - so that there are no gaps or overlaps. You can do this by handling the resize event, probably in the parent windows of the three panels. Another way, which requires you to write less code, would be to use wxGrid with one row and three columns and zero width labels for columns and rows. You will lose the flexibility of panels, but wxGrid will look after the resizing of the column widths for you.",0.0,False,1,1439 -2011-09-12 15:08:22.067,Python - how to get a list of all global names I have ever defined?,"I work in a python shell and some weeks ago I have defined a variable which refers to a very important list. The shell stays always open, but I have forgotten this name. How to get a list of all global names I have ever defined?","You can examine globals(), which shows all the module-level variables, or locals(), which is the local scope. In the prompt, these are the same. Also, vars() shows all the names available to you, no matter where you are.",0.2012947653214861,False,2,1440 2011-09-12 15:08:22.067,Python - how to get a list of all global names I have ever defined?,"I work in a python shell and some weeks ago I have defined a variable which refers to a very important list. The shell stays always open, but I have forgotten this name. How to get a list of all global names I have ever defined?",Don't you have readline enabled? You can look through your interpreter history to find what you want. I think it's easier than digging through globals() or dir().,0.2012947653214861,False,2,1440 +2011-09-12 15:08:22.067,Python - how to get a list of all global names I have ever defined?,"I work in a python shell and some weeks ago I have defined a variable which refers to a very important list. The shell stays always open, but I have forgotten this name. How to get a list of all global names I have ever defined?","You can examine globals(), which shows all the module-level variables, or locals(), which is the local scope. In the prompt, these are the same. Also, vars() shows all the names available to you, no matter where you are.",0.2012947653214861,False,2,1440 2011-09-12 19:05:21.490,Remote procedure call in C#,"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. That 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. I 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. @@ -15675,7 +15675,7 @@ EDIT: I'm asking this because I've actually developed my own Cron implementation in Python. The only problem is that I can't decide how my code should wait for next occurrence. One of the differences between my implementation and original Cron is support for seconds. So, simply sleeping for minimum possible interval (1 second in my case) is too inefficient. I realize now that this question could perhaps be changed to ""how does Cron do this?"" i.e. ""how does Cron check if any date has passed? Does it run constantly or is a process run each minute?"". I believe the latter is the case, which, again, is inefficient if interval is 1 second. Another difference is that my code reads crontab once and calculates the exact date (datetime object) of next occurrence from the pattern. While Cron, I assume, simply checks each minute if any pattern from crontab matches current time. -I'll stick to the ""hybrid"" way if there's no other way to do this.","If this is something that might be six months out like you said, a chron job is probably more suitable than keeping a python program running the whole time.",0.1352210990936997,False,3,1445 +I'll stick to the ""hybrid"" way if there's no other way to do this.","I use the gobject main loop, but any library with an event loop should have this ability.",0.0,False,3,1445 2011-09-14 07:51:35.203,Calling a function at datetime in Python,"What is a good way to call a function at datetime in Python? There 3 ways that I know of: @@ -15691,7 +15691,7 @@ EDIT: I'm asking this because I've actually developed my own Cron implementation in Python. The only problem is that I can't decide how my code should wait for next occurrence. One of the differences between my implementation and original Cron is support for seconds. So, simply sleeping for minimum possible interval (1 second in my case) is too inefficient. I realize now that this question could perhaps be changed to ""how does Cron do this?"" i.e. ""how does Cron check if any date has passed? Does it run constantly or is a process run each minute?"". I believe the latter is the case, which, again, is inefficient if interval is 1 second. Another difference is that my code reads crontab once and calculates the exact date (datetime object) of next occurrence from the pattern. While Cron, I assume, simply checks each minute if any pattern from crontab matches current time. -I'll stick to the ""hybrid"" way if there's no other way to do this.","I use the gobject main loop, but any library with an event loop should have this ability.",0.0,False,3,1445 +I'll stick to the ""hybrid"" way if there's no other way to do this.","If this is something that might be six months out like you said, a chron job is probably more suitable than keeping a python program running the whole time.",0.1352210990936997,False,3,1445 2011-09-14 07:51:35.203,Calling a function at datetime in Python,"What is a good way to call a function at datetime in Python? There 3 ways that I know of: @@ -15753,7 +15753,9 @@ See Configured Parameters. During the execution of a streaming job, But I still cant understand how to make use of this inside my mapper. Any help is highly appreciated. -Thanks",The new ENV_VARIABLE for Hadoop 2.x is MAPREDUCE_MAP_INPUT_FILE,0.0,False,2,1450 +Thanks","By parsing the mapreduce_map_input_file(new) or map_input_file(deprecated) environment variable, you will get the map input file name. +Notice: +The two environment variables are case-sensitive, all letters are lower-case.",0.6730655149877884,False,2,1450 2011-09-16 19:59:17.773,Get input file name in streaming hadoop program,"I am able to find the name if the input file in a mapper class using FileSplit when writing the program in Java. Is there a corresponding way to do this when I write a program in Python (using streaming?) I found the following in the hadoop streaming document on apache: @@ -15766,28 +15768,26 @@ See Configured Parameters. During the execution of a streaming job, But I still cant understand how to make use of this inside my mapper. Any help is highly appreciated. -Thanks","By parsing the mapreduce_map_input_file(new) or map_input_file(deprecated) environment variable, you will get the map input file name. -Notice: -The two environment variables are case-sensitive, all letters are lower-case.",0.6730655149877884,False,2,1450 +Thanks",The new ENV_VARIABLE for Hadoop 2.x is MAPREDUCE_MAP_INPUT_FILE,0.0,False,2,1450 2011-09-19 17:31:47.497,Netbeans 7 not starting up after python plugin installation,"I went to tools, plugins. Then chose to install the three python items that show up. After installation. I choose the restart netbeans option. But instead of restarting, netbeans just closed. And now it is not opening. Any ideas how to fix this? I normally develop Java on my netbeans 7 install. I am using a mac osx -I see there are no takers, so let me ask this: Is there a way to revert to before the new plugin install?","I know I'm not answering your question directly, but I too was considering installing the Python plugin in Netbeans 7 but saw that it was still in Beta. -I use WingIDE from wingware for Python development. I'm a Python newbie but I'm told by the pros that Wing is the best IDE for Python. The ""101"" version is free and works very well. The licensed versions include more options such as version control integration and Django features.",-0.0679224682270276,False,5,1451 +I see there are no takers, so let me ask this: Is there a way to revert to before the new plugin install?","I have the same problem afther installing the python plguin. To solve this problem i deleted the file: org-openide-awt.jar from C:\Users\MYUSERNAME.netbeans\7.0\modules +Regards! +Martín. +PD: I'm using Netbeans 7.0.1 anda Windows 7 64bit.",0.0,False,5,1451 2011-09-19 17:31:47.497,Netbeans 7 not starting up after python plugin installation,"I went to tools, plugins. Then chose to install the three python items that show up. After installation. I choose the restart netbeans option. But instead of restarting, netbeans just closed. And now it is not opening. Any ideas how to fix this? I normally develop Java on my netbeans 7 install. I am using a mac osx -I see there are no takers, so let me ask this: Is there a way to revert to before the new plugin install?","I had the same issue. Netbeans would die before opening at all. I could not fix it, and had to revert back to 6.9.1.",0.0679224682270276,False,5,1451 +I see there are no takers, so let me ask this: Is there a way to revert to before the new plugin install?","I was having a problem with Netbeans 7 not starting. Netbeans had first errored out with no error message. Then it wouldn't start or give me an error. I looked in the .netbeans directory in my user directory, and found and attempted to delete the 'lock' file in that directory. When I first tried to delete it, it said it was in use. So with task manager, I had to go to processes tab and find netbeans. I killed that task, then was able to delete 'lock'. Then netbeans started.",0.0679224682270276,False,5,1451 2011-09-19 17:31:47.497,Netbeans 7 not starting up after python plugin installation,"I went to tools, plugins. Then chose to install the three python items that show up. After installation. I choose the restart netbeans option. But instead of restarting, netbeans just closed. And now it is not opening. Any ideas how to fix this? I normally develop Java on my netbeans 7 install. I am using a mac osx I see there are no takers, so let me ask this: Is there a way to revert to before the new plugin install?","I had the same problem, but with Windows 7. I deleted the .netbeans directory located in my home folder. That fixed my problem, hope it fixes yours.",0.0679224682270276,False,5,1451 2011-09-19 17:31:47.497,Netbeans 7 not starting up after python plugin installation,"I went to tools, plugins. Then chose to install the three python items that show up. After installation. I choose the restart netbeans option. But instead of restarting, netbeans just closed. And now it is not opening. Any ideas how to fix this? I normally develop Java on my netbeans 7 install. I am using a mac osx -I see there are no takers, so let me ask this: Is there a way to revert to before the new plugin install?","I was having a problem with Netbeans 7 not starting. Netbeans had first errored out with no error message. Then it wouldn't start or give me an error. I looked in the .netbeans directory in my user directory, and found and attempted to delete the 'lock' file in that directory. When I first tried to delete it, it said it was in use. So with task manager, I had to go to processes tab and find netbeans. I killed that task, then was able to delete 'lock'. Then netbeans started.",0.0679224682270276,False,5,1451 +I see there are no takers, so let me ask this: Is there a way to revert to before the new plugin install?","I had the same issue. Netbeans would die before opening at all. I could not fix it, and had to revert back to 6.9.1.",0.0679224682270276,False,5,1451 2011-09-19 17:31:47.497,Netbeans 7 not starting up after python plugin installation,"I went to tools, plugins. Then chose to install the three python items that show up. After installation. I choose the restart netbeans option. But instead of restarting, netbeans just closed. And now it is not opening. Any ideas how to fix this? I normally develop Java on my netbeans 7 install. I am using a mac osx -I see there are no takers, so let me ask this: Is there a way to revert to before the new plugin install?","I have the same problem afther installing the python plguin. To solve this problem i deleted the file: org-openide-awt.jar from C:\Users\MYUSERNAME.netbeans\7.0\modules -Regards! -Martín. -PD: I'm using Netbeans 7.0.1 anda Windows 7 64bit.",0.0,False,5,1451 +I see there are no takers, so let me ask this: Is there a way to revert to before the new plugin install?","I know I'm not answering your question directly, but I too was considering installing the Python plugin in Netbeans 7 but saw that it was still in Beta. +I use WingIDE from wingware for Python development. I'm a Python newbie but I'm told by the pros that Wing is the best IDE for Python. The ""101"" version is free and works very well. The licensed versions include more options such as version control integration and Django features.",-0.0679224682270276,False,5,1451 2011-09-20 08:53:11.127,Python Apps and Python Interpreter?,"I'm wondering how many python interpreter would be executed for distinct python apps? Say I have 6 different python apps up and running, so does that mean there are 6 different python interpreters are running for each of them?","Yes, each python script is launched by a separate python interpreter process. (unless your applications are in fact a single application multi threaded of course ;) )",0.1352210990936997,False,3,1452 2011-09-20 08:53:11.127,Python Apps and Python Interpreter?,"I'm wondering how many python interpreter would be executed for distinct python apps? @@ -15818,7 +15818,7 @@ I went into terminal and went to the django-registration folder and ran python setup.py install. It did a bunch of things then spit out the following: error: could not create '/usr/local/lib/python2.7/dist-packages/registration': Permission denied -The Install file says I can just put it into the same folder as my project, so do I even need to install this? If so, how do I properly install it?",Do you need more permission? As in you need to do: sudo python setup.py install,0.1016881243684853,False,2,1454 +The Install file says I can just put it into the same folder as my project, so do I even need to install this? If so, how do I properly install it?",i'd also add that there is a set of default templates somewhere that make the usage of registration vastly easier. think they were on ubernostrums google code last time i needed them.,0.1016881243684853,False,2,1454 2011-09-20 20:41:52.210,How do I properly install django registration on localhost?,"I have a directory for a django project on my localhost /MyDjangoList/ In this folder I have a django application called PK @@ -15827,7 +15827,7 @@ I went into terminal and went to the django-registration folder and ran python setup.py install. It did a bunch of things then spit out the following: error: could not create '/usr/local/lib/python2.7/dist-packages/registration': Permission denied -The Install file says I can just put it into the same folder as my project, so do I even need to install this? If so, how do I properly install it?",i'd also add that there is a set of default templates somewhere that make the usage of registration vastly easier. think they were on ubernostrums google code last time i needed them.,0.1016881243684853,False,2,1454 +The Install file says I can just put it into the same folder as my project, so do I even need to install this? If so, how do I properly install it?",Do you need more permission? As in you need to do: sudo python setup.py install,0.1016881243684853,False,2,1454 2011-09-20 21:06:15.253,"Tkinter is freezing while the loop is processing, how can i prevent it?","I am making some programs which includes while loops(to illustrate some number calculatings) and when I use Tkinter for GUI, the program windows is freezing until the loop finished. I want to add a stop button and I want the windows not to freeze. How can I do these two things? Thank you","You'll have to use separate threads or processes. Tkinter uses a single thread to process display updates, and the same thread is used to do event callbacks. If your event handler blocks then no Tkinter code will execute until it completes. If you have the Tkinter thread (the one that calls Tk.mainloop) and another thread for the rest of your application, then the event handlers running within the Tkinter thread can simply pass messages (possibly using Queue.Queue) to your application event handler.",1.2,True,1,1455 @@ -15932,12 +15932,12 @@ abort: pretxncommit.jira hook exited with status 1","class Check_jira ends on li Just put the if block outside after the whole class definition.",1.2,True,1,1457 2011-09-23 11:36:48.647,Embed python/dsl for scripting in an PHP web application,"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. I'm seeking advise on how to approach this development task? -Update: 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).","You could do it without Python, by ie. parsing the user input for pre-defined ""tags"" and returning the result.",0.0,False,2,1458 -2011-09-23 11:36:48.647,Embed python/dsl for scripting in an PHP web application,"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. -I'm seeking advise on how to approach this development task? Update: 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).","How about doing the scripting on the client. That will ensure maximum security and also save server resources. In 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. Oh 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.",0.2012947653214861,False,2,1458 +2011-09-23 11:36:48.647,Embed python/dsl for scripting in an PHP web application,"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. +I'm seeking advise on how to approach this development task? +Update: 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).","You could do it without Python, by ie. parsing the user input for pre-defined ""tags"" and returning the result.",0.0,False,2,1458 2011-09-24 03:08:57.527,"A script im robot with xmpppy of python, how to detect network failure?","I am using xmpppy libary to write a XMPP IM robot. I want to act on disconnects, but I don't know how to detect disconnects. This could happen if your Jabber server crashes or if you have lost your internet connection. I found the callback, RegisterDisconnectHandler(self, DisconnectHandler), but it didn't work for the network failure, it only works when I explicitly call the method ""disconnect"". @@ -15975,12 +15975,12 @@ Actually implementing this in multiprocessing probably means that you'll have a For the project I'm doing that's not enough since I don't want to assume that the device always gets assigned to for example COM7 in Windows. I need to be able to identify the device programatically across the possible platforms (Win, Linux, OSX (which I imagine would be similar to the Linux approach)), using python. Perhaps by, as the title suggests, enumerate USB-devices on the system and somehow get more friendly names for them. Windows and Linux being the most important platforms to support. Any help would be greatly appreciated! EDIT: -Seems like the pyudev-module would be a good fit for Linux-systems. Has anyone had any experience with that?","It will be great if this is possible, but in my experience with commercial equipments using COM ports this is not the case. Most of the times you need to set manually in the software the COM port. This is a mess, specially in windows (at least XP) that tends to change the number of the com ports in certain cases. In some equipment there is an autodiscovery feature in the software that sends a small message to every COM port and waits for the right answer. This of course only works if the instrument implements some kind of identification command. Good luck.",0.0,False,2,1462 +Seems like the pyudev-module would be a good fit for Linux-systems. Has anyone had any experience with that?","Regarding Linux, if all you need is to enumerate devices, you can even skip pyudev dependency for your project, and simply parse the output of /sbin/udevadm info --export-db command (does not require root privileges). It will dump all information about present devices and classes, including USB product IDs for USB devices, which should be more then enough to identify your USB-to-serial adapters. Of course, you can also do this with pyudev.",1.2,True,2,1462 2011-09-26 06:53:54.313,Getting friendly device names in python,"I have an 2-port signal relay connected to my computer via a USB serial interface. Using the pyserial module I can control these relays with ease. However, this is based on the assumption that I know beforehand which COM-port (or /dev-node) the device is assigned to. For the project I'm doing that's not enough since I don't want to assume that the device always gets assigned to for example COM7 in Windows. I need to be able to identify the device programatically across the possible platforms (Win, Linux, OSX (which I imagine would be similar to the Linux approach)), using python. Perhaps by, as the title suggests, enumerate USB-devices on the system and somehow get more friendly names for them. Windows and Linux being the most important platforms to support. Any help would be greatly appreciated! EDIT: -Seems like the pyudev-module would be a good fit for Linux-systems. Has anyone had any experience with that?","Regarding Linux, if all you need is to enumerate devices, you can even skip pyudev dependency for your project, and simply parse the output of /sbin/udevadm info --export-db command (does not require root privileges). It will dump all information about present devices and classes, including USB product IDs for USB devices, which should be more then enough to identify your USB-to-serial adapters. Of course, you can also do this with pyudev.",1.2,True,2,1462 +Seems like the pyudev-module would be a good fit for Linux-systems. Has anyone had any experience with that?","It will be great if this is possible, but in my experience with commercial equipments using COM ports this is not the case. Most of the times you need to set manually in the software the COM port. This is a mess, specially in windows (at least XP) that tends to change the number of the com ports in certain cases. In some equipment there is an autodiscovery feature in the software that sends a small message to every COM port and waits for the right answer. This of course only works if the instrument implements some kind of identification command. Good luck.",0.0,False,2,1462 2011-09-28 10:42:10.123,read() stops after NUL character,"I'm downloading files over HTTPS, I request the files through urllib2.Request and they come back as a socket._fileobject. I'd ideally like to stream this to file to avoid loading it into memory but I'm not sure how to do this. My problem is if I call .read() on the object it only returns all the data up to the first NUL character and doesn't read the whole file. How can I solve this? The NUL character comes down as \x00 if that's any help, not sure what encoding that is","I found out the problem was that I was running the code inside PyScripter and the in-built python interpreter terminates NUL bytes in the output. So there was no problem with my code, if I run it outside PyScripter everything works fine. Now running Wing IDE and never looking back :)",1.2,True,1,1463 @@ -16024,6 +16024,10 @@ Add that environmental variable to Windows.",1.2,True,1,1467 2011-10-01 23:25:55.543,Sync local file with HTTP server location (in Python),"I have an HTTP server which host some large file and have python clients (GUI apps) which download it. I want the clients to download the file only when needed, but have an up-to-date file on each run. I thought each client will download the file on each run using the If-Modified-Since HTTP header with the file time of the existing file, if any. Can someone suggest how to do it in python? +Can someone suggest an alternative, easy, way to achieve my goal?","You can add a header called ETag, (hash of your file, md5sum or sha256 etc ), to compare if two files are different instead of last-modified date",0.1352210990936997,False,2,1468 +2011-10-01 23:25:55.543,Sync local file with HTTP server location (in Python),"I have an HTTP server which host some large file and have python clients (GUI apps) which download it. +I want the clients to download the file only when needed, but have an up-to-date file on each run. +I thought each client will download the file on each run using the If-Modified-Since HTTP header with the file time of the existing file, if any. Can someone suggest how to do it in python? Can someone suggest an alternative, easy, way to achieve my goal?","I'm assuming some things right now, BUT.. One solution would be to have a separate HTTP file on the server (check.php) which creates a hash/checksum of each files you're hosting. If the files differ from the local files, then the client will download the file. This means that if the content of the file on the server changes, the client will notice the change since the checksum will differ. do a MD5 hash of the file contents, put it in a database or something and check against it before downloading anything. @@ -16031,10 +16035,6 @@ Your solution would work to, but it requires the server to actually include the I'd say putting up a database that looks something like: [ID] [File_name] [File_hash] 0001 moo.txt asd124kJKJhj124kjh12j",0.0,False,2,1468 -2011-10-01 23:25:55.543,Sync local file with HTTP server location (in Python),"I have an HTTP server which host some large file and have python clients (GUI apps) which download it. -I want the clients to download the file only when needed, but have an up-to-date file on each run. -I thought each client will download the file on each run using the If-Modified-Since HTTP header with the file time of the existing file, if any. Can someone suggest how to do it in python? -Can someone suggest an alternative, easy, way to achieve my goal?","You can add a header called ETag, (hash of your file, md5sum or sha256 etc ), to compare if two files are different instead of last-modified date",0.1352210990936997,False,2,1468 2011-10-02 00:12:39.143,Removing indent in PYDEV,"I am using pydev for python development. I am facing issue while removing indentation for a block of statement. If I have to add indentation I used to press SHIFT + down arrow key until I reach the end of block of statements which I want to indent and then press the TAB key.This is how i used to add indent for a block of statements in one step. The issue now I am facing is to remove indent in one step for a block of statement.For example I have a for loop and i have a block of statement with in that for loop. Now I dont want to have the for loop any more and want to remove the indent underlying the for loop statement block. At present I am going each line and press backspace to remove that indentation. Is there any easy way to do this for the entire statement block?","I don't know Pydev, but in most editors Shift+Tab will do the trick.",0.9981778976111988,False,2,1469 @@ -16156,7 +16156,7 @@ Change something (from user to exec) in the fstab: however, my fstab file is all change the #! usr/bin/env python line in the script to the actual location of Python: did not work, same error add a PYTHONPATH to the environment variables of windows: same error. -I would really appreciate it if someone could help me out with a suggestion!","This seems to be a late answer, but may be useful for others. I got the same kinda error, when I was trying to run a shell script which used python. Please check \usr\bin for existence of python. If not found, install that to solve the issue. I come to such a conclusion, as the error shows ""bad interpreter"".",0.0509761841073563,False,2,1477 +I would really appreciate it if someone could help me out with a suggestion!","You should write your command as 'python ./example.py ',then fix it in your script.",0.0,False,2,1477 2011-10-10 17:22:03.820,usr/bin/env: bad interpreter Permission Denied --> how to change the fstab,"I'm using cygwin on windows 7 to run a bash script that activates a python script, and I am getting the following error: myscript.script: /cydrive/c/users/mydrive/folder/myscript.py: usr/bin/env: bad interpreter: Permission Denied. I'm a total newbie to programming, so I've looked around a bit, and I think this means Python is mounted on a different directory that I don't have access to. However, based on what I found, I have tried to following things: @@ -16165,7 +16165,7 @@ Change something (from user to exec) in the fstab: however, my fstab file is all change the #! usr/bin/env python line in the script to the actual location of Python: did not work, same error add a PYTHONPATH to the environment variables of windows: same error. -I would really appreciate it if someone could help me out with a suggestion!","You should write your command as 'python ./example.py ',then fix it in your script.",0.0,False,2,1477 +I would really appreciate it if someone could help me out with a suggestion!","This seems to be a late answer, but may be useful for others. I got the same kinda error, when I was trying to run a shell script which used python. Please check \usr\bin for existence of python. If not found, install that to solve the issue. I come to such a conclusion, as the error shows ""bad interpreter"".",0.0509761841073563,False,2,1477 2011-10-11 02:55:05.540,Python Audio over Network Problems,"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. I will post all relevant code and try and explain it the best I can these are the constant/global values @@ -16324,6 +16324,12 @@ After coming to grips with both languages and IDEs, I've gotten stuck on integra a. 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? b. 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. c. Will the calls between modules be significantly harmful for performance? If they will, should I just develop everything in in one language? +Thanks!",Have you considered IronPython? It's trivial to integrate and since it's working directly with .net the integration works very well.,0.3869120172231254,False,2,1488 +2011-10-17 09:48:30.130,Integrating python and c#,"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). +After 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): +a. 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? +b. 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. +c. Will the calls between modules be significantly harmful for performance? If they will, should I just develop everything in in one language? Thanks!","Sincerely, I would say C# is today gives you a lot of goods from Python. To quote Jon Skeet: Do you know what I really like about dynamic languages such as Python, Ruby, and @@ -16336,12 +16342,6 @@ Do you know what I really like about dynamic languages such as Python, Ruby, and but statically typed languages don't have to be clumsy and heavyweight. And you can have dynamic typing too. That's a new project, I would use just C# here.",1.2,True,2,1488 -2011-10-17 09:48:30.130,Integrating python and c#,"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). -After 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): -a. 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? -b. 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. -c. Will the calls between modules be significantly harmful for performance? If they will, should I just develop everything in in one language? -Thanks!",Have you considered IronPython? It's trivial to integrate and since it's working directly with .net the integration works very well.,0.3869120172231254,False,2,1488 2011-10-19 13:24:13.720,KML to string in Python?,"I'd like to download a KML file and print a particular element of it as a string in Python. Could anyone give me an example of how to do this? Thanks.","You can download the KML file in python using urllib. For reading KML, you can use a parser (search for ""kml python parser"").",0.0,False,1,1489 @@ -16364,12 +16364,12 @@ I am wondering how to interpret this. Thanks.","It sounds like you're using Numpy. If so, the shape (38845,) means you have a 1-dimensional array, of size 38845.",0.296905446847765,False,3,1491 2011-10-21 00:24:05.100,How to intepret the shape of the array in Python?,"I am using a package and it is returning me an array. When I print the shape it is (38845,). Just wondering why this ','. I am wondering how to interpret this. -Thanks.","Python has tuples, which are like lists but of fixed size. A two-element tuple is (a, b); a three-element one is (a, b, c). However, (a) is just a in parentheses. To represent a one-element tuple, Python uses a slightly odd syntax of (a,). So there is only one dimension, and you have a bunch of elements in that one dimension.",1.2,True,3,1491 -2011-10-21 00:24:05.100,How to intepret the shape of the array in Python?,"I am using a package and it is returning me an array. When I print the shape it is (38845,). Just wondering why this ','. -I am wondering how to interpret this. Thanks.","Just wondering why this ','. Because (38845) is the same thing as 38845, but a tuple is expected here, not an int (since in general, your array could have multiple dimensions). (38845,) is a 1-tuple.",0.0,False,3,1491 +2011-10-21 00:24:05.100,How to intepret the shape of the array in Python?,"I am using a package and it is returning me an array. When I print the shape it is (38845,). Just wondering why this ','. +I am wondering how to interpret this. +Thanks.","Python has tuples, which are like lists but of fixed size. A two-element tuple is (a, b); a three-element one is (a, b, c). However, (a) is just a in parentheses. To represent a one-element tuple, Python uses a slightly odd syntax of (a,). So there is only one dimension, and you have a bunch of elements in that one dimension.",1.2,True,3,1491 2011-10-21 07:36:05.983,How can I query the nearest record in a given coordinates(latitude and longitude of string type)?,I am using GeoDjango with PostGIS. Then I am into trouble on how to get the nearest record from the given coordinates from my postgres db table.,"I have no experience with GeoDjango, but on PostgreSQL/PostGIS you have the st_distance(..) function. So, you can order your results by st_distance(geom_column, your_coordinates) asc and see what are the nearest rows. If you have plain coordinates (no postgis geometry), you can convert your coordinates to a point with the geometryFromText function. Is that what you were looking for? If not, try to be more explicit.",0.1352210990936997,False,1,1492 @@ -16457,6 +16457,13 @@ At the top of each method you can insert a callback to a routine of your own tha 2011-10-31 22:33:16.290,Boto: how to keep EMR job flow running after completion/failure?,"How can I add steps to a waiting Amazon EMR job flow using boto without the job flow terminating once complete? I've created an interactive job flow on Amazon's Elastic Map Reduce and loaded some tables. When I pass in new steps to the job flow using Boto's emr_conn.add_jobflow_steps(...), the job flow terminates after it finishes or fails. I know I can start a job flow with boto using run_jobflow with the keep_alive parameter -- but I'd like to work with flows that are already running.","If it finishes correctly, it should not terminate with keep_alive=True. That said, it would normally exit on failure, so you want to add terminate_on_failure=""CONTINUE"" to your add_job_steps arguments.",1.2,True,1,1500 +2011-11-01 09:59:10.747,Qt Designer: how to add custom slot and code to a button,"I use Qt4 Designer and I want that when I click on the ""yes"" button, some code will execute. And when I click on the ""no"", some other code will be execute. How can I do it?","Right-click on your widget +Select ""Go to slot..."" +Select a signal and click OK + +Your custom slot declaration and definition for that signal will be added to *.cpp and *.h files. Its name will be generated automatically. +upd: +Sorry, I didn't notice that the question is about Python & QtDesigner itself, I was thinking of the designer mode in QtCreator IDE. However, this still may be useful for someone who is looking for Qt/C++ info, so I leave the answer.",0.9981778976111988,False,2,1501 2011-11-01 09:59:10.747,Qt Designer: how to add custom slot and code to a button,"I use Qt4 Designer and I want that when I click on the ""yes"" button, some code will execute. And when I click on the ""no"", some other code will be execute. How can I do it?","Click on the Edit Signal/Slots tool. Create a connection for your button. For this, select your button in the designer by pressing on it with the left button of the mouse. Move the mouse to some place in the main window to create a connection with the main window (it is like a red line with a earth connection). When you release the mouse button, the Configure Connection dialog appears. @@ -16465,13 +16472,6 @@ Then press edit in the right text control (the receiver). A dialog for the Signa In the slot panel add a new slot (green cross). The text slot1() appears. Double click on it to edit the line and write instead the name of your function doit_when_yes_ispressed(). Accept. Now in the Configure Connection dialog you will see your function in the right text control. Select and Accept. In the designer now you can see the signal and your function in the widget.",1.0,False,2,1501 -2011-11-01 09:59:10.747,Qt Designer: how to add custom slot and code to a button,"I use Qt4 Designer and I want that when I click on the ""yes"" button, some code will execute. And when I click on the ""no"", some other code will be execute. How can I do it?","Right-click on your widget -Select ""Go to slot..."" -Select a signal and click OK - -Your custom slot declaration and definition for that signal will be added to *.cpp and *.h files. Its name will be generated automatically. -upd: -Sorry, I didn't notice that the question is about Python & QtDesigner itself, I was thinking of the designer mode in QtCreator IDE. However, this still may be useful for someone who is looking for Qt/C++ info, so I leave the answer.",0.9981778976111988,False,2,1501 2011-11-02 05:40:45.253,How can I get generators/iterators to evaluate as False when exhausted?,Other empty objects in Python evaluate as False -- how can I get iterators/generators to do so as well?,"Guido doesn't want generators and iterators to behave that way. Objects are true by default. They can be false only if they define __len__ that returns zero or __nonzero__ that returns False (the latter is called __bool__ in Py3.x). You can add one of those methods to a custom iterator, but it doesn't match Guido's intent. He rejected adding __len__ to iterators where the upcoming length is known. That is how we got __length_hint__ instead. @@ -16502,7 +16502,9 @@ Fifth, I run the test runner and see 1 pass and 10 failures. Sixth, I go to step 2. Ideally, instead of seeing tests in terms of passes, failures, and exceptions, I'd like to have a fourth possibility: NotImplemented. -What's the best practice here?","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.",0.0,False,3,1506 +What's the best practice here?","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. +Also, 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. +Having 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.",0.1016881243684853,False,3,1506 2011-11-05 01:28:50.570,TDD practice: Distinguishing between genuine failures and unimplemented features,"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. My general practice for writing tests is as follows: @@ -16527,9 +16529,7 @@ Fifth, I run the test runner and see 1 pass and 10 failures. Sixth, I go to step 2. Ideally, instead of seeing tests in terms of passes, failures, and exceptions, I'd like to have a fourth possibility: NotImplemented. -What's the best practice here?","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. -Also, 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. -Having 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.",0.1016881243684853,False,3,1506 +What's the best practice here?","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.",0.0,False,3,1506 2011-11-07 09:37:55.587,On what side is 'HTTP Error 403: request disallowed by robots.txt' generated?,"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?","The server blocks your activity with such response. Is it your site? If not, follow the rules: @@ -16586,16 +16586,16 @@ There are 4 Objects: MainWindow, centralWidget, menubar, and statusbar. I need to set default layout inside the window, so probably for centralWidget. But I didnt found way how to do it. I can get LayoutWidget with some particular size into centralWidget. -But I want to set layout for the whole centralWidget.","Add some widgets to the central widget first. -Then select the central widget and use the ""Layout in a Grid"", ""Layout Vertically"", etc buttons on the toolbar to add a main layout. -The layouts in the ""Widget Box"" side-bar are used for adding child layouts to a main layout.",0.2012947653214861,False,2,1518 +But I want to set layout for the whole centralWidget.","Right click anywhere within your centralWidget go to the Lay Out sub menu and select the Layout you want. This will be applied automatically to all contents of your centralWidget. +In order to see how it works place inside it 2 or 3 push buttons and try changing the layouts.",1.2,True,2,1518 2011-11-11 14:04:37.737,pyqt designer and layout for central widget,"I started new clear Main Window project, There are 4 Objects: MainWindow, centralWidget, menubar, and statusbar. I need to set default layout inside the window, so probably for centralWidget. But I didnt found way how to do it. I can get LayoutWidget with some particular size into centralWidget. -But I want to set layout for the whole centralWidget.","Right click anywhere within your centralWidget go to the Lay Out sub menu and select the Layout you want. This will be applied automatically to all contents of your centralWidget. -In order to see how it works place inside it 2 or 3 push buttons and try changing the layouts.",1.2,True,2,1518 +But I want to set layout for the whole centralWidget.","Add some widgets to the central widget first. +Then select the central widget and use the ""Layout in a Grid"", ""Layout Vertically"", etc buttons on the toolbar to add a main layout. +The layouts in the ""Widget Box"" side-bar are used for adding child layouts to a main layout.",0.2012947653214861,False,2,1518 2011-11-11 17:23:13.507,How do I confirm a form has been submitted with django?,"I'm submitting a form and instead of redirecting to a success url I would like to just show ""Form has been submitted"" in text on the page when the form has been submitted. Does anyone know how I can do so?","Honestly, this isn't a Django-specific issue. The problem is whether you are doing a normal form submission or using AJAX. The basic idea is to POST to your form submission endpoint using AJAX and the form data, and in the Django view, merely update your models and return either an empty 200 response or some data (in XML, JSON, small HTML, whatever you need). Then the AJAX call can populate a success message div on success, or display a failure message if it gets back a non-200 response.",0.0,False,1,1519 2011-11-11 18:02:47.620,Sending data through the web to a remote program using python,"I have a program that I wrote in python that collects data. I want to be able to store the data on the internet somewhere and allow for another user to access it from another computer somewhere else, anywhere in the world that has an internet connection. My original idea was to use an e-mail client, such as g-mail, to store the data by sending pickled strings to the address. This would allow for anyone to access the address and simply read the newest e-mail to get the data. It worked perfectly, but the program requires a new e-mail to be sent every 5-30 seconds. So the method fell through because of the limit g-mail has on e-mails, among other reasons, such as I was unable to completely delete old e-mails. @@ -16603,16 +16603,16 @@ Now I want to try a different idea, but I do not know very much about network pr I do not know if this is a feasible task in python, but any and all ideas are welcome. Also, if you have an ideas on how to do this a different way, I am all ears, well eyes in this case.",I would suggest taking a look at setting up a simple site in google app engine. It's free and you can use python to do the site. Than it would just be a matter of creating a simple restful service that you could send a POST to with your pickled data and store it in a database. Than just create a simple web front end onto the database.,0.2012947653214861,False,4,1520 2011-11-11 18:02:47.620,Sending data through the web to a remote program using python,"I have a program that I wrote in python that collects data. I want to be able to store the data on the internet somewhere and allow for another user to access it from another computer somewhere else, anywhere in the world that has an internet connection. My original idea was to use an e-mail client, such as g-mail, to store the data by sending pickled strings to the address. This would allow for anyone to access the address and simply read the newest e-mail to get the data. It worked perfectly, but the program requires a new e-mail to be sent every 5-30 seconds. So the method fell through because of the limit g-mail has on e-mails, among other reasons, such as I was unable to completely delete old e-mails. Now I want to try a different idea, but I do not know very much about network programming with python. I want to setup a webpage with essentially nothing on it. The ""master"" program, the program actually collecting the data, will send a pickled string to the webpage. Then any of the ""remote"" programs will be able to read the string. I will also need the master program to delete old strings as it updates the webpage. It would be preferred to be able to store multiple string, so there is no chance of the master updating while the remote is reading. -I do not know if this is a feasible task in python, but any and all ideas are welcome. Also, if you have an ideas on how to do this a different way, I am all ears, well eyes in this case.","Another option in addition to what Casey already provided: -Set up a remote MySQL database somewhere that has user access levels allowing remote connections. Your Python program could then simply access the database and INSERT the data you're trying to store centrally (e.g. through MySQLDb package or pyodbc package). Your users could then either read the data through a client that supports MySQL or you could write a simple front-end in Python or PHP that displays the data from the database.",0.1016881243684853,False,4,1520 +I do not know if this is a feasible task in python, but any and all ideas are welcome. Also, if you have an ideas on how to do this a different way, I am all ears, well eyes in this case.","I suggest you to use a good middle-ware like: Zero-C ICE, Pyro4, Twisted. +Pyro4 using pickle to serialize data.",0.0,False,4,1520 2011-11-11 18:02:47.620,Sending data through the web to a remote program using python,"I have a program that I wrote in python that collects data. I want to be able to store the data on the internet somewhere and allow for another user to access it from another computer somewhere else, anywhere in the world that has an internet connection. My original idea was to use an e-mail client, such as g-mail, to store the data by sending pickled strings to the address. This would allow for anyone to access the address and simply read the newest e-mail to get the data. It worked perfectly, but the program requires a new e-mail to be sent every 5-30 seconds. So the method fell through because of the limit g-mail has on e-mails, among other reasons, such as I was unable to completely delete old e-mails. Now I want to try a different idea, but I do not know very much about network programming with python. I want to setup a webpage with essentially nothing on it. The ""master"" program, the program actually collecting the data, will send a pickled string to the webpage. Then any of the ""remote"" programs will be able to read the string. I will also need the master program to delete old strings as it updates the webpage. It would be preferred to be able to store multiple string, so there is no chance of the master updating while the remote is reading. I do not know if this is a feasible task in python, but any and all ideas are welcome. Also, if you have an ideas on how to do this a different way, I am all ears, well eyes in this case.","Adding this as an answer so that OP will be more likely to see it... Make sure you consider security! If you just blindly accept pickled data, it can open you up to arbitrary code execution.",0.0,False,4,1520 2011-11-11 18:02:47.620,Sending data through the web to a remote program using python,"I have a program that I wrote in python that collects data. I want to be able to store the data on the internet somewhere and allow for another user to access it from another computer somewhere else, anywhere in the world that has an internet connection. My original idea was to use an e-mail client, such as g-mail, to store the data by sending pickled strings to the address. This would allow for anyone to access the address and simply read the newest e-mail to get the data. It worked perfectly, but the program requires a new e-mail to be sent every 5-30 seconds. So the method fell through because of the limit g-mail has on e-mails, among other reasons, such as I was unable to completely delete old e-mails. Now I want to try a different idea, but I do not know very much about network programming with python. I want to setup a webpage with essentially nothing on it. The ""master"" program, the program actually collecting the data, will send a pickled string to the webpage. Then any of the ""remote"" programs will be able to read the string. I will also need the master program to delete old strings as it updates the webpage. It would be preferred to be able to store multiple string, so there is no chance of the master updating while the remote is reading. -I do not know if this is a feasible task in python, but any and all ideas are welcome. Also, if you have an ideas on how to do this a different way, I am all ears, well eyes in this case.","I suggest you to use a good middle-ware like: Zero-C ICE, Pyro4, Twisted. -Pyro4 using pickle to serialize data.",0.0,False,4,1520 +I do not know if this is a feasible task in python, but any and all ideas are welcome. Also, if you have an ideas on how to do this a different way, I am all ears, well eyes in this case.","Another option in addition to what Casey already provided: +Set up a remote MySQL database somewhere that has user access levels allowing remote connections. Your Python program could then simply access the database and INSERT the data you're trying to store centrally (e.g. through MySQLDb package or pyodbc package). Your users could then either read the data through a client that supports MySQL or you could write a simple front-end in Python or PHP that displays the data from the database.",0.1016881243684853,False,4,1520 2011-11-12 23:54:26.693,Downloading PDF files with Scrapy,"I'm scraping pdf files from a site using Scrapy, a Python web-scraping framework. The site requires to follow the same session in order to allow you to download the pdf. It works great with Scrapy's because it's all automated but when I run the script after a couple of seconds it starts to give me fake pdf files like when I try to access directly the pdf, without my session. @@ -16705,12 +16705,12 @@ However, I manged to connect to the remote server but the control gets lost afte 2011-11-21 15:41:18.600,CSound and Python communication,"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. The 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). Shortly 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. -Thanks in advance","sending parameter values from python to csound could be done using the osc protocol -sending audio from csound to python could be done by routing jack channels between the two applications",0.2012947653214861,False,2,1534 +Thanks in advance","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.",0.2012947653214861,False,2,1534 2011-11-21 15:41:18.600,CSound and Python communication,"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. The 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). Shortly 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. -Thanks in advance","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.",0.2012947653214861,False,2,1534 +Thanks in advance","sending parameter values from python to csound could be done using the osc protocol +sending audio from csound to python could be done by routing jack channels between the two applications",0.2012947653214861,False,2,1534 2011-11-23 20:06:01.947,How to know/change current directory in Python shell?,"I am using Python 3.2 on Windows 7. When I open the Python shell, how can I know what the current directory is and how can I change it to another directory where my modules are?","If you import os you can use os.getcwd to get the current working directory, and you can use os.chdir to change your directory",0.1731644579931097,False,1,1535 2011-11-24 00:27:42.660,Accessing Django Runserver on Shared Hosting,"I'm developing a Django application on a shared hosting service (hostmonster) and am, of course, unable to access the runserver on the default localhost ip of 127.0.0.1:8000 over Firefox. The Django Project site's documentation details how to set up remote access to the run-server, but I'm not having any success with that. Setting the runserver to 0.0.0.0:8000 leaves it inaccessible. Though I figured it wouldn't work, I tried to configure the runserver to my home ip address. That gave me a ""That IP address can't be assigned-to"" error, as I'd expected. So, I tried configuring it to my hosted IP, the one through which I SSH in the first place. That set up properly, but still was unable to access the address via Firefox. When I plug in the IP address on its own, I just get a hostmonster error page. When I affix the port number, the connection times out. When I plug in the IP, port number and the /admin to access the Django admin page I've created, I also time out.","I'm betting that port 8000 is blocked. That explains the timeouts you mention in the last couple sentences: the firewall is set to simply drop the packets and not return any connection refusal responses. @@ -16873,14 +16873,14 @@ Thank you. PS: If you want more info: I have a proprietary high-res camera, and a proprietary binary that I run to capture a single image, I can specify where it will write the file, which is a huge TIFF file, and then the python program runs the convert program from imagemagick to convert it to JPEG and then compress it in tar.bz2, so the quality is almost the same but the filesize is 1/50 of the TIFF.","If on Debian (and possibly its derivatives), use ""/run/shm"" directory.",0.0,False,2,1546 2011-11-28 17:14:11.647,Could someone give me their two cents on this optimization strategy,"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. Rather 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. -Would this be faster, is it feasible in python, and if so does anyone have any recommendations for how to do it?",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.,0.0,False,2,1547 -2011-11-28 17:14:11.647,Could someone give me their two cents on this optimization strategy,"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. -Rather 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. Would this be faster, is it feasible in python, and if so does anyone have any recommendations for how to do it?","Regarding: ""would this be faster:"" The 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. Caveat, 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. However, 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. You 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? … 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.",0.2655860252697744,False,2,1547 +2011-11-28 17:14:11.647,Could someone give me their two cents on this optimization strategy,"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. +Rather 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. +Would this be faster, is it feasible in python, and if so does anyone have any recommendations for how to do it?",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.,0.0,False,2,1547 2011-11-28 17:40:57.727,Biomorph Implementation in Python,"I'm trying to create a Python implementation of Dawkins' biomorphs as described in his book, The Blind Watchmaker. It works like this: A parent organism is displayed, as well as its offspring which are just mutated versions of the parent. Then the user clicks on a descendant it wants to breed, and all the offspring will ""evolve"" based on cumulative selection. What I'm unsure of is how to get started in Python. I've already created genetic algorithm and l-system programs that are supposed to be used. The l-system program evolves trees given certain parameters (which is my goal in this biomorph implementation), and the genetic algorithm program evolves the genotypes that are created in the l-system program. @@ -17063,9 +17063,11 @@ is_dir(path), remove(path), read(file_descr), file_descr open(file_path, mode=w|r), close(file_descr), -write(file_descr, str)","You should first ask the question: What operations should my ""file system"" support? -Based on the answer you select the data representation. -For example, if you choose to support only create and delete and the order of the files in the dictionary is not important, then select a python dictionary. A dictionary will map a file name (sub path name) to either a dictionary or the file container object.",0.0,False,2,1574 +write(file_descr, str)","What's the API of the filestore? Do you want to keep creation, modification and access times? Presumably the primary lookup will be by file name. Are any other retrieval operations anticipated? +If only lookup by name is required then one possible representation is to map the filestore root directory on to a Python dict. Each entry's key will be the filename, and the value will either be a StringIO object (hint: in Python 2 use cStringIO for better performance if it becomes an issue) or another dict. The StringIO objects represent your files, the dicts represent subdirectories. +So, to access any path you split it up into its constituent components (using .split(""/"")) and then use each to look up a successive element. Any KeyError exceptions imply ""File or directory not found,"" as would any attempts to index a StringIO object (I'm too lazy to verify the specific exception). +If you want to implement greater detail then you would replace the StringIO objects and dicts with instances of some ""filestore object"" class. You could call it a ""link"" (since that's what it models: A Linux hard link). The various attributes of this object can easily be manipulated to keep the file attributes up to date, and the .data attribute can be either a StringIO object or a dict as before. +Overall I would prefer the second solution, since then it's easy to implement methods that do things like keep access times up to date by updating them as the operations are performed, but as I said much depends on the level of detail you want to provide.",0.0,False,2,1574 2011-12-14 08:59:17.003,Representing filesystem table,"I’m working on simple class something like “in memory linux-like filesystem” for educational purposes. Files will be as StringIO objects. I can’t make decision how to implement files-folders hierarchy type in Python. I’m thinking about using list of objects with fields: type, name, parent what else? Maybe I should look for trees and graphs. Update: There will be these methods: @@ -17076,30 +17078,28 @@ is_dir(path), remove(path), read(file_descr), file_descr open(file_path, mode=w|r), close(file_descr), -write(file_descr, str)","What's the API of the filestore? Do you want to keep creation, modification and access times? Presumably the primary lookup will be by file name. Are any other retrieval operations anticipated? -If only lookup by name is required then one possible representation is to map the filestore root directory on to a Python dict. Each entry's key will be the filename, and the value will either be a StringIO object (hint: in Python 2 use cStringIO for better performance if it becomes an issue) or another dict. The StringIO objects represent your files, the dicts represent subdirectories. -So, to access any path you split it up into its constituent components (using .split(""/"")) and then use each to look up a successive element. Any KeyError exceptions imply ""File or directory not found,"" as would any attempts to index a StringIO object (I'm too lazy to verify the specific exception). -If you want to implement greater detail then you would replace the StringIO objects and dicts with instances of some ""filestore object"" class. You could call it a ""link"" (since that's what it models: A Linux hard link). The various attributes of this object can easily be manipulated to keep the file attributes up to date, and the .data attribute can be either a StringIO object or a dict as before. -Overall I would prefer the second solution, since then it's easy to implement methods that do things like keep access times up to date by updating them as the operations are performed, but as I said much depends on the level of detail you want to provide.",0.0,False,2,1574 +write(file_descr, str)","You should first ask the question: What operations should my ""file system"" support? +Based on the answer you select the data representation. +For example, if you choose to support only create and delete and the order of the files in the dictionary is not important, then select a python dictionary. A dictionary will map a file name (sub path name) to either a dictionary or the file container object.",0.0,False,2,1574 2011-12-14 14:22:33.660,Tornadoweb webapp cannot be managed via upstart,"Few days ago I found out that my webapp wrote ontop of the tornadoweb framework doesn't stop or restart via upstart. Upstart just hangs and doesn't do anything. I investigated the issue and found that upstart recieves wrong PID, so it can only run once my webapp daemon and can't do anything else. Strace shows that my daemon makes 4 (!) clone() calls instead of 2. Week ago anything was good and webapp was fully and correctly managed by the upstart. OS is Ubuntu 10.04.03 LTS (as it was weeks ago). Do you have any ideas how to fix it? -PS: I know about ""expect fork|daemon"" directive, it changes nothing ;)","Sorry my silence, please. -Investigation of the issue ended with the knowledge about uuid python library which adds 2 forks to my daemon. I get rid of this lib and tornado daemon works now properly. -Alternative answer was supervisord which can run any console tools as a daemon which can't daemonize by itself.",1.2,True,2,1575 +PS: I know about ""expect fork|daemon"" directive, it changes nothing ;)","There are two often used solutions +The first one is to let your application honestly report its pid. If you could force your application to write the actual pid into the pidfile then you could get its pid from there. +The second one is a little more complicated. You may add specific environment variable for the script invocation. This environment variable will stay with all the forks if forks don't clear environment and than you can find all of your processes by parsing /proc/*/environ files. +There should be easier solution for finding processes by their environment but I'm not sure.",0.0,False,2,1575 2011-12-14 14:22:33.660,Tornadoweb webapp cannot be managed via upstart,"Few days ago I found out that my webapp wrote ontop of the tornadoweb framework doesn't stop or restart via upstart. Upstart just hangs and doesn't do anything. I investigated the issue and found that upstart recieves wrong PID, so it can only run once my webapp daemon and can't do anything else. Strace shows that my daemon makes 4 (!) clone() calls instead of 2. Week ago anything was good and webapp was fully and correctly managed by the upstart. OS is Ubuntu 10.04.03 LTS (as it was weeks ago). Do you have any ideas how to fix it? -PS: I know about ""expect fork|daemon"" directive, it changes nothing ;)","There are two often used solutions -The first one is to let your application honestly report its pid. If you could force your application to write the actual pid into the pidfile then you could get its pid from there. -The second one is a little more complicated. You may add specific environment variable for the script invocation. This environment variable will stay with all the forks if forks don't clear environment and than you can find all of your processes by parsing /proc/*/environ files. -There should be easier solution for finding processes by their environment but I'm not sure.",0.0,False,2,1575 +PS: I know about ""expect fork|daemon"" directive, it changes nothing ;)","Sorry my silence, please. +Investigation of the issue ended with the knowledge about uuid python library which adds 2 forks to my daemon. I get rid of this lib and tornado daemon works now properly. +Alternative answer was supervisord which can run any console tools as a daemon which can't daemonize by itself.",1.2,True,2,1575 2011-12-14 16:40:24.343,using data from a txt file in python,"I'm learning python and now I'm having some problems with reading and analyzing txt files. I want to open in python a .txt file that contains many lines and in each line I have one fruit and it's price. I would like to know how to make python recognize their prices as a number (since it recognizes as a string when I use readlines()) so then I could use the numbers in some simple functions to calculate the minimum price that I have to sell the fruits to obtain profit. Any ideas of how to do it?","I had the same problem when I first was learning Python, coming from Perl. Perl will ""do what you mean"" (or at least what it thinks you mean), and automatically convert something that looks like a number into a number when you try to use it like a number. (I'm generalizing, but you get the idea). The Python philosophy is to not have so much magic occurring, so you must do the conversion explicitly. Call either float(""12.00"") or int(""123"") to convert from strings.",0.0,False,1,1576 @@ -17107,6 +17107,11 @@ Any ideas of how to do it?","I had the same problem when I first was learning Py For example, ""HELPMEPLZ"" and ""HELPNEPLX"" are different at positions 4 and 8.","Easiest way is to split data into two char arrays and then loop through comparing the letters and return the index when the two chars do not equal each other. This method will work fine as long as both strings are equal in length.",0.0,False,1,1577 2011-12-18 12:36:37.527,How do I run Python code from Sublime Text 2?,"I want to set up a complete Python IDE in Sublime Text 2. +I want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?",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.,0.0,False,4,1578 +2011-12-18 12:36:37.527,How do I run Python code from Sublime Text 2?,"I want to set up a complete Python IDE in Sublime Text 2. +I want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?","seems the Ctrl+Break doesn't work on me, neither the Preference - User... +use keys, Alt → t → c",0.0255046717588776,False,4,1578 +2011-12-18 12:36:37.527,How do I run Python code from Sublime Text 2?,"I want to set up a complete Python IDE in Sublime Text 2. I want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?","[ This applies to ST3 (Win), not sure about ST2 ] To have the output visible in Sublime as another file (+ one for errors), do this: @@ -17128,25 +17133,7 @@ ctrl + b Now, next to your file, e.g. ""file.py"" you'll have ""file.__STDOUT__.py"" and ""file.__STDERR__.py"" (for errors, if any) If you split your window into 3 columns, or a grid, you'll see the result immediately, without a need to switch panels / windows",0.126863772113723,False,4,1578 2011-12-18 12:36:37.527,How do I run Python code from Sublime Text 2?,"I want to set up a complete Python IDE in Sublime Text 2. -I want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?","seems the Ctrl+Break doesn't work on me, neither the Preference - User... -use keys, Alt → t → c",0.0255046717588776,False,4,1578 -2011-12-18 12:36:37.527,How do I run Python code from Sublime Text 2?,"I want to set up a complete Python IDE in Sublime Text 2. I want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?",You can access the Python console via “View/Show console” or Ctrl+`.,0.0,False,4,1578 -2011-12-18 12:36:37.527,How do I run Python code from Sublime Text 2?,"I want to set up a complete Python IDE in Sublime Text 2. -I want to know how to run the Python code from within the editor. Is it done using build system? How do I do it ?",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.,0.0,False,4,1578 -2011-12-18 20:27:54.363,Personalizing Online Assignments for a Statistics Class,"I teach undergraduate statistics, and am interested in administering personalized online assignments. I have already solved one portion of the puzzle, the generation of multiple version of a question using latex/markdown + knitr/sweave, using seeds. -I am now interested in developing a web-based system, that would use the various versions generated, and administer a different one for each student, online. I have looked into several sites related to forms (google docs, wufoo, formsite etc.), but none of them allow programmatic creation of questionnaires. -I am tagging this with R since that is the language I am most familiar with, and is key to solving the first part of the problem. I know that there are several web-based frameworks for R, and was wondering whether any of them are suitable for this job. -I am not averse to solutions in other languages like Ruby, Python etc. But the key consideration is the ability to programatically deliver online assignments. I am aware of tools like WebWork, but they require the use of Perl and the interfaces are usually quite clunky. -Feel free to add tags to the post, if you think I have missed a framework that would be more suitable. -EDIT. Let me make it clear by giving an example. Currently, if I want to administer an assignment online, I could simply create a Google Form, send the link to my students, and collect all responses in a spreadsheet, and automatically grade it. This works, if I just have one version of the assignment. -My questions is, if I want to administer a different version of the assignment for each student, and collect their responses, how can I do that?","The way you have worded your question it's not really clear why you have to mark the students' work online. Especially since you say that you generate assignments using sweave. If you use R to generate the (randomised) questions, then you really have to use R to mark them (or output the data set). -For my courses, I use a couple of strategies. - -For the end of year exam (~500 students), each student gets a unique data set. The students log on to a simple web-site (we use blackboard since the University already has it set up). All students answer the same questions, but use their own unique data set. For example, ""What is the mean"". The answers are marked offline using an R script. -In my introductory R course, students upload their R functions and I run and mark them off line. I use sweave to generate a unique pdf for each student. Their pdf shows where they lost marks. For example, they didn't use the correct named arguments. - -Coupling a simple web-form with marking offline gives you a lot of flexibility and is fairly straightforward.",0.725124135103691,False,2,1579 2011-12-18 20:27:54.363,Personalizing Online Assignments for a Statistics Class,"I teach undergraduate statistics, and am interested in administering personalized online assignments. I have already solved one portion of the puzzle, the generation of multiple version of a question using latex/markdown + knitr/sweave, using seeds. I am now interested in developing a web-based system, that would use the various versions generated, and administer a different one for each student, online. I have looked into several sites related to forms (google docs, wufoo, formsite etc.), but none of them allow programmatic creation of questionnaires. I am tagging this with R since that is the language I am most familiar with, and is key to solving the first part of the problem. I know that there are several web-based frameworks for R, and was wondering whether any of them are suitable for this job. @@ -17163,6 +17150,19 @@ Create a common Google Form to capture final answers for each student. The advantage I see is two-fold. One, since all final answers get captured on a spreadsheet, I can access them with R and grade them automatically. Two, since I have access to all the completed assignments on Google Docs, I can skim through them and provide individual comments as required (or let some of my TAs do it). I will provide an update, if I manage to get this working, and maybe even create an R package if it would be useful for others.",0.2012947653214861,False,2,1579 +2011-12-18 20:27:54.363,Personalizing Online Assignments for a Statistics Class,"I teach undergraduate statistics, and am interested in administering personalized online assignments. I have already solved one portion of the puzzle, the generation of multiple version of a question using latex/markdown + knitr/sweave, using seeds. +I am now interested in developing a web-based system, that would use the various versions generated, and administer a different one for each student, online. I have looked into several sites related to forms (google docs, wufoo, formsite etc.), but none of them allow programmatic creation of questionnaires. +I am tagging this with R since that is the language I am most familiar with, and is key to solving the first part of the problem. I know that there are several web-based frameworks for R, and was wondering whether any of them are suitable for this job. +I am not averse to solutions in other languages like Ruby, Python etc. But the key consideration is the ability to programatically deliver online assignments. I am aware of tools like WebWork, but they require the use of Perl and the interfaces are usually quite clunky. +Feel free to add tags to the post, if you think I have missed a framework that would be more suitable. +EDIT. Let me make it clear by giving an example. Currently, if I want to administer an assignment online, I could simply create a Google Form, send the link to my students, and collect all responses in a spreadsheet, and automatically grade it. This works, if I just have one version of the assignment. +My questions is, if I want to administer a different version of the assignment for each student, and collect their responses, how can I do that?","The way you have worded your question it's not really clear why you have to mark the students' work online. Especially since you say that you generate assignments using sweave. If you use R to generate the (randomised) questions, then you really have to use R to mark them (or output the data set). +For my courses, I use a couple of strategies. + +For the end of year exam (~500 students), each student gets a unique data set. The students log on to a simple web-site (we use blackboard since the University already has it set up). All students answer the same questions, but use their own unique data set. For example, ""What is the mean"". The answers are marked offline using an R script. +In my introductory R course, students upload their R functions and I run and mark them off line. I use sweave to generate a unique pdf for each student. Their pdf shows where they lost marks. For example, they didn't use the correct named arguments. + +Coupling a simple web-form with marking offline gives you a lot of flexibility and is fairly straightforward.",0.725124135103691,False,2,1579 2011-12-19 09:37:12.580,python string parsing using regular expression,"Given a string #abcde#jfdkjfd, how can I get the string between two # ? And I also want that if no # pair(means no # or only one #), the function will return None.","Use (?<=#)(\w+)(?=#) and capture the first group. You can even cycle through a string which contains several embedded strings and it will work. This uses both a positive lookbehind and positive lookahead.",0.2655860252697744,False,1,1580 2011-12-20 05:57:10.960,Running .py files,"I have .ui, .py and .pyc files generated. Now, when I edit the .py file, how will it reflect changes in the .ui file? How do I connect .the ui and .py files together as QT designer allows only .ui files for running purposes?","the .py file generated from pyuic is not supposed to be edited by the user, best way it is intended to use is to subclass the class in .py file into your own class and do the necessary changes in your class..",0.0,False,1,1581 @@ -17183,8 +17183,9 @@ Are my perceptions of SqlAlchemy (slow/interpreted, bloated, steep learning curv execute SQL statements directly without having to mess about with the ORM layer, etc. -Any examples of doing this available?","SQLAlchemy is a ORM, psycopg2 is a database driver. These are completely different things: SQLAlchemy generates SQL statements and psycopg2 sends SQL statements to the database. SQLAlchemy depends on psycopg2 or other database drivers to communicate with the database! -As a rather complex software layer SQLAlchemy does add some overhead but it also is a huge boost to development speed, at least once you learned the library. SQLAlchemy is a excellent library and will teach you the whole ORM concept, but if you don't want to generate SQL statements to begin with then you don't want SQLAlchemy.",1.2,True,2,1582 +Any examples of doing this available?","To talk with database any one need driver for that. If you are using client like SQL Plus for oracle, MysqlCLI for Mysql then it will direct run the query and that client come with DBServer pack. +To communicate from outside with any language like java, c, python, C#... We need driver to for that database. psycopg2 is driver to run query for PostgreSQL from python. +SQLAlchemy is the ORM which is not same as database driver. It will give you flexibility so you can write your code without any database specific standard. ORM provide database independence for programmer. If you write object.save in ORM then it will check, which database is associated with that object and it will generate insert query according to the backend database.",0.9999665971563038,False,2,1582 2011-12-21 10:08:50.210,SQLAlchemy or psycopg2?,"I am writing a quick and dirty script which requires interaction with a database (PG). The script is a pragmatic, tactical solution to an existing problem. however, I envisage that the script will evolve over time into a more ""refined"" system. Given the fact that it is currently being put together very quickly (i.e. I don't have the time to pour over huge reams of documentation), I am tempted to go the quick and dirty route, using psycopg. The advantages for psycopg2 (as I currently understand it) is that: @@ -17202,9 +17203,8 @@ Are my perceptions of SqlAlchemy (slow/interpreted, bloated, steep learning curv execute SQL statements directly without having to mess about with the ORM layer, etc. -Any examples of doing this available?","To talk with database any one need driver for that. If you are using client like SQL Plus for oracle, MysqlCLI for Mysql then it will direct run the query and that client come with DBServer pack. -To communicate from outside with any language like java, c, python, C#... We need driver to for that database. psycopg2 is driver to run query for PostgreSQL from python. -SQLAlchemy is the ORM which is not same as database driver. It will give you flexibility so you can write your code without any database specific standard. ORM provide database independence for programmer. If you write object.save in ORM then it will check, which database is associated with that object and it will generate insert query according to the backend database.",0.9999665971563038,False,2,1582 +Any examples of doing this available?","SQLAlchemy is a ORM, psycopg2 is a database driver. These are completely different things: SQLAlchemy generates SQL statements and psycopg2 sends SQL statements to the database. SQLAlchemy depends on psycopg2 or other database drivers to communicate with the database! +As a rather complex software layer SQLAlchemy does add some overhead but it also is a huge boost to development speed, at least once you learned the library. SQLAlchemy is a excellent library and will teach you the whole ORM concept, but if you don't want to generate SQL statements to begin with then you don't want SQLAlchemy.",1.2,True,2,1582 2011-12-21 14:43:37.823,deploying a python web application,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?,"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.",1.2,True,1,1583 2011-12-23 13:10:01.587,How to keep global variables persistent over multiple google appengine instances?,"Our situation is as follows: We are working on a schoolproject where the intention is that multiple teams walk around in a city with smarthphones and play a city game while walking. @@ -17218,8 +17218,9 @@ Can we somehow make sure these global variables are always the same on every run OR Can we limit the amount of instances ever running, no matter how many requests are done to '1'. OR -Is there perhaps another way to store this data in a better way, without using the datastore and without using globals.","You should be using memcache. If you use the ndb (new database) library, you can automatically cache the results of queries. Obviously this won't improve your writes much, but it should significantly improve the numbers of reads you can do. -You need to back it with the datastore as data can be ejected from memcache at any time. If you're willing to take the (small) chance of losing updates you could just use memcache. You could do something like store just a message ID in the datastore and have the controller periodically verify that every message ID has a corresponding entry in memcache. If one is missing the controller would need to reenter it.",1.2,True,3,1584 +Is there perhaps another way to store this data in a better way, without using the datastore and without using globals.","Interesting question. Some bad news first, I don't think there's a better way of storing data; no, you won't be able to stop new instances from spawning and no, you cannot make seperate instances always have the same data. +What you could do is have the instances perioidically sync themselves with a master record in the datastore, by choosing the frequency of this intelligently and downloading/uploading the information in one lump you could limit the number of read/writes to a level that works for you. This is firmly in the kludge territory though. +Despite finding the quota for just about everything else, I can't find the limits for free read/write so it is possible that they're ludicrously small but the fact that you're hitting them with a mere 10 smartphones raises a red flag to me. Are you certain that the smartphones are being polled (or calling in) at a sensible frequency? It sounds like you might be hammering them unnecessarily.",0.0,False,3,1584 2011-12-23 13:10:01.587,How to keep global variables persistent over multiple google appengine instances?,"Our situation is as follows: We are working on a schoolproject where the intention is that multiple teams walk around in a city with smarthphones and play a city game while walking. As such, we can have 10 active smarthpones walking around in the city, all posting their location, and requesting data from the google appengine. @@ -17232,9 +17233,8 @@ Can we somehow make sure these global variables are always the same on every run OR Can we limit the amount of instances ever running, no matter how many requests are done to '1'. OR -Is there perhaps another way to store this data in a better way, without using the datastore and without using globals.","Interesting question. Some bad news first, I don't think there's a better way of storing data; no, you won't be able to stop new instances from spawning and no, you cannot make seperate instances always have the same data. -What you could do is have the instances perioidically sync themselves with a master record in the datastore, by choosing the frequency of this intelligently and downloading/uploading the information in one lump you could limit the number of read/writes to a level that works for you. This is firmly in the kludge territory though. -Despite finding the quota for just about everything else, I can't find the limits for free read/write so it is possible that they're ludicrously small but the fact that you're hitting them with a mere 10 smartphones raises a red flag to me. Are you certain that the smartphones are being polled (or calling in) at a sensible frequency? It sounds like you might be hammering them unnecessarily.",0.0,False,3,1584 +Is there perhaps another way to store this data in a better way, without using the datastore and without using globals.","You should be using memcache. If you use the ndb (new database) library, you can automatically cache the results of queries. Obviously this won't improve your writes much, but it should significantly improve the numbers of reads you can do. +You need to back it with the datastore as data can be ejected from memcache at any time. If you're willing to take the (small) chance of losing updates you could just use memcache. You could do something like store just a message ID in the datastore and have the controller periodically verify that every message ID has a corresponding entry in memcache. If one is missing the controller would need to reenter it.",1.2,True,3,1584 2011-12-23 13:10:01.587,How to keep global variables persistent over multiple google appengine instances?,"Our situation is as follows: We are working on a schoolproject where the intention is that multiple teams walk around in a city with smarthphones and play a city game while walking. As such, we can have 10 active smarthpones walking around in the city, all posting their location, and requesting data from the google appengine. @@ -17348,23 +17348,23 @@ You need to ""ease up to"" the setpoint so that you arrive at the set point just 2011-12-28 03:54:46.327,OpenERP - Report Creation,"I am trying to create a new report with report plugin and openoffice but I don't know how to assign it in the OpenERP system. Is there someone who can give me exact steps for creation of new report and integration with openerp? Thanks in advance!",First you save .odt file then connect with server and select open new report and then send it ti server with proper report name and then keep on editing your report by selecting the option modify existing report.,0.1016881243684853,False,1,1593 -2011-12-28 23:36:06.063,Plotting Complex Numbers in Python?,"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!","Julia set renderings are generally 2D color plots, with [x y] representing a complex starting point and the color usually representing an iteration count.",0.0,False,2,1594 2011-12-28 23:36:06.063,Plotting Complex Numbers in Python?,"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!",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.,0.3869120172231254,False,2,1594 +2011-12-28 23:36:06.063,Plotting Complex Numbers in Python?,"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!","Julia set renderings are generally 2D color plots, with [x y] representing a complex starting point and the color usually representing an iteration count.",0.0,False,2,1594 2011-12-29 02:33:05.313,How do I transform every doc in a large Mongodb collection without map/reduce?,"Apologies for the longish description. I want to run a transform on every doc in a large-ish Mongodb collection with 10 million records approx 10G. Specifically I want to apply a geoip transform to the ip field in every doc and either append the result record to that doc or just create a whole other record linked to this one by say id (the linking is not critical, I can just create a whole separate record). Then I want to count and group by say city - (I do know how to do the last part). The major reason I believe I cant use map-reduce is I can't call out to the geoip library in my map function (or at least that's the constraint I believe exists). So I the central question is how do I run through each record in the collection apply the transform - using the most efficient way to do that. Batching via Limit/skip is out of question as it does a ""table scan"" and it is going to get progressively slower. Any suggestions? -Python or Js preferred just bec I have these geoip libs but code examples in other languages welcome.","Since you have to go over ""each record"", you'll do one full table scan anyway, then a simple cursor (find()) + maybe only fetching few fields (_id, ip) should do it. python driver will do the batching under the hood, so maybe you can give a hint on what's the optimal batch size (batch_size) if the default is not good enough. -If you add a new field and it doesn't fit the previously allocated space, mongo will have to move it to another place, so you might be better off creating a new document.",1.2,True,2,1595 +Python or Js preferred just bec I have these geoip libs but code examples in other languages welcome.","Actually I am also attempting another approach in parallel (as plan B) which is to use mongoexport. I use it with --csv to dump a large csv file with just the (id, ip) fields. Then the plan is to use a python script to do a geoip lookup and then post back to mongo as a new doc on which map-reduce can now be run for count etc. Not sure if this is faster or the cursor is. We'll see.",0.0,False,2,1595 2011-12-29 02:33:05.313,How do I transform every doc in a large Mongodb collection without map/reduce?,"Apologies for the longish description. I want to run a transform on every doc in a large-ish Mongodb collection with 10 million records approx 10G. Specifically I want to apply a geoip transform to the ip field in every doc and either append the result record to that doc or just create a whole other record linked to this one by say id (the linking is not critical, I can just create a whole separate record). Then I want to count and group by say city - (I do know how to do the last part). The major reason I believe I cant use map-reduce is I can't call out to the geoip library in my map function (or at least that's the constraint I believe exists). So I the central question is how do I run through each record in the collection apply the transform - using the most efficient way to do that. Batching via Limit/skip is out of question as it does a ""table scan"" and it is going to get progressively slower. Any suggestions? -Python or Js preferred just bec I have these geoip libs but code examples in other languages welcome.","Actually I am also attempting another approach in parallel (as plan B) which is to use mongoexport. I use it with --csv to dump a large csv file with just the (id, ip) fields. Then the plan is to use a python script to do a geoip lookup and then post back to mongo as a new doc on which map-reduce can now be run for count etc. Not sure if this is faster or the cursor is. We'll see.",0.0,False,2,1595 +Python or Js preferred just bec I have these geoip libs but code examples in other languages welcome.","Since you have to go over ""each record"", you'll do one full table scan anyway, then a simple cursor (find()) + maybe only fetching few fields (_id, ip) should do it. python driver will do the batching under the hood, so maybe you can give a hint on what's the optimal batch size (batch_size) if the default is not good enough. +If you add a new field and it doesn't fit the previously allocated space, mongo will have to move it to another place, so you might be better off creating a new document.",1.2,True,2,1595 2011-12-29 22:08:12.297,Website Links to Downloadable Files Don't Seem to Update,"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. A little background on the current situation: I'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. @@ -17409,11 +17409,11 @@ If it is allowed to be variable, you would need do str(countrycode) + str(n).zfi Otherwise, for a fixed total length of 12 digits, you would need str(countrycode) + str(n).zfill(12 - len(str(countrycode)))",0.1352210990936997,False,1,1601 2012-01-03 03:42:56.000,how to copy an executable file with python?,"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. EDIT: -ok 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.","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. -I hope I'm interpreting your error properly. In the future it is best to copy and paste the actual error message into your question.",0.0814518047658113,False,2,1602 +ok 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.","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.",0.0,False,2,1602 2012-01-03 03:42:56.000,how to copy an executable file with python?,"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. EDIT: -ok 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.","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.",0.0,False,2,1602 +ok 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.","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. +I hope I'm interpreting your error properly. In the future it is best to copy and paste the actual error message into your question.",0.0814518047658113,False,2,1602 2012-01-03 16:37:26.713,how to share variable between python and go language?,"i need to know how share variable between two program, basically the go program have to write a variable ,like a string, and the python program have to read this variable. Please help me, thank you in advance.","use standard streams. use a simple printf type command to print the string to stdout. then read it with a raw_input() in python. @@ -17447,7 +17447,7 @@ Thanks :)","Like the commentators have said, find someone to talk to in your uni If 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"". Does anyone know how to use symlink for importing?","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. If 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.",0.999329299739067,False,1,1607 -2012-01-07 18:46:22.470,how long can i store data in cPickle?,"I'm storing a list of dictionaries in cPickle, but need to be able to add and remove to/from it occasionally. If I store the dictionary data in cPickle, is there some sort of limit on when I will be able to load it again?",No. cPickle just writes data to files and reads it back; why would you think there would be a limit?,0.0,False,3,1608 +2012-01-07 18:46:22.470,how long can i store data in cPickle?,"I'm storing a list of dictionaries in cPickle, but need to be able to add and remove to/from it occasionally. If I store the dictionary data in cPickle, is there some sort of limit on when I will be able to load it again?","You can store it for as long as you want. It's just a file. However, if your data structures start becoming complicated, it can become tedious and time consuming to unpickle, update and pickle the data again. Also, it's just file access so you have to handle concurrency issues by yourself.",1.2,True,3,1608 2012-01-07 18:46:22.470,how long can i store data in cPickle?,"I'm storing a list of dictionaries in cPickle, but need to be able to add and remove to/from it occasionally. If I store the dictionary data in cPickle, is there some sort of limit on when I will be able to load it again?","cPickle is just a faster implementation of pickle. You can use it to convert a python object to its string equivalent and retrieve it back by unpickling. You can do one of the two things with a pickled object: @@ -17458,7 +17458,7 @@ Write to a file We can write this pickled data to a file and read it whenever we want and get back the python objects/data structures. Your pickled data is safe as long as your pickled file is stored on the disk.",0.0,False,3,1608 -2012-01-07 18:46:22.470,how long can i store data in cPickle?,"I'm storing a list of dictionaries in cPickle, but need to be able to add and remove to/from it occasionally. If I store the dictionary data in cPickle, is there some sort of limit on when I will be able to load it again?","You can store it for as long as you want. It's just a file. However, if your data structures start becoming complicated, it can become tedious and time consuming to unpickle, update and pickle the data again. Also, it's just file access so you have to handle concurrency issues by yourself.",1.2,True,3,1608 +2012-01-07 18:46:22.470,how long can i store data in cPickle?,"I'm storing a list of dictionaries in cPickle, but need to be able to add and remove to/from it occasionally. If I store the dictionary data in cPickle, is there some sort of limit on when I will be able to load it again?",No. cPickle just writes data to files and reads it back; why would you think there would be a limit?,0.0,False,3,1608 2012-01-08 16:29:08.923,Changing privacy of old Facebook posts using the Graph API,"So I was flicking through my Facebook Timeline, and started to look at some old posts I made in 2009~2010. And they're a bit stupid and I'd like to remove them or change the privacy settings on them. There are too many to do it individually, so I've been looking at the Graph API. However, I have been unable to find anything about changing the privacy settings of posts, or even searching for posts made in a specific date range. So here is the information that I want: @@ -17466,15 +17466,10 @@ Is it possible to change privacy settings for OLD posts via the Graph API? Is it possible to search the Graph API for posts in a particular date range? Preferably before 31st December 2010. If it is possible, how do you do it!?","1) Nope. 2) Yes, you can use the Graph API and HTTP Get me/feed?until={date}",1.2,True,1,1609 -2012-01-09 15:12:36.140,Convert HTML HEX Color or RGB tuple to X11 color,"I'm searching for a single function to convert RGB tuple (255, 255, 255) or HTML hex (#FFFFFF) to X11 color (0...255 int) to manage colors in Unix terminal. I've looked over the internet but I didn't find anything like that, so I'm asking for code or link to a website that contains code or information about how I can do this in Python.","If I understand your question properly, I don't think you can do this. The RGB tuple (and its representation as a 6-digit hex number for HTML) represents a specific color in the RGB colorspace. The single integer in the range 0 to 255 you mention for the Unix terminal isn't a specific color, but rather an index into a color table. As an example, color 15 on one terminal may be #ff0000, but #33ff33 on another. There really isn't a conversion between the two.",0.1016881243684853,False,2,1610 2012-01-09 15:12:36.140,Convert HTML HEX Color or RGB tuple to X11 color,"I'm searching for a single function to convert RGB tuple (255, 255, 255) or HTML hex (#FFFFFF) to X11 color (0...255 int) to manage colors in Unix terminal. I've looked over the internet but I didn't find anything like that, so I'm asking for code or link to a website that contains code or information about how I can do this in Python.","You can't convert to x11 colors automatically. x11 colors are basically just names mapped to arbitrary RGB values, so the only way to get from RGB to x11 is to reverse the map. If you want to convert an RGB color that isn't in x11 to the closest match in x11 that would be pretty difficult.",0.1016881243684853,False,2,1610 -2012-01-09 16:50:24.777,"how do I launch IDLE, the development environment for Python, on Mac OS 10.7?","I am running python 2.7.1. I can't figure out how to launch the IDLE IDE. I am told it comes already installed with python, but I can't find it using spotlight.","In the stock Mac OS X python installation, idle is found in /usr/bin, which is not (easily) accessible from Finder and not indexed by Spotlight. The quickest option is to open the Terminal utility and type 'idle' at the prompt. For a more Mac-like way of opening it, you'll have to create a small app or shortcut to launch /usr/bin/idle for you (an exercise left to the reader).",1.2,True,6,1611 -2012-01-09 16:50:24.777,"how do I launch IDLE, the development environment for Python, on Mac OS 10.7?","I am running python 2.7.1. I can't figure out how to launch the IDLE IDE. I am told it comes already installed with python, but I can't find it using spotlight.","After you launch idle from the command line (make sure idle shell window has focus), click File, click ""New File"". A new window opens; this is your editor. -Type your program in the editor. Click ""File"", click ""Save As..."". Save your file somewhere with any name you choose, and a "".py"" extension to the file name. -Click ""Run"", click ""Run Module"" (or, F5). Assuming no errors, the results will appear in the Shell window. Edit your file & repeat as necessary.",0.0407936753323291,False,6,1611 -2012-01-09 16:50:24.777,"how do I launch IDLE, the development environment for Python, on Mac OS 10.7?","I am running python 2.7.1. I can't figure out how to launch the IDLE IDE. I am told it comes already installed with python, but I can't find it using spotlight.","As to the earlier questions about starting IDLE: you can certainly start it from the command line. Also, if you installed Python using Homebrew, you can run 'brew linkapps' (from the command line); that will place an app for IDLE (among other things) in Launchpad (Applications folder).",0.0,False,6,1611 +2012-01-09 15:12:36.140,Convert HTML HEX Color or RGB tuple to X11 color,"I'm searching for a single function to convert RGB tuple (255, 255, 255) or HTML hex (#FFFFFF) to X11 color (0...255 int) to manage colors in Unix terminal. I've looked over the internet but I didn't find anything like that, so I'm asking for code or link to a website that contains code or information about how I can do this in Python.","If I understand your question properly, I don't think you can do this. The RGB tuple (and its representation as a 6-digit hex number for HTML) represents a specific color in the RGB colorspace. The single integer in the range 0 to 255 you mention for the Unix terminal isn't a specific color, but rather an index into a color table. As an example, color 15 on one terminal may be #ff0000, but #33ff33 on another. There really isn't a conversion between the two.",0.1016881243684853,False,2,1610 2012-01-09 16:50:24.777,"how do I launch IDLE, the development environment for Python, on Mac OS 10.7?","I am running python 2.7.1. I can't figure out how to launch the IDLE IDE. I am told it comes already installed with python, but I can't find it using spotlight.","One way to run IDLE from spotlight or an icon in the Applications folder is to build a quick Automation for it. As mentioned by other commentators, this probably isn't necessary for Python 3, as it creates a shortcut automatically, and some hand-installed versions have tools to do this automatically. But if you want to roll your own: You'll need to know the terminal command to open your version of IDLE. On my Mac right now (early 2016), running python 2.7.10, it is ""idle2.7"" @@ -17485,6 +17480,11 @@ In the actions column, find ""Run Shell Script"" and double-click it, or drag it Enter the terminal command in the parameters box that appears. Save your automation (I called mine ""IDLE"" and put it in the Applications folder, to make it easy). It's now available (as soon as spotlight indexes it) via all the normal methods. The only side-effect will be that while it's running, your menu bar will have a spinning gear over in the tray area next to the clock. This indicates an automation workflow is running. Once you close IDLE, it will go away.",0.4858489546925263,False,6,1611 +2012-01-09 16:50:24.777,"how do I launch IDLE, the development environment for Python, on Mac OS 10.7?","I am running python 2.7.1. I can't figure out how to launch the IDLE IDE. I am told it comes already installed with python, but I can't find it using spotlight.","After you launch idle from the command line (make sure idle shell window has focus), click File, click ""New File"". A new window opens; this is your editor. +Type your program in the editor. Click ""File"", click ""Save As..."". Save your file somewhere with any name you choose, and a "".py"" extension to the file name. +Click ""Run"", click ""Run Module"" (or, F5). Assuming no errors, the results will appear in the Shell window. Edit your file & repeat as necessary.",0.0407936753323291,False,6,1611 +2012-01-09 16:50:24.777,"how do I launch IDLE, the development environment for Python, on Mac OS 10.7?","I am running python 2.7.1. I can't figure out how to launch the IDLE IDE. I am told it comes already installed with python, but I can't find it using spotlight.","As to the earlier questions about starting IDLE: you can certainly start it from the command line. Also, if you installed Python using Homebrew, you can run 'brew linkapps' (from the command line); that will place an app for IDLE (among other things) in Launchpad (Applications folder).",0.0,False,6,1611 +2012-01-09 16:50:24.777,"how do I launch IDLE, the development environment for Python, on Mac OS 10.7?","I am running python 2.7.1. I can't figure out how to launch the IDLE IDE. I am told it comes already installed with python, but I can't find it using spotlight.","In the stock Mac OS X python installation, idle is found in /usr/bin, which is not (easily) accessible from Finder and not indexed by Spotlight. The quickest option is to open the Terminal utility and type 'idle' at the prompt. For a more Mac-like way of opening it, you'll have to create a small app or shortcut to launch /usr/bin/idle for you (an exercise left to the reader).",1.2,True,6,1611 2012-01-09 16:50:24.777,"how do I launch IDLE, the development environment for Python, on Mac OS 10.7?","I am running python 2.7.1. I can't figure out how to launch the IDLE IDE. I am told it comes already installed with python, but I can't find it using spotlight.","The answer of Matthewm1970 works like a charm! And if you add an & to your shell command, the automation script will end immediately. There is no spinning gear. Like so: @@ -17516,12 +17516,6 @@ I know how to use thread synchronization primitives and thread-safe data structu My 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. Anyone know whether the Serial class can be used this way? EDIT: 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. -EDIT: There's only been one response but if anyone else has tried this, please leave a response with your experience.","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.",1.2,True,3,1615 -2012-01-09 23:46:39.250,"pyserial - possible to write to serial port from thread a, do blocking reads from thread b?","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? -I 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. -My 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. -Anyone know whether the Serial class can be used this way? -EDIT: 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. EDIT: There's only been one response but if anyone else has tried this, please leave a response with your experience.","I've used pyserial in this way on Linux (and Windows), no problems !",0.4961739557460144,False,3,1615 2012-01-09 23:46:39.250,"pyserial - possible to write to serial port from thread a, do blocking reads from thread b?","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? I 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. @@ -17532,9 +17526,12 @@ EDIT: There's only been one response but if anyone else has tried this, please l Thread A could run at full speed for a friendly user interface or perform any real time operation. Thread 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. Thread 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.",0.0,False,3,1615 -2012-01-10 18:27:38.723,how to deploy a hardened Thrift server for python?,"There is probably a nice document that will help me. Please point to it. -If 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? -Thanks in advance.","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).",0.2012947653214861,False,2,1616 +2012-01-09 23:46:39.250,"pyserial - possible to write to serial port from thread a, do blocking reads from thread b?","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? +I 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. +My 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. +Anyone know whether the Serial class can be used this way? +EDIT: 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. +EDIT: There's only been one response but if anyone else has tried this, please leave a response with your experience.","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.",1.2,True,3,1615 2012-01-10 18:27:38.723,how to deploy a hardened Thrift server for python?,"There is probably a nice document that will help me. Please point to it. If 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? Thanks in advance.","I assume that you are using the Python THttpServer? A couple of notes: @@ -17545,6 +17542,9 @@ This class is not very performant, but it is useful (for example) for """""" I 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. 2) 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.",0.2012947653214861,False,2,1616 +2012-01-10 18:27:38.723,how to deploy a hardened Thrift server for python?,"There is probably a nice document that will help me. Please point to it. +If 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? +Thanks in advance.","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).",0.2012947653214861,False,2,1616 2012-01-11 17:29:45.500,Huge memory usage by ipcontroller,"I am using IPython 0.10.2 and Python 2.7 right now. I start one ipcontroller and 20 ipengines on my cluster. The code structure is very simple. I just use MultiEngineClient.execute() methods and MultiEngineClient dictionary interface (e.g., mec['a'] = b) . My current application needs to run nearly two days. However, after 10 hours running, I find that ipcontroller has used 3.1 GB memory. I do use MultiEngineClient.clear_properties(). But it never releases any memory. Does anyone know how to release the memory of ipcontroller ?","Unfortunately, it may not be possible to free memory effectively in the Controller in IPython 0.10, but the MultiEngineClient.clear_pending_results() method may help. The controller in 0.11-0.12 can use a database (sqlite or mongodb) to store results, and has been seen to run for a long time, with gigabytes of throughput without unreasonable long-term growth.",1.2,True,1,1617 2012-01-11 17:36:49.003,"In emacs Python mode, how do I set a different auto-fill width for docstrings and code?","I would like to have auto-fill set to 79 columns for code sections and 72 for docstrings to get automatic PEP8 compliance. There seems to be an option to do this for Lisp mode (emacs-lisp-docstring-fill-column) but not for Python. @@ -17557,17 +17557,17 @@ Is there a way to change this behavior to single click Is there a way to have 2nd cell in 1st row selected and ready for editing by default when window is created?","You can also use setCurrentCell. table.setCurrentCell(0,1) QTableWidget.setCurrentCell (self, int row, int column)",0.3869120172231254,False,1,1619 -2012-01-11 22:33:12.303,Rock paper Scissors bot algorithm,"In my school our teacher is holding a Rock, paper, scissors bot competition. I know how to program in Python, but I have no idea how to program a bot that would have a bigger chance of success than one that randomly selects its weapons. I think it is possible to store all previous moves and then look for patterns in order to defy attacks. Am I going in a right direction? Any ideas?","It is proven for rock-paper-scissors that a random bot will be at the median of each rank. -Therefore, I'd create a set of bots, each calculating one heuristic and running on the background on parallel. For each turn, each bot will virtually ""draw"" and check if he had won or lost - if it would have played this turn. Each bot will keep track on how many games it would have won if it played, and how many it would have lost. -One of these bots will be the random attacker. -Each time it is your turn: choose which bot won so far the most [greedy] - and use it. -Using this approach you are guaranteed to be at the top median of your class! [with enough rounds of games of course]",1.2,True,2,1620 2012-01-11 22:33:12.303,Rock paper Scissors bot algorithm,"In my school our teacher is holding a Rock, paper, scissors bot competition. I know how to program in Python, but I have no idea how to program a bot that would have a bigger chance of success than one that randomly selects its weapons. I think it is possible to store all previous moves and then look for patterns in order to defy attacks. Am I going in a right direction? Any ideas?","Where might be some potential profit in trying to figure out the strategies of the other bots, for instance, if it's a forced participation, there will be some lazy student who makes up a bot that would always throw up scissors. I propose another strategy (I've heard about it on some similar competition, but can't track the source anymore), suppose that you could let several bots running (if not, cooperate with some of your classmates to run this strategy). Let's say you have 4 bots A,B,C,D Imagine each bot play 100 times against the others. Let your B,C,D bots play for the first let's say 10 times play a strategy that would let recognise it as a bot from your team, say 'RPPSPPSSRS', let your A bot play some other strategy that would let it be recognized by the bots B,C,D. Then, in the next 90 round let the bots B,C,D lose ('paper') to the A and play random against the others. Let the bot A win ('scissors') from the B,C,D and play random against the others. Thus, the bot A gets a huge advantage.",0.0,False,2,1620 +2012-01-11 22:33:12.303,Rock paper Scissors bot algorithm,"In my school our teacher is holding a Rock, paper, scissors bot competition. I know how to program in Python, but I have no idea how to program a bot that would have a bigger chance of success than one that randomly selects its weapons. I think it is possible to store all previous moves and then look for patterns in order to defy attacks. Am I going in a right direction? Any ideas?","It is proven for rock-paper-scissors that a random bot will be at the median of each rank. +Therefore, I'd create a set of bots, each calculating one heuristic and running on the background on parallel. For each turn, each bot will virtually ""draw"" and check if he had won or lost - if it would have played this turn. Each bot will keep track on how many games it would have won if it played, and how many it would have lost. +One of these bots will be the random attacker. +Each time it is your turn: choose which bot won so far the most [greedy] - and use it. +Using this approach you are guaranteed to be at the top median of your class! [with enough rounds of games of course]",1.2,True,2,1620 2012-01-12 18:15:21.740,OpenCV Lip Segmentation,"How do people usually extract the shape of the lips once the mouth region is found (in my case using haar cascade)? I tried color segmentation and edge/corner detection but they're very inaccurate for me. I need to find the two corners and the very upper and lower lip at the center. I've heard things about active appearance models but I'm having trouble understanding how to use this with python and I don't have enough context to figure out if this is even the conventional method for detecting different parts of the lips. Is that my best choice or do I have other options? If I should use it, how would I get started with it using python and simplecv?","The color segementation involves ""gradient of the difference between the pseudo-hue and luminance (obtaining hybrid contours)"". Try googling for qouted string and you will find multiple research papers on this topic.",0.0,False,1,1621 2012-01-13 03:15:46.143,How can i do replace a child element(s) in ElementTree,"I want to replace child elements from one tree to another , based on some criteria. I can do this using Comprehension ? But how do we replace element in ElementTree?","You can't replace an element from the ElementTree you can only work with Element. Even when you call ElementTree.find() it's just a shortcut for getroot().find(). @@ -17628,6 +17628,9 @@ in the new window you can remove software, or revert some installation/configura Hope this help you",0.0,False,1,1629 2012-01-17 01:19:27.970,Match a line with multiple regex using Python,"Is there a way to see if a line contains words that matches a set of regex pattern? If I have [regex1, regex2, regex3], and I want to see if a line matches any of those, how would I do this? +Right now, I am using re.findall(regex1, line), but it only matches 1 regex at a time.",Try this new regex: (regex1)|(regex2)|(regex3). This will match a line with any of the 3 regexs in it.,0.6133572603953825,False,2,1630 +2012-01-17 01:19:27.970,Match a line with multiple regex using Python,"Is there a way to see if a line contains words that matches a set of regex pattern? +If I have [regex1, regex2, regex3], and I want to see if a line matches any of those, how would I do this? Right now, I am using re.findall(regex1, line), but it only matches 1 regex at a time.","You can use the built in functions any (or all if all regexes have to match) and a Generator expression to cycle through all the regex objects. any (regex.match(line) for regex in [regex1, regex2, regex3]) (or any(re.match(regex_str, line) for regex in [regex_str1, regex_str2, regex_str2]) if the regexes are not pre-compiled regex objects, of course) @@ -17635,9 +17638,6 @@ However, that will be inefficient compared to combining your regexes in a single A simple way to combine all the regexes is to use the string join method: re.match(""|"".join([regex_str1, regex_str2, regex_str2]), line) A warning about combining the regexes in this way: It can result in wrong expressions if the original ones already do make use of the | operator.",1.2,True,2,1630 -2012-01-17 01:19:27.970,Match a line with multiple regex using Python,"Is there a way to see if a line contains words that matches a set of regex pattern? -If I have [regex1, regex2, regex3], and I want to see if a line matches any of those, how would I do this? -Right now, I am using re.findall(regex1, line), but it only matches 1 regex at a time.",Try this new regex: (regex1)|(regex2)|(regex3). This will match a line with any of the 3 regexs in it.,0.6133572603953825,False,2,1630 2012-01-18 06:48:57.963,how to make a lot of parameters available to the entire system?,"I have objects from various classes that work together to perform a certain task. The task requires a lot of parameters, provided by the user (through a configuration file). The parameters are used deep inside the system. I have a choice of having the controller object read the configuration file, and then allocate the parameters as appropriate to the next layer of objects, and so on in each layer. But the only objects themselves know which parameters they need, so the controller object would need to learn a lot of detail about every other object. The other choice is to bundle all the parameters into a collection, and pass the whole collection into every function call (equivalently, create a global object that stores them, and is accessible to everyone). This looks and feels ugly, and would cause a variety of minor technical issues (e.g., I can't allow two objects to use parameters with the same name; etc.) @@ -17652,9 +17652,9 @@ if what is in the cell is a string i get something like text:u'MyName' and i onl if what is in the cell is a number i get something like number:201.0 and i only want to keep the integer 201. If anyone can indicate me what i should to only extract the value, formatted as i want, thank you.",The correct answer to this is to simply use the Cell.value function. This will return a number or a Unicode string depending on what the cell contains.,0.0,False,1,1632 +2012-01-18 15:03:16.873,How to make a gui in python,"I was wondering if any of you know where I could find a simple tutorial on the web maybe to make a very simplistic gui. I have no idea how to start out in code to make one so I need your help. What I want the gui to be used for is I have written a program that I want to be to use it on other computers that already don't have python on it. I have already made an executable but I would much rather use a gui just because of the more ""polished"" look it has.",If you're more into gaming you can use PyGame for GUIs.,0.0407936753323291,False,2,1633 2012-01-18 15:03:16.873,How to make a gui in python,"I was wondering if any of you know where I could find a simple tutorial on the web maybe to make a very simplistic gui. I have no idea how to start out in code to make one so I need your help. What I want the gui to be used for is I have written a program that I want to be to use it on other computers that already don't have python on it. I have already made an executable but I would much rather use a gui just because of the more ""polished"" look it has.","While some suggestions have included tkinter and wxPython, the other part of the answer to your question is that you will also need to package it using something like py2app, pyinstaller, or py2exe (depending on the operating system). You mentioned the other machines do not have python, so this would be required in order to distribute the entire python environment with your app. Also have a look at PySide or PyQt. They have a ton of tutorials everywhere and heavy documentation from Qt.",0.0,False,2,1633 -2012-01-18 15:03:16.873,How to make a gui in python,"I was wondering if any of you know where I could find a simple tutorial on the web maybe to make a very simplistic gui. I have no idea how to start out in code to make one so I need your help. What I want the gui to be used for is I have written a program that I want to be to use it on other computers that already don't have python on it. I have already made an executable but I would much rather use a gui just because of the more ""polished"" look it has.",If you're more into gaming you can use PyGame for GUIs.,0.0407936753323291,False,2,1633 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -17684,11 +17684,13 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>","if .\venv\Scripts\activate does not work neither and you find this error -\Activate.ps1 cannot be loaded because running scripts is disabled on this system -you can simple type set-executionpolicy remotesigned in powershell and the error must be gone. - -powershell should run as administrator",0.0,False,17,1634 +c:\testdjangoproj\mysite>","Open your powershell as admin +Enter ""Set-ExecutionPolicy RemoteSigned -Force +Run ""gpedit.msc"" and go to >Administrative Templates>Windows Components>Windows Powershell +Look for ""Activate scripts execution"" and set it on ""Activated"" +Set execution directive to ""Allow All"" +Apply +Refresh your env",0.0479823334210096,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -17718,9 +17720,9 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>","Some people are having trouble with vscode i assume as all the above methods dont work. -Its simply because by default vscode uses powershell not cmd... -click on the little arrow beside it and select cmd and run the command.",-0.012004225262257,False,17,1634 +c:\testdjangoproj\mysite>","If some beginner, like me, has followed multiple Python tutorials now possible has multiple Python versions and/or multiple versions of pip/virtualenv/pipenv... +In that case, answers listed, while many correct, might not help. +The first thing I would try in your place is uninstall and reinstall Python and go from there.",0.0,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -17750,10 +17752,9 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>","It's been a while without usign Django, so when I got back to my old project I run into the same issue on Windows 10 -and this worked for me: - -venv/Scripts/activate",0.0,False,17,1634 +c:\testdjangoproj\mysite>","I have a hell of a time using virtualenv on windows with git bash, I usually end up specifying the python binary explicitly. +If my environment is in say .env I'll call python via ./.env/Scripts/python.exe …, or in a shebang line #!./.env/Scripts/python.exe; +Both assuming your working directory contains your virtualenv (.env).",0.0240049913710709,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -17783,7 +17784,14 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>",Use These it worked for meenv\Scripts\activate,0.0,False,17,1634 +c:\testdjangoproj\mysite>","For activation you can go to the venv your virtualenv directory +by cd venv. +Then on Windows, type dir (on unix, type ls). +You will get 5 folders include, Lib, Scripts, tcl and 60 +Now type .\Scripts\activate to activate your virtualenv venv. + +Your prompt will change to indicate that you are now operating within the virtual environment. It will look something like this (venv)user@host:~/venv$. +And your venv is activated now.",0.246892465020296,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -17813,10 +17821,7 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>","The steps for activating virtualenv using Python3 on windows are: - -python3 -m venv env -.\env\bin\activate",0.012004225262257,False,17,1634 +c:\testdjangoproj\mysite>",You can run the source command on cygwin terminal,0.0240049913710709,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -17846,8 +17851,7 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>","For windows Microsoft Tech Support it might be a problem with Execution Policy Settings. To fix it, you should try executing -Set-ExecutionPolicy Unrestricted -Scope Process",0.0240049913710709,False,17,1634 +c:\testdjangoproj\mysite>","If you’re using Windows, use the command ""venv\Scripts\activate"" (without the word source) to activate the virtual environment. If you’re using PowerShell, you might need to capitalize Activate.",0.0,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -17877,7 +17881,10 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>","If you are using windows, just run .\Scripts\activate. Mind that the backslash plays the trick!",0.0,False,17,1634 +c:\testdjangoproj\mysite>","Open your project using VS code editor . +Change the default shell in vs code terminal to git bash. +now your project is open with bash console and right path, put +""source venv\Scripts\activate"" in Windows",0.0,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -17907,13 +17914,7 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>","Open your powershell as admin -Enter ""Set-ExecutionPolicy RemoteSigned -Force -Run ""gpedit.msc"" and go to >Administrative Templates>Windows Components>Windows Powershell -Look for ""Activate scripts execution"" and set it on ""Activated"" -Set execution directive to ""Allow All"" -Apply -Refresh your env",0.0479823334210096,False,17,1634 +c:\testdjangoproj\mysite>",If you are using windows OS then in Gitbash terminal use the following command $source venv/Scripts/activate. This will help you to enter the virtual environment.,0.0,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -17943,7 +17944,12 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>","If you see the 5 folders (Include,Lib,Scripts,tcl,pip-selfcheck) after using the virtualenv yourenvname command, change directory to Scripts folder in the cmd itself and simply use ""activate"" command.",0.012004225262257,False,17,1634 +c:\testdjangoproj\mysite>","Navigate to your virtualenv folder eg ..\project1_env> +Then type + +source scripts/activate + +eg ..\project1_env>source scripts/activate",0.0,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -17973,12 +17979,11 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>","Navigate to your virtualenv folder eg ..\project1_env> -Then type - -source scripts/activate +c:\testdjangoproj\mysite>","if .\venv\Scripts\activate does not work neither and you find this error +\Activate.ps1 cannot be loaded because running scripts is disabled on this system +you can simple type set-executionpolicy remotesigned in powershell and the error must be gone. -eg ..\project1_env>source scripts/activate",0.0,False,17,1634 +powershell should run as administrator",0.0,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -18008,10 +18013,7 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>","Open your project using VS code editor . -Change the default shell in vs code terminal to git bash. -now your project is open with bash console and right path, put -""source venv\Scripts\activate"" in Windows",0.0,False,17,1634 +c:\testdjangoproj\mysite>",Use These it worked for meenv\Scripts\activate,0.0,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -18041,7 +18043,9 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>",If you are using windows OS then in Gitbash terminal use the following command $source venv/Scripts/activate. This will help you to enter the virtual environment.,0.0,False,17,1634 +c:\testdjangoproj\mysite>","Some people are having trouble with vscode i assume as all the above methods dont work. +Its simply because by default vscode uses powershell not cmd... +click on the little arrow beside it and select cmd and run the command.",-0.012004225262257,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -18071,7 +18075,10 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>","If you’re using Windows, use the command ""venv\Scripts\activate"" (without the word source) to activate the virtual environment. If you’re using PowerShell, you might need to capitalize Activate.",0.0,False,17,1634 +c:\testdjangoproj\mysite>","It's been a while without usign Django, so when I got back to my old project I run into the same issue on Windows 10 +and this worked for me: + +venv/Scripts/activate",0.0,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -18101,7 +18108,7 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>",You can run the source command on cygwin terminal,0.0240049913710709,False,17,1634 +c:\testdjangoproj\mysite>","If you see the 5 folders (Include,Lib,Scripts,tcl,pip-selfcheck) after using the virtualenv yourenvname command, change directory to Scripts folder in the cmd itself and simply use ""activate"" command.",0.012004225262257,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -18131,14 +18138,10 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>","For activation you can go to the venv your virtualenv directory -by cd venv. -Then on Windows, type dir (on unix, type ls). -You will get 5 folders include, Lib, Scripts, tcl and 60 -Now type .\Scripts\activate to activate your virtualenv venv. +c:\testdjangoproj\mysite>","The steps for activating virtualenv using Python3 on windows are: -Your prompt will change to indicate that you are now operating within the virtual environment. It will look something like this (venv)user@host:~/venv$. -And your venv is activated now.",0.246892465020296,False,17,1634 +python3 -m venv env +.\env\bin\activate",0.012004225262257,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -18168,9 +18171,8 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>","I have a hell of a time using virtualenv on windows with git bash, I usually end up specifying the python binary explicitly. -If my environment is in say .env I'll call python via ./.env/Scripts/python.exe …, or in a shebang line #!./.env/Scripts/python.exe; -Both assuming your working directory contains your virtualenv (.env).",0.0240049913710709,False,17,1634 +c:\testdjangoproj\mysite>","For windows Microsoft Tech Support it might be a problem with Execution Policy Settings. To fix it, you should try executing +Set-ExecutionPolicy Unrestricted -Scope Process",0.0240049913710709,False,17,1634 2012-01-19 04:54:37.953,Issue with virtualenv - cannot activate,"I created a virtualenv around my project, but when I try to activate it I cannot. It might just be syntax or folder location, but I am stumped right now. You can see below, I create the virtualenv and call it venv. Everything looks good, then I try to activate it by running source venv/bin/activate @@ -18200,9 +18202,7 @@ c:\testdjangoproj\mysite>source mysite/bin/activate 'source' is not recognized as an internal or external command, operable program or batch file. -c:\testdjangoproj\mysite>","If some beginner, like me, has followed multiple Python tutorials now possible has multiple Python versions and/or multiple versions of pip/virtualenv/pipenv... -In that case, answers listed, while many correct, might not help. -The first thing I would try in your place is uninstall and reinstall Python and go from there.",0.0,False,17,1634 +c:\testdjangoproj\mysite>","If you are using windows, just run .\Scripts\activate. Mind that the backslash plays the trick!",0.0,False,17,1634 2012-01-20 00:08:55.353,Sending 'secure' financial statements on S3,"I need to provide individuals with their financial statement, and I am using S3. So far what I am doing is making the file public-read and creating a unique Key, using uuid.uuid4(). Would this be acceptable, or how else could I make this more secure? Sending authentication keys for each individual is not an option.","Even though version 4 UUIDs are supposed to incorporate random data, I wouldn't want to rely on the fact that the RNG used by Python's uuid.uuid4() being securely random. The Python docs make no mention about the quality of the randomness, so I'd be afraid that you might end up with guessable UUID's. I'm not a crypto expert, so I won't suggest a specific alternative, but I would suggest using something that is designed to produce crypto-quailty random data, and transform that into something that can be used as an S3 key (I'm not sure what the requirements on S3 key data might be, but I'd guess they're supposed to be something like a filename). @@ -18219,6 +18219,10 @@ Note that numpy uses the famous (and well-optimized) BLAS libraries, so it is al 2012-01-22 19:31:36.067,Get away from an object in a 2D-grid,"I'm developing a small game in python. I am using a 2D rectangular grid. I know that for pathfinding I can use A* and the likes, I know how this works, but the problem I have is a bit different. Let's say we have a computer controlled human and some computer controlled zombies. When the human spots a zombie, it should get away from this as far as he can. At the moment, to test everything I just turn around 180° and run away, until I spot another zombie and repeat. Obviously this is not very smart (and can cause problems if there is a zombie on both sides). +I was wondering if there was a smarter way to do this? Something like using Dijkstra to find a ""safe zone"" where I can run to? Alternatives are always welcome, I can't seem to figure it out.","You could suppose that the zombies can see everything within a particular range (radius or perhaps be more clever) and then have the human look for a spot that he thinks the zombies can't see. Pick the closest spot the zombie can't see and use the A* algorithm to find a path if one exists, else try a different one. Look out when there's nowhere to run. Alternatively you could weight all of the spots in your visibility region with a value based on how far away you would be from the zombies if you chose that spot.",1.2,True,2,1637 +2012-01-22 19:31:36.067,Get away from an object in a 2D-grid,"I'm developing a small game in python. I am using a 2D rectangular grid. I know that for pathfinding I can use A* and the likes, I know how this works, but the problem I have is a bit different. +Let's say we have a computer controlled human and some computer controlled zombies. When the human spots a zombie, it should get away from this as far as he can. At the moment, to test everything I just turn around 180° and run away, until I spot another zombie and repeat. +Obviously this is not very smart (and can cause problems if there is a zombie on both sides). I was wondering if there was a smarter way to do this? Something like using Dijkstra to find a ""safe zone"" where I can run to? Alternatives are always welcome, I can't seem to figure it out.","Just off the top of my head, you'll probably be able to do some vector math and have the human run in the normal vector to the zombies. I don't know how well this will work (or how it will scale to the number of zombies you have), but you could do something like: @@ -18228,10 +18232,6 @@ Find the sum of all the vectors. Make the human run in the normal vector to your result. I'm not sure how resource intensive this would be, but it seems like the most logical way to prioritize where to run.",0.0,False,2,1637 -2012-01-22 19:31:36.067,Get away from an object in a 2D-grid,"I'm developing a small game in python. I am using a 2D rectangular grid. I know that for pathfinding I can use A* and the likes, I know how this works, but the problem I have is a bit different. -Let's say we have a computer controlled human and some computer controlled zombies. When the human spots a zombie, it should get away from this as far as he can. At the moment, to test everything I just turn around 180° and run away, until I spot another zombie and repeat. -Obviously this is not very smart (and can cause problems if there is a zombie on both sides). -I was wondering if there was a smarter way to do this? Something like using Dijkstra to find a ""safe zone"" where I can run to? Alternatives are always welcome, I can't seem to figure it out.","You could suppose that the zombies can see everything within a particular range (radius or perhaps be more clever) and then have the human look for a spot that he thinks the zombies can't see. Pick the closest spot the zombie can't see and use the A* algorithm to find a path if one exists, else try a different one. Look out when there's nowhere to run. Alternatively you could weight all of the spots in your visibility region with a value based on how far away you would be from the zombies if you chose that spot.",1.2,True,2,1637 2012-01-23 08:35:01.870,Python serialization - Why pickle?,"I understood that Python pickling is a way to 'store' a Python Object in a way that does respect Object programming - different from an output written in txt file or DB. Do you have more details or references on the following points: @@ -18260,10 +18260,10 @@ While I see how to do this for registered members, I'm not sure how to do this w Maybe a better way would be to append access rights to users sessions using cookies? Can route factories help me for this purpose? Any other way?","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. Route factories will allow you to assign custom ACLs to individual routes. They simply override the default root factory on the Configurator.",1.2,True,1,1640 -2012-01-24 15:22:25.107,ctypes - does python need to be compiled with same version as C library?,"I'm running into some really weird problems with ctypes. I'm using ctypes to interface to a C++ library that has a C interface. The library has lots of parallel functionality. More often than not, the parallel calls tend to end up with a segfault from the C++ layer, but I've run into them with some serial code too. I'm wondering if there is any restriction on whether the Python interpreter and the C++ code need to be compiled with the same version of the C++ compiler? If so, how do I find out what c++ was used to build Python? I've tried to run strings on Python and grep for gcc and g++, nothing shows up.","CPython doesn't contain C++ code and thus there is no requirement with regards to the C++ compiler used to compile a C++ library loaded into a CPython process. However, the C layer and the C++ library must generally be compiled with the same C++ compiler. And if the C++ library or the C layer link against libpython, they must be compiled against the same version of CPython that is later used to run the ctypes code that loads the library.",0.0,False,2,1641 2012-01-24 15:22:25.107,ctypes - does python need to be compiled with same version as C library?,"I'm running into some really weird problems with ctypes. I'm using ctypes to interface to a C++ library that has a C interface. The library has lots of parallel functionality. More often than not, the parallel calls tend to end up with a segfault from the C++ layer, but I've run into them with some serial code too. I'm wondering if there is any restriction on whether the Python interpreter and the C++ code need to be compiled with the same version of the C++ compiler? If so, how do I find out what c++ was used to build Python? I've tried to run strings on Python and grep for gcc and g++, nothing shows up.","There's no requirement at all that the native library that you call with ctypes has to be built with a matching runtime. In fact there's not even a requirement that the native library even uses a C runtime. For example you can use ctypes to call code written in other languages, e.g. Delphi. Or you can use ctypes to call Windows API functions which are not linked against MSVC. I guess you'll have to look elsewhere to resolve your problem!",1.2,True,2,1641 +2012-01-24 15:22:25.107,ctypes - does python need to be compiled with same version as C library?,"I'm running into some really weird problems with ctypes. I'm using ctypes to interface to a C++ library that has a C interface. The library has lots of parallel functionality. More often than not, the parallel calls tend to end up with a segfault from the C++ layer, but I've run into them with some serial code too. I'm wondering if there is any restriction on whether the Python interpreter and the C++ code need to be compiled with the same version of the C++ compiler? If so, how do I find out what c++ was used to build Python? I've tried to run strings on Python and grep for gcc and g++, nothing shows up.","CPython doesn't contain C++ code and thus there is no requirement with regards to the C++ compiler used to compile a C++ library loaded into a CPython process. However, the C layer and the C++ library must generally be compiled with the same C++ compiler. And if the C++ library or the C layer link against libpython, they must be compiled against the same version of CPython that is later used to run the ctypes code that loads the library.",0.0,False,2,1641 2012-01-25 07:16:21.320,Bug output feature class,"I just encounter a little bug, maybe someone can help me. I'm creating Thiessen Polygons. I define my shapefile in Input Features, and in Output Feature Class, then I have to possibilities either keep the default file or save my output where I want. @@ -18281,17 +18281,17 @@ I did use APScheduler to fire requests in the separate threads. Thanks to your a i am using matplotlib to analyze a large dataset. What i have now is a distribution of x,y points. I want to find out the cases in which the x values of my function are the same, but y differs the greatest. So if i plot it, one part of the cases is at the top of my graph, the other is the botton of the graph. So how do i get the points(x,y), (x,y') where f(x)=y and f(x)=y' and y-y'=max ? cheers","I think what you want is a variance plot. Create a dictionary for distinct x values. Put each distinct value of y in a list associated with each x. Find the stdev (np.std) of the list associated with each x say ""s"". Plot the s vs. x.",0.2012947653214861,False,1,1644 -2012-01-27 01:25:23.073,How to register an event for when a user has a new tweet?,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?,I don't think there is any event based pub-sub exposed by twitter. You just have to do the long polling.,0.1352210990936997,False,2,1645 2012-01-27 01:25:23.073,How to register an event for when a user has a new tweet?,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?,I used the .filter function then filtered for the user I was looking for.,1.2,True,2,1645 -2012-01-27 14:31:02.807,"Python run .py in separate windows (Windows 7, Python 2.6.6 64-bit)","I have no idea why python run every script in a new command window. -For example I run: python testfile.py, it is show new window and close immediately, so I can't look the traceback. -Python 2.7 32-bit at the same machine works normally",Did you try adding raw_input() at the end of testfile.py ?,0.0,False,2,1646 +2012-01-27 01:25:23.073,How to register an event for when a user has a new tweet?,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?,I don't think there is any event based pub-sub exposed by twitter. You just have to do the long polling.,0.1352210990936997,False,2,1645 2012-01-27 14:31:02.807,"Python run .py in separate windows (Windows 7, Python 2.6.6 64-bit)","I have no idea why python run every script in a new command window. For example I run: python testfile.py, it is show new window and close immediately, so I can't look the traceback. Python 2.7 32-bit at the same machine works normally","You can run it through IDLE, the built-in editor. It may not be much helpful if you have to provide command-line args. An alternate option may be making the code wait for a keypress using raw_input(), as Insidi0us said. You can also print the errors to a file. Another option may be running the command prompt first, then run python command (make sure your environment variable contains the python installation directory).",0.0,False,2,1646 +2012-01-27 14:31:02.807,"Python run .py in separate windows (Windows 7, Python 2.6.6 64-bit)","I have no idea why python run every script in a new command window. +For example I run: python testfile.py, it is show new window and close immediately, so I can't look the traceback. +Python 2.7 32-bit at the same machine works normally",Did you try adding raw_input() at the end of testfile.py ?,0.0,False,2,1646 2012-01-27 16:26:04.283,OpenOPC using Python,"I am trying to do some stuff with siemens PLC using OPENOPC using python. I am wondering how I will get OPC server that I can communicate using PYOPC. Is there any open OPC server available or am I not understanding some of the key concepts here? Since I am a newbie, I hope to get some down-to-earth suggestions.","You can install some tryout opc servers. google opc simulation. The python OpenOPC client is what i try to use. My problems was that I did not have a plc on my desk. You need a plc on your desk connected to your actual siemens s7 engineering station to have the siemens opc server show the tags in the plc.",1.2,True,1,1647 2012-01-27 18:52:38.700,How to import a java class i created in jython and call a method,"I have made a java class that calls other java classes and then prints to a screen. i am trying to build a python interface that calls my java class, runs the one method within it, and terminates. i cannot get access to my method. i have used the line ""import directory.directory2.myClass.java (and .jar and .class) i made the .jar file from both the raw code and from the .class file. none of these seem to be working. i set sys.path.append to point to the directory where the java files are. Do i need to convert my java class file to a python module? and if so how do i do that?","Jython supports loading Java classes as if they were Python modules. It searches the directories in sys.path for .class files. @@ -18410,6 +18410,10 @@ Estimate Honestly: Study your own previous efforts to learn how long it takes yo 2012-02-07 23:09:05.063,"In Python, what's the method for returning only the max odd integer in a list?","If you have a list of numbers, how do you return only the max odd integer without using the max() function? I'm assuming it will have something to do with int % 2 != 0, but I'm not sure what else. +I also have to return the overall max integer without using max(), but I got around that by sorting my list and using list[-1].",Have a look at 'filter' built-in function,0.0582430451621389,False,3,1662 +2012-02-07 23:09:05.063,"In Python, what's the method for returning only the max odd integer in a list?","If you have a list of numbers, how do you return only the max odd integer without using the max() function? +I'm assuming it will have something to do with int % 2 != 0, but I'm not sure what else. + I also have to return the overall max integer without using max(), but I got around that by sorting my list and using list[-1].","numbers = [] while True: try: @@ -18428,10 +18432,6 @@ else: 2012-02-07 23:09:05.063,"In Python, what's the method for returning only the max odd integer in a list?","If you have a list of numbers, how do you return only the max odd integer without using the max() function? I'm assuming it will have something to do with int % 2 != 0, but I'm not sure what else. -I also have to return the overall max integer without using max(), but I got around that by sorting my list and using list[-1].",Have a look at 'filter' built-in function,0.0582430451621389,False,3,1662 -2012-02-07 23:09:05.063,"In Python, what's the method for returning only the max odd integer in a list?","If you have a list of numbers, how do you return only the max odd integer without using the max() function? -I'm assuming it will have something to do with int % 2 != 0, but I'm not sure what else. - I also have to return the overall max integer without using max(), but I got around that by sorting my list and using list[-1].","The easiest approach is to separate the problem into subproblems. You can safely ignore every even number, so you have to be able to identify even numbers, you have to ignore numbers that satisfy the condition of being even and on the result - a list of odd numbers - you just have to find the highest number. So, find or implement... @@ -18443,18 +18443,18 @@ Once you've done that you just have to combine the three functions.",0.0,False,3 2012-02-08 03:42:51.433,Cloud Computing Passing a Function to Server,"Let's say I had a cloud cluster with Python or C or something and I want to execute my function (as a client) in the cloud. How could I possibly pass the function I wrote locally up to the server? I've seen this elsewhere and I not only don't know how to do it but I want to see if there are many ideas for it. Thanks, -Anthony Hurst","One of the most popular systems for processing large amounts of data in a cluster is Hadoop (http://hadoop.apache.org/) -You can write functions in python using the MapReduce programming pattern (google it), upload your program to the cluster, and it will process your data. -Take a look and read up. It's a huge topic - too much for one question. If you have some specific use cases please edit your question with more info.",0.1352210990936997,False,3,1663 -2012-02-08 03:42:51.433,Cloud Computing Passing a Function to Server,"Let's say I had a cloud cluster with Python or C or something and I want to execute my function (as a client) in the cloud. How could I possibly pass the function I wrote locally up to the server? -I've seen this elsewhere and I not only don't know how to do it but I want to see if there are many ideas for it. -Thanks, Anthony Hurst","Well if you wrote it locally you probably wont be executing anything that require compilation in realtime (I assume your looking for efficiency and will be exchanging a whole series of computations in the cloud) which in that case you looking to send it something like a ruby file on the fly? But that doesn't seem very practical since you really aren't going to get this newly written function coming from the client side sent over and scaled well across the cluster you are sending it to. That being said, set something up where you can send functions perimeters in the form of xml, json, etc. Use an http connection or an https if you need it secure and build it using hadoop, mpi, et.",0.0,False,3,1663 2012-02-08 03:42:51.433,Cloud Computing Passing a Function to Server,"Let's say I had a cloud cluster with Python or C or something and I want to execute my function (as a client) in the cloud. How could I possibly pass the function I wrote locally up to the server? I've seen this elsewhere and I not only don't know how to do it but I want to see if there are many ideas for it. Thanks, +Anthony Hurst","One of the most popular systems for processing large amounts of data in a cluster is Hadoop (http://hadoop.apache.org/) +You can write functions in python using the MapReduce programming pattern (google it), upload your program to the cluster, and it will process your data. +Take a look and read up. It's a huge topic - too much for one question. If you have some specific use cases please edit your question with more info.",0.1352210990936997,False,3,1663 +2012-02-08 03:42:51.433,Cloud Computing Passing a Function to Server,"Let's say I had a cloud cluster with Python or C or something and I want to execute my function (as a client) in the cloud. How could I possibly pass the function I wrote locally up to the server? +I've seen this elsewhere and I not only don't know how to do it but I want to see if there are many ideas for it. +Thanks, Anthony Hurst","Code mobility is a largely unexplored field with more questions than answers. Generally you cannot move arbitrary code around at runtime. There are a few programming languages that historically supported code mobility (e.g. Kali Scheme), but it is not something that would be ready for main stream use. Concerning functions, here I am not quite sure what you are asking. There are functional programming languages that support what I would consider ""precursors"" to code mobility. E.g. in Erlang you can pass function signatures around and in Cloud Haskell you can send a Closure (that is a function with collocated data) within certain limitations. Other approaches that have reached higher significance are to craft plug-ins, that is precompiled binaries that are loaded at runtime. There might be further possibilities to pass object code around so that not everything has to be compiled and linked at runtime when it is passed from one platform to an other. @@ -18533,8 +18533,11 @@ Note that projects are not shared across workspaces, so if you create a new work 2012-02-12 21:43:27.323,How do set Python path to run Django with WSGI and Apache?,"The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. Now, how do I specify for Apache/WSGI to use Python 2.7 to run the Django project? [edit] -I can't update Python 2.4 because CentOS depends on that version of Python. Unless there is a safe way of updating without breaking a service such as yum","You need to build mod_wsgi against python 2.7 and load this module into apache instead of the current mod_wsgi version you are using that links against python 2.4. -This requires root access to the machine.",1.2,True,3,1676 +I can't update Python 2.4 because CentOS depends on that version of Python. Unless there is a safe way of updating without breaking a service such as yum","""You got peanut butter on my chocolate!"" +""You got chocolate in my peanut butter!"" +Two great tastes that go together. +As Thiefmaster says, you need to use the correct version of wsgi. As Alex says, you need to run in a virtualenv for the later python so that you don't mess up everything else. +Install all your python stuff, including your preferred Django, into your virtualenv and everything will be good.",0.0,False,3,1676 2012-02-12 21:43:27.323,How do set Python path to run Django with WSGI and Apache?,"The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. Now, how do I specify for Apache/WSGI to use Python 2.7 to run the Django project? [edit] @@ -18543,17 +18546,14 @@ I've installed django on Centos 5 with Apache+mod_wsgi and Cherokee+uwsgi (I pre 2012-02-12 21:43:27.323,How do set Python path to run Django with WSGI and Apache?,"The default Python on the server is 2.4, but Django needs version 2.5 or higher. So I installed Python 2.7 in different directory and trying to run Apache with WSGI. Now, how do I specify for Apache/WSGI to use Python 2.7 to run the Django project? [edit] -I can't update Python 2.4 because CentOS depends on that version of Python. Unless there is a safe way of updating without breaking a service such as yum","""You got peanut butter on my chocolate!"" -""You got chocolate in my peanut butter!"" -Two great tastes that go together. -As Thiefmaster says, you need to use the correct version of wsgi. As Alex says, you need to run in a virtualenv for the later python so that you don't mess up everything else. -Install all your python stuff, including your preferred Django, into your virtualenv and everything will be good.",0.0,False,3,1676 +I can't update Python 2.4 because CentOS depends on that version of Python. Unless there is a safe way of updating without breaking a service such as yum","You need to build mod_wsgi against python 2.7 and load this module into apache instead of the current mod_wsgi version you are using that links against python 2.4. +This requires root access to the machine.",1.2,True,3,1676 +2012-02-13 21:53:30.813,Similarities between tcl and Python,"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.","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.",1.2,True,2,1677 2012-02-13 21:53:30.813,Similarities between tcl and Python,"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.","While this question will obviously be closed as inconstructive in a short time, I'll leave my answer here anyway. Joe, 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. I 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. Tcl 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. So my opinion is that your premises are wrong. Hope I was able to explain why.",0.9866142981514304,False,2,1677 -2012-02-13 21:53:30.813,Similarities between tcl and Python,"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.","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.",1.2,True,2,1677 2012-02-14 18:19:12.757,Run a python script in windows,"I have always used a mac to write and run python scripts. However, I have a bunch of files on a PC that I need to run a script on. I have never really used a PC and don't know how to run the script. If I go to the command program on the PC and type in python, nothing happens. How do I find where the python path is in order to get into the python prompt? Also, once I am in the prompt, is the importing of modules the same as in a Unix system?","Assuming Python is installed, it is usually placed in a folder prefixed with ""Python"" and the major/minor version. E.g. C:\Python26",0.2012947653214861,False,1,1678 2012-02-15 05:16:50.257,NLTK certainty measure?,"In NLTK, if I write a NaiveBayes classifier for say movie reviews (determining if positive or negative), how can I determine the classifier ""certainty"" when classify a particular review? That is, I know how to run an 'accuracy' test on a given test set to see the general accuracy of the classifier. But is there anyway to have NLTk output its certainess? (perhaps on the basis on the most informative features...) @@ -18569,21 +18569,21 @@ If not, is there a performance loss for me putting the project there? I 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/ but 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. There are surely lots of python projects installed in Ubuntu ( and obviously other distros ) how do they deal with this? -Thanks","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. -This 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). -What 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. -Note 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.",0.2012947653214861,False,2,1680 +Thanks",".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.",0.2012947653214861,False,2,1680 2012-02-15 08:27:53.213,Out of home folder .pyc files?,"If I place my project in /usr/bin/ will 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? If not, is there a performance loss for me putting the project there? I 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/ but 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. There are surely lots of python projects installed in Ubuntu ( and obviously other distros ) how do they deal with this? -Thanks",".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.",0.2012947653214861,False,2,1680 -2012-02-15 16:57:27.377,2d random walk in python - drawing hypotenuse from distribution,"I'm writing a simple 2d brownian motion simulator in Python. It's obviously easy to draw values for x displacement and y displacement from a distribution, but I have to set it up so that the 2d displacement (ie hypotenuse) is drawn from a distribution, and then translate this to new x and y coordinates. This is probably trivial and I'm just too far removed from trigonometry to remember how to do it correctly. Am I going to need to generate a value for the hypotenuse and then translate it into x and y displacements with sin and cos? (How do you do this correctly?)","If you have a hypotenuse in the form of a line segment, then you have two points. From two points in the form P0 = (x0, y0) P1 = (x1, y1) you can get the x and y displacements by subtracting x0 from x1 and y0 from y1. -If your hypotenuse is actually a vector in a polar coordinate plane, then yes, you'll have to take the sin of the angle and multiply it by the magnitude of the vector to get the y displacement and likewise with cos for the x displacement.",0.0,False,2,1681 +Thanks","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. +This 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). +What 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. +Note 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.",0.2012947653214861,False,2,1680 2012-02-15 16:57:27.377,2d random walk in python - drawing hypotenuse from distribution,"I'm writing a simple 2d brownian motion simulator in Python. It's obviously easy to draw values for x displacement and y displacement from a distribution, but I have to set it up so that the 2d displacement (ie hypotenuse) is drawn from a distribution, and then translate this to new x and y coordinates. This is probably trivial and I'm just too far removed from trigonometry to remember how to do it correctly. Am I going to need to generate a value for the hypotenuse and then translate it into x and y displacements with sin and cos? (How do you do this correctly?)","This is best done by using polar coordinates (r, theta) for your distributions (where r is your ""hypotenuse"")), and then converting the result to (x, y), using x = r cos(theta) and y = r sin(theta). That is, select r from whatever distribution you like, and then select a theta, usually from a flat, 0 to 360 deg, distribution, and then convert these values to x and y. Going the other way around (i.e., constructing correlated (x, y) distributions that gave a direction independent hypotenuse) would be very difficult.",1.2,True,2,1681 +2012-02-15 16:57:27.377,2d random walk in python - drawing hypotenuse from distribution,"I'm writing a simple 2d brownian motion simulator in Python. It's obviously easy to draw values for x displacement and y displacement from a distribution, but I have to set it up so that the 2d displacement (ie hypotenuse) is drawn from a distribution, and then translate this to new x and y coordinates. This is probably trivial and I'm just too far removed from trigonometry to remember how to do it correctly. Am I going to need to generate a value for the hypotenuse and then translate it into x and y displacements with sin and cos? (How do you do this correctly?)","If you have a hypotenuse in the form of a line segment, then you have two points. From two points in the form P0 = (x0, y0) P1 = (x1, y1) you can get the x and y displacements by subtracting x0 from x1 and y0 from y1. +If your hypotenuse is actually a vector in a polar coordinate plane, then yes, you'll have to take the sin of the angle and multiply it by the magnitude of the vector to get the y displacement and likewise with cos for the x displacement.",0.0,False,2,1681 2012-02-16 20:29:35.910,How to make __repr__ to return unicode string,"I call a __repr__() function on object x as follows: val = x.__repr__() and then I want to store val string to SQLite database. The problem is @@ -18611,10 +18611,6 @@ FYI: I want to achieve something like ideone.com or codepad.org I'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?",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.,0.2401167094949473,False,1,1683 2012-02-17 03:18:52.663,Set encoding in Python 3 CGI scripts,"When writing a Python 3.1 CGI script, I run into horrible UnicodeDecodeErrors. However, when running the script on the command line, everything works. It 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. -I 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.","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. -BTW: 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.",0.0582430451621389,False,3,1684 -2012-02-17 03:18:52.663,Set encoding in Python 3 CGI scripts,"When writing a Python 3.1 CGI script, I run into horrible UnicodeDecodeErrors. However, when running the script on the command line, everything works. -It 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. I 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.","You shouldn't read your IO streams as strings for CGI/WSGI; they aren't Unicode strings, they're explicitly byte sequences. (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...) So 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. @@ -18622,6 +18618,10 @@ Unfortunately the standard library CGI and WSGI interfaces don't get this right The 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.",0.229096917477335,False,3,1684 2012-02-17 03:18:52.663,Set encoding in Python 3 CGI scripts,"When writing a Python 3.1 CGI script, I run into horrible UnicodeDecodeErrors. However, when running the script on the command line, everything works. It 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. +I 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.","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. +BTW: 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.",0.0582430451621389,False,3,1684 +2012-02-17 03:18:52.663,Set encoding in Python 3 CGI scripts,"When writing a Python 3.1 CGI script, I run into horrible UnicodeDecodeErrors. However, when running the script on the command line, everything works. +It 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. I 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.","Summarizing @cercatrova 's answer: Add PassEnv LANG line to the end of your /etc/apache2/apache2.conf or .htaccess. @@ -18648,32 +18648,32 @@ Consider the case you return a string or an iterable normally, checking for an e 2012-02-19 07:07:27.350,Python strip with \n,"This is my problem. I'm trying to read a text file and then convert the lines into floats. The text file has \n and \t in it though I don't know how to get rid of it. I tried using line.strip() but it didn't take it off and I got an error when I wanted to convert the stuff to floats. I then tried line.strip(""\n"") but that didn't work either. My program works fine when I take out the \t and \n from the text file, but it's part of the assignment to get it to work with them. +I really don't know why this isn't working. Thanks for any help.","If you're trying to convert lines of floats separated by tab characters, then just float(line) will try to convert the whole line into one float, which will fail if there's more than one. Using strip to get rid of leading and trailing whitespace isn't going to help that fundamental problem. +Maybe you need to split each line into pieces and do something with each piece?",0.0582430451621389,False,2,1688 +2012-02-19 07:07:27.350,Python strip with \n,"This is my problem. +I'm trying to read a text file and then convert the lines into floats. The text file has \n and \t in it though I don't know how to get rid of it. +I tried using line.strip() but it didn't take it off and I got an error when I wanted to convert the stuff to floats. I then tried line.strip(""\n"") but that didn't work either. My program works fine when I take out the \t and \n from the text file, but it's part of the assignment to get it to work with them. I really don't know why this isn't working. Thanks for any help.","Often, depending on the way you read the lines, in order to get rid of \n from myline, you can take myline[:-1] since \n is the last character of myline. For the '\t' you can use replace() or strip()",0.0582430451621389,False,2,1688 -2012-02-19 07:07:27.350,Python strip with \n,"This is my problem. -I'm trying to read a text file and then convert the lines into floats. The text file has \n and \t in it though I don't know how to get rid of it. -I tried using line.strip() but it didn't take it off and I got an error when I wanted to convert the stuff to floats. I then tried line.strip(""\n"") but that didn't work either. My program works fine when I take out the \t and \n from the text file, but it's part of the assignment to get it to work with them. -I really don't know why this isn't working. Thanks for any help.","If you're trying to convert lines of floats separated by tab characters, then just float(line) will try to convert the whole line into one float, which will fail if there's more than one. Using strip to get rid of leading and trailing whitespace isn't going to help that fundamental problem. -Maybe you need to split each line into pieces and do something with each piece?",0.0582430451621389,False,2,1688 2012-02-19 14:46:11.867,Autocompletion in Pydev- Eclipse for wxpython,"How can I activate autocompletion feature for wx classes in pyDev? I cannot find anything to prompt me to change that will activate this feature from PyDev>Preference>Autocompletion. How can I get autocompletion from packages like wx and other third-party packages? Update: I added wx path in configuration to pyDev and it now shows autocompletion for wx. However, I cannot see the method arguments and properties. For example if I seek for wx.Button, I just get autocompletion to complete writing Button but I want to know the required arguments for wx.Button as wx.Button(,....,size,pos...) etc. This works for the other methods of built-in methods when I press Ctrl+Space but I don't know how should I configure to get that from wx and other third party packages?","Regarding missing parameters on the constructor for wx.Button, unfortunately that's currently expected. Please create a bug report for PyDev specifying that.",1.2,True,1,1689 2012-02-19 15:21:06.460,u'Georges Méliès' vs u'Georges M\xe9li\xe8s',"I've read a dozen pages but im still not getting it. Where is the difference between these versions: u'Georges Méliès' and u'Georges M\xe9li\xe8s' +and how do convert one to the other and vice-versa?","It's the same, and I would add: +u'Georges Méliès'.encode('latin1') gives 'Georges M\xe9li\xe8s'",1.2,True,2,1690 +2012-02-19 15:21:06.460,u'Georges Méliès' vs u'Georges M\xe9li\xe8s',"I've read a dozen pages but im still not getting it. +Where is the difference between these versions: +u'Georges Méliès' and u'Georges M\xe9li\xe8s' and how do convert one to the other and vice-versa?","There is no difference after those strings have been parsed by the interpreter. One version simply puts the special characters, but it requires the source file to have a special encoding, such as UTF-8. The second version replaces those characters with their byte representation, so it's safe to have such strings in an ASCII-encoded file. You can't talk about ""converting"" between them, because they are essentially the same strings. But here is something that may be interesting. print u'Georges M\xe9li\xe8s' gives the output Georges Méliès and print repr(u'Georges Méliès') gives u'Georges M\xe9li\xe8s'",0.9981778976111988,False,2,1690 -2012-02-19 15:21:06.460,u'Georges Méliès' vs u'Georges M\xe9li\xe8s',"I've read a dozen pages but im still not getting it. -Where is the difference between these versions: -u'Georges Méliès' and u'Georges M\xe9li\xe8s' -and how do convert one to the other and vice-versa?","It's the same, and I would add: -u'Georges Méliès'.encode('latin1') gives 'Georges M\xe9li\xe8s'",1.2,True,2,1690 2012-02-19 15:40:57.060,How to create a Mac .pkg from python which supports multiple versions of OSX,"I am trying to create a .pkg installer for a python application (specifically Spyderlib). This is not an app but a python package and a command line executable that have to be copied to specific locations. However, the location depends on the version of OSX. I'm only targeting 10.6 and 10.7 but they come with different versions of python (2.6 and 2.7) so the install path is different. Using bdist_mpkg I was able to create a Mac mpkg in 10.7 which installs correctly and can be edited with PackageMaker. Now I want to know how I can edit this package so that it detects the version of OSX and sets the install target path correctly. @@ -18692,6 +18692,9 @@ Thanks!","Use virtualenv. Create a virtualenv, activate it, install what you need, then do pip freeze > requirements.txt to create a file listing all your requirements. Then on your new machine (also inside a virtualenv) you can do pip install -r requirements.txt to reinstall all those libraries.",1.2,True,1,1694 2012-02-21 19:19:16.700,What does Python's eval() do?,"In the book that I am reading on Python, it keeps using the code eval(input('blah')) I read the documentation, and I understand it, but I still do not see how it changes the input() function. +What does it do? Can someone explain?","eval() interprets a string as code. The reason why so many people have warned you about using this is because a user can use this as an option to run code on the computer. If you have eval(input()) and os imported, a person could type into input() os.system('rm -R *') which would delete all your files in your home directory. (Assuming you have a unix system). Using eval() is a security hole. If you need to convert strings to other formats, try to use things that do that, like int().",0.9999999999999988,False,4,1695 +2012-02-21 19:19:16.700,What does Python's eval() do?,"In the book that I am reading on Python, it keeps using the code eval(input('blah')) +I read the documentation, and I understand it, but I still do not see how it changes the input() function. What does it do? Can someone explain?","In Python 2.x input(...) is equivalent to eval(raw_input(...)), in Python 3.x raw_input was renamed input, which I suspect lead to your confusion (you were probably looking at the documentation for input in Python 2.x). Additionally, eval(input(...)) would work fine in Python 3.x, but would raise a TypeError in Python 2. In this case eval is used to coerce the string returned from input into an expression and interpreted. Generally this is considered bad practice.",0.992631520201128,False,4,1695 2012-02-21 19:19:16.700,What does Python's eval() do?,"In the book that I am reading on Python, it keeps using the code eval(input('blah')) @@ -18700,9 +18703,6 @@ What does it do? Can someone explain?","Maybe a misleading example of reading a Try eval(input()) and type ""1+1"" - this should print 2. Eval evaluates expressions.",0.2401167094949473,False,4,1695 2012-02-21 19:19:16.700,What does Python's eval() do?,"In the book that I am reading on Python, it keeps using the code eval(input('blah')) I read the documentation, and I understand it, but I still do not see how it changes the input() function. -What does it do? Can someone explain?","eval() interprets a string as code. The reason why so many people have warned you about using this is because a user can use this as an option to run code on the computer. If you have eval(input()) and os imported, a person could type into input() os.system('rm -R *') which would delete all your files in your home directory. (Assuming you have a unix system). Using eval() is a security hole. If you need to convert strings to other formats, try to use things that do that, like int().",0.9999999999999988,False,4,1695 -2012-02-21 19:19:16.700,What does Python's eval() do?,"In the book that I am reading on Python, it keeps using the code eval(input('blah')) -I read the documentation, and I understand it, but I still do not see how it changes the input() function. What does it do? Can someone explain?","eval(), as the name suggests, evaluates the passed argument. raw_input() is now input() in python 3.x versions. So the most commonly found example for the use of eval() is its use to provide the functionality that input() provided in 2.x version of python. raw_input returned the user-entered data as a string, while input evaluated the value of data entered and returned it. @@ -18748,7 +18748,9 @@ You can check numpy.version.version to make sure you're getting the version you 2012-02-23 21:11:44.477,deploying python applications,"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? I'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? Basically 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. -How do professional software houses developing in python do it (or maybe the answer is that they don't) ?",Build a web application in python. Then the world can use it via a browser with zero install.,0.0814518047658113,False,3,1703 +How do professional software houses developing in python do it (or maybe the answer is that they don't) ?","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.) +If 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. +Professional 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.",1.2,True,3,1703 2012-02-23 21:11:44.477,deploying python applications,"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? I'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? Basically 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. @@ -18758,9 +18760,7 @@ Original source code can trivially be obtained from .pyc files if someone wants 2012-02-23 21:11:44.477,deploying python applications,"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? I'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? Basically 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. -How do professional software houses developing in python do it (or maybe the answer is that they don't) ?","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.) -If 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. -Professional 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.",1.2,True,3,1703 +How do professional software houses developing in python do it (or maybe the answer is that they don't) ?",Build a web application in python. Then the world can use it via a browser with zero install.,0.0814518047658113,False,3,1703 2012-02-24 13:53:40.810,Customize QTreeView items,"I'm new to PySide and Qt at all, and now need to create an application which has a tree view with styled items. Each item needs two lines of text (different styles), and a button. Many items are supposed to be in the view, so I chose QTreeView over QTreeWidget. Now I managed to add simple text items (non-styled) to the QTreeView and have almost no idea about how to place several widgets on one item. Could you please give me an example of how to create such design? I've found some samples on the Internet, that are similar to what I want, but they all are in C++, and it's not obvious how to convert delegates and other things to Python. I'm now really confused about it all...","I'd recomend you use simple QTreeWidget and insert complex widgets with setItemWidget. While Qt's widhets are alien, they are not so heavy to draw, but: @@ -18913,11 +18913,6 @@ Root_ is optional of course. Ask if you have any questions.",0.0,False,1,1719 2012-03-03 23:13:33.187,Scraping with JQuery or Python?,"So lets say I'm scraping multiple pages (lets say a 1000) on a website. I want to know which language is best to use to scrape those pages with - javascript or python. Further, I've heard about javascript scrapers being faster (due to multiple get requests), but am unsure how to implement this - can anyone enlighten me? -Thanks!","If I'm reading your question right, you're not trying to build a web app (client- or server-side), but rather a standalone app that simply requests and downloads pages from the Web. -You can write a standalone app in JavaScript, but it's not common. The primary use of JavaScript is for code that's going to run in a user's Web browser. For standalone apps, Python is the better choice. And it has very good support (in the form of the urllib2 and related libraries) for tasks like Web scraping. -Of course, if your scraping task is relatively simple, you might be better off just using wget.",0.0,False,2,1720 -2012-03-03 23:13:33.187,Scraping with JQuery or Python?,"So lets say I'm scraping multiple pages (lets say a 1000) on a website. I want to know which language is best to use to scrape those pages with - javascript or python. -Further, I've heard about javascript scrapers being faster (due to multiple get requests), but am unsure how to implement this - can anyone enlighten me? Thanks!","This is just my opinion but I would rank them like this javascript might be the best choice but only if you have a node @@ -18925,6 +18920,14 @@ environment already set up. The advantage of javascript scrapers is they can interpret the js in the pages you're scraping. next is a three way tie between perl python and ruby. They all have a mechanize library and do xpath and regex in a sensible way. Down at the bottom is php. It's lack of a cookie handling library like mechanize (curl isn't great) and it's clumsy dom and regex functions make it a poor choice for scraping.",1.2,True,2,1720 +2012-03-03 23:13:33.187,Scraping with JQuery or Python?,"So lets say I'm scraping multiple pages (lets say a 1000) on a website. I want to know which language is best to use to scrape those pages with - javascript or python. +Further, I've heard about javascript scrapers being faster (due to multiple get requests), but am unsure how to implement this - can anyone enlighten me? +Thanks!","If I'm reading your question right, you're not trying to build a web app (client- or server-side), but rather a standalone app that simply requests and downloads pages from the Web. +You can write a standalone app in JavaScript, but it's not common. The primary use of JavaScript is for code that's going to run in a user's Web browser. For standalone apps, Python is the better choice. And it has very good support (in the form of the urllib2 and related libraries) for tasks like Web scraping. +Of course, if your scraping task is relatively simple, you might be better off just using wget.",0.0,False,2,1720 +2012-03-04 05:35:51.437,python re.match group: number after \number,"In a Python match pattern, how do I match a literal digit like 1 after a backreference by number like \1? +I tried the \g<1> syntax that is available in substitution patterns for this purpose, but it doesn't work in my match pattern. +I have a larger problem that I want to solve using a function that will perform the following somewhat unusual task. The task is to construct patterns dynamically so that each pattern will match digit sequences that have repeated digits in certain positions and specific digits in the remaining positions.",Put the digit that you want to match literally in a character class \1[1] or a group \1(1) of its own so that the bracket or parentheses separates the digit from the backreference.,0.3869120172231254,False,2,1721 2012-03-04 05:35:51.437,python re.match group: number after \number,"In a Python match pattern, how do I match a literal digit like 1 after a backreference by number like \1? I tried the \g<1> syntax that is available in substitution patterns for this purpose, but it doesn't work in my match pattern. I have a larger problem that I want to solve using a function that will perform the following somewhat unusual task. The task is to construct patterns dynamically so that each pattern will match digit sequences that have repeated digits in certain positions and specific digits in the remaining positions.","I noticed that I don't need the \g<1> syntax. Instead I can use one of several techniques to separate the numeric backreference like \2 from the digit like 9 that follows it. Here are three such techniques: @@ -18932,9 +18935,6 @@ I have a larger problem that I want to solve using a function that will perform a non-capturing group (?:\2)9 an otherwise unnecessary quantification by one \2{1}9 using an otherwise unnecessary character class to contain only the digit that follows the backreference \2[9]",1.2,True,2,1721 -2012-03-04 05:35:51.437,python re.match group: number after \number,"In a Python match pattern, how do I match a literal digit like 1 after a backreference by number like \1? -I tried the \g<1> syntax that is available in substitution patterns for this purpose, but it doesn't work in my match pattern. -I have a larger problem that I want to solve using a function that will perform the following somewhat unusual task. The task is to construct patterns dynamically so that each pattern will match digit sequences that have repeated digits in certain positions and specific digits in the remaining positions.",Put the digit that you want to match literally in a character class \1[1] or a group \1(1) of its own so that the bracket or parentheses separates the digit from the backreference.,0.3869120172231254,False,2,1721 2012-03-04 10:41:17.713,SQLAlchamy Database Construction & Reuse,"there's something I'm struggling to understand with SQLAlchamy from it's documentation and tutorials. I see how to autoload classes from a DB table, and I see how to design a class and create from it (declaratively or using the mapper()) a table that is added to the DB. My question is how does one write code that both creates the table (e.g. on first run) and then reuses it? @@ -18964,12 +18964,12 @@ In cmd.exe: C:\> echo m | p4 resolve",0.0,False,1,1726 2012-03-05 20:05:51.293,How to access and modify Xcode project files from python code?,"I am a Xcode newbie and need to programmatically access Xcode projects and methods to modify from a Python module. For example, say i have a ""hello world"" program in Xcode, and i need to modify the message to ""Hello Python!"", how do i do that from within my Python module? Please note i am talking about a Python module which is external and not in the Xcode project.","Xcode projects are bundles like app bundles. So 'foo.xcodeproj' will be a directory, inside of which is project.pbxproj. There may be other files in the directory, but they are not used for the build and direct project definition; they are user configuration and window layout and things like that for the user of the project.",-0.3869120172231254,False,1,1727 -2012-03-05 22:23:32.727,Do I need to create a separate class in my models.py when using the django.contrib.auth.models import user?,"The import statement import the needed parts. but is the ""user"" class already made when you put that into your installed apps? or do you still need to clarify in models.py in order to make the table in the db? or can someone expand on how to use django users and sessions? I'm looking over the django docs right now and they all just go over how to use the thing once. they never put the code in a syntax where users are going to be the ones using the code through a browser and not you through a python shell.","All installed apps can contribute to the database schema. django.contrib.auth.models contributes, among others, the auth_user table behind the django.contrib.auth.models.User model, therefore you do not have to worry about recreating it unless you have a specific reason to do so.",1.2,True,2,1728 2012-03-05 22:23:32.727,Do I need to create a separate class in my models.py when using the django.contrib.auth.models import user?,"The import statement import the needed parts. but is the ""user"" class already made when you put that into your installed apps? or do you still need to clarify in models.py in order to make the table in the db? or can someone expand on how to use django users and sessions? I'm looking over the django docs right now and they all just go over how to use the thing once. they never put the code in a syntax where users are going to be the ones using the code through a browser and not you through a python shell.","There's a number of things going on here. As you're aware, Django comes with a number of ""contrib"" packages that can be used in your app. You ""activate"" these by putting them into your INSTALLED_APPS. When you run python manage.py syncdb, Django parse the models.py files of every app in INSTALLED_APPS and creates the associated tables in your database. So, once you have added django.contrib.auth to your INSTALLED_APPS and ran syncdb, the tables for User and Group are there and ready to be used. Now, if you want to use these models in your other apps, you can import them, as you mention, with something like from django.contrib.auth.models import User. You can then do something like create a ForeignKey, OneToOneField or ManyToManyField on one of your models to the User model. When you do this, no tables are created (with the exception of ManyToManyField; more on that in a bit). The same table is always used for User, just as for any of your own models that you might create relationships between. ManyToManyFields are slightly different in that an intermediary table is created (often called a ""join table"") that links both sides of the relationship together. However, this is purely for the purposes of that one particular relationship -- nothing about the actual User table is different or changed in any way. The point is that one table is created for User and this same table is used to store all Users no matter what context they were created in. You can import User into any and all of your apps, create as many and as varied relationships as you like and nothing really changes as far as User is concerned.",0.0,False,2,1728 +2012-03-05 22:23:32.727,Do I need to create a separate class in my models.py when using the django.contrib.auth.models import user?,"The import statement import the needed parts. but is the ""user"" class already made when you put that into your installed apps? or do you still need to clarify in models.py in order to make the table in the db? or can someone expand on how to use django users and sessions? I'm looking over the django docs right now and they all just go over how to use the thing once. they never put the code in a syntax where users are going to be the ones using the code through a browser and not you through a python shell.","All installed apps can contribute to the database schema. django.contrib.auth.models contributes, among others, the auth_user table behind the django.contrib.auth.models.User model, therefore you do not have to worry about recreating it unless you have a specific reason to do so.",1.2,True,2,1728 2012-03-06 01:50:28.840,django-admin-tools : change header 'Django Administration',"I am using django-admin-tool to customized my django admin page. my problem is, how can I change the header of 'Django Administration' with django-admin-tools? i know how to change it using base_site.html but the problem is my custom menu that i have done in django-admin-tools is not appearing.","The django-admin-tools header is controlled by the theming.css file which is by default sitting under \admin_tools\theming\static\admin_tools\css\theming.css, and the default header should display the ""Django"" png that comes with django-admin-tools and is placed under \admin_tools\theming\static\admin_tools\images\django.png. I guess that if the default admin tools header doesn't display then your admin tools theme is not kicking in either. This means django can't see your theming folder of admin tools. Check that your MEDIA_ROOT, STATIS_ROOT andADMIN_MEDIA_PREFIX parameters in setting.py are set correctly. Check the PYTHONPATH env param is also set to all the needed folders. @@ -19008,7 +19008,13 @@ I can use queues with Kombu to inline all writtings. But do you know a way to make the same with reading ? E.G: if one script need to read from the DB, his request is sent to a blocking queue, et it resumes when it got the answer ? This way everybody is making request to one process, and the process is the only one talking to the DB, making one request at the time. I have no idea how to do this. -Of course, in the end I may have to add more servers to the mix, but before that, is there something I can do at the software level ?","You could create a function that each process must call in order to talk to the DB. You could re-write the scripts so that they must call that function rather than talk directly to the DB. Within that function, you could have a scope-based lock so that only one process would be talking to the DB at a time.",0.0,False,2,1735 +Of course, in the end I may have to add more servers to the mix, but before that, is there something I can do at the software level ?","You say that your dataset is <1GB, the problem is CPU bound. +Now start analyzing what is eating CPU cycles: + +Which queries are really slow and executed often. MySQL can log those queries. +What about the slow queries? Can they be accelerated by using an index? +Are there unused indices? Drop them! +Nothing helps? Can you solve it by denormalizing/precomputing stuff?",0.1352210990936997,False,2,1735 2012-03-08 13:59:39.890,How to ensure several Python processes access the data base one by one?,"I got a lot scripts running: scrappers, checkers, cleaners, etc. They have some things in common: they are forever running; @@ -19020,13 +19026,7 @@ I can use queues with Kombu to inline all writtings. But do you know a way to make the same with reading ? E.G: if one script need to read from the DB, his request is sent to a blocking queue, et it resumes when it got the answer ? This way everybody is making request to one process, and the process is the only one talking to the DB, making one request at the time. I have no idea how to do this. -Of course, in the end I may have to add more servers to the mix, but before that, is there something I can do at the software level ?","You say that your dataset is <1GB, the problem is CPU bound. -Now start analyzing what is eating CPU cycles: - -Which queries are really slow and executed often. MySQL can log those queries. -What about the slow queries? Can they be accelerated by using an index? -Are there unused indices? Drop them! -Nothing helps? Can you solve it by denormalizing/precomputing stuff?",0.1352210990936997,False,2,1735 +Of course, in the end I may have to add more servers to the mix, but before that, is there something I can do at the software level ?","You could create a function that each process must call in order to talk to the DB. You could re-write the scripts so that they must call that function rather than talk directly to the DB. Within that function, you could have a scope-based lock so that only one process would be talking to the DB at a time.",0.0,False,2,1735 2012-03-09 15:06:28.283,Is that possible to develop a ACM ONLINE JUDGE system using NODE.JS(or PYTHON)?,"I'm a newer and if the question is so easy I apologize for that. Assume I want to dev a classical online judge system, obviously the core part is @@ -19151,8 +19151,8 @@ This myserver.py can and will use multiprocessing to spawn subprocesses of its o Generally, 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. If 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.",1.2,True,1,1748 2012-03-15 16:59:47.290,Can you share an example of using class based view with MonthMixin?,"I have a news on my site done with ""James Bennett - Practical Django Projects, 2nd Edition (2009)"". So I am using a date-based views, which will be deprecated in django-1.4. How can I just convert my views and urls to class-based views ? May be you have seen this, please just post a link, I can't find any working example, at least for MonthMixin.","Think of CBV, more specifically ""Generic Class Based Views"" as a large tree of Python classes. Starting with the simplest class. Each one subclasses and over rides methods from one another. For example, the ArchiveIndexView is typically the view you will sub-class for the index of your site. It adds an extra context variable called latest. You must supply it with a date_field, num_latest, and a couple optionals in the view class. You can also pass these arguements in through the URLConf. However, it is more tidy and clean to have the logic in the views.py . It is quite convenient once you get the hang of it. You can create mixins of your own that essentially are as powerful as your brain. Beyond, a mixin though for something you want available on every page then perhaps a template tag or a custom context processor at worst.",0.0,False,1,1749 -2012-03-15 19:09:47.057,Multiple imports of python modules,"Just for my knowledge, how does python, especially wxpython reacts to multiple imports? If I import wx in multiple files, how does it handle that when called the main frame? Does it slows the speed or it firstly checks whether it is already been imported or not?","When Python imports a file, it keps track of it by storing it in sys.modules. So whenever Python is importing a file it checks there first and, if it finds it there, returns that instead; if it is not there, it imports it, adds it to sys.modules, and then returns it.",1.2,True,2,1750 2012-03-15 19:09:47.057,Multiple imports of python modules,"Just for my knowledge, how does python, especially wxpython reacts to multiple imports? If I import wx in multiple files, how does it handle that when called the main frame? Does it slows the speed or it firstly checks whether it is already been imported or not?",Only the first import executes the file. Subsequent imports copy the reference from sys.modules.,0.5457054096481145,False,2,1750 +2012-03-15 19:09:47.057,Multiple imports of python modules,"Just for my knowledge, how does python, especially wxpython reacts to multiple imports? If I import wx in multiple files, how does it handle that when called the main frame? Does it slows the speed or it firstly checks whether it is already been imported or not?","When Python imports a file, it keps track of it by storing it in sys.modules. So whenever Python is importing a file it checks there first and, if it finds it there, returns that instead; if it is not there, it imports it, adds it to sys.modules, and then returns it.",1.2,True,2,1750 2012-03-16 11:38:13.003,Python : Automate the user input data(Multiple sequential inputs)?,"I have a python script say script1.py. It will prompt the user with a serious of questions like Name, 'Y' / 'N' type questions. Now i need to call this python script from another python script,say scripts2.py such that I would define the user inputs in script2.py. So how to pass the input sequentially??? Help would be appreciated. Regards, @@ -19312,10 +19312,10 @@ I'm biased for wxPython. However, you're better off taking a look at their demos ie,given 3,5,2 I need 3 to be returned. I tried to implement this by going thru all three and using if else conditions to check if each is between the other two.But this seems a naive way to do this.Is there a better way?","Put them in a list, sort them, pick the middle one.",1.2,True,1,1776 -2012-04-03 10:56:17.117,Linux - Linebreak in IPython,"Hi I'm new to Linux and I really like the idea of writing and testing python code in a shell. But my problem is how can I do line breaks in IPython. Every time I use the (I think) ""normal"" shortcut shift+enter the code gets executed. Function keys are disabled and keyboard layout works fine on my laptop, what could be the problem?","Nothing is the problem. Python code is executed line-by-line. -If your code does not work when executed line-by-line, it should not work when loaded from a file (assuming in both cases a ""clean"" environment).",1.2,True,2,1777 2012-04-03 10:56:17.117,Linux - Linebreak in IPython,"Hi I'm new to Linux and I really like the idea of writing and testing python code in a shell. But my problem is how can I do line breaks in IPython. Every time I use the (I think) ""normal"" shortcut shift+enter the code gets executed. Function keys are disabled and keyboard layout works fine on my laptop, what could be the problem?","If you want to do a line-break, you end the line with the \ escape character, same as you do in a Python file. Shift+Enter doesn't have any special meaning in ipython, and indeed most over places in the shell. It doesn't have special meaning in Python, either. It does have special meaning in some text editors and word processors, most notably LyX and LibreOffice, and of course on some websites (through a web browser).",0.7408590612005881,False,2,1777 +2012-04-03 10:56:17.117,Linux - Linebreak in IPython,"Hi I'm new to Linux and I really like the idea of writing and testing python code in a shell. But my problem is how can I do line breaks in IPython. Every time I use the (I think) ""normal"" shortcut shift+enter the code gets executed. Function keys are disabled and keyboard layout works fine on my laptop, what could be the problem?","Nothing is the problem. Python code is executed line-by-line. +If your code does not work when executed line-by-line, it should not work when loaded from a file (assuming in both cases a ""clean"" environment).",1.2,True,2,1777 2012-04-03 14:10:45.350,How to structure complex Django project?,"I have a Django project which is getting more and more complex. I started off with the traditional files: models, views, and forms.py. The issue I have right now is that those files are getting bigger and bigger and I'd like to break them into manageable parts. What are the best practices around that? In addition, I am wondering if it is best practice to add class method to a model in Django? For instance, I have a Vote class on which I would like to add methods to get the number of votes for a specific user, content, etc?","I certainly use class methods, and I have found that where there are similar operations to be performed on classes, it is possible (and easy) to factor the classmethods into base classes (use the self parameter of your class method to write generic code). Probably the best way to manage broken-up views, etc is to replace each file you want to break up with its own package, and put whatever you need to (if anything) into that package's __init__.py module.",0.1352210990936997,False,2,1778 @@ -19464,12 +19464,12 @@ SciTE is a SCIntilla based Text Editor. Originally built to 2012-04-06 17:36:06.800,How to close the doc reading part of the IPython notebook?,"In an IPython notebook, when you look at some docs with ? or help(), a split frame is opened at the bottom of the screen where the documentation shows up. While I find this useful as a guide for continuing to play with some Python code, I would like to close this spit frame when I'm done reading the docs, so to get back the screen space. But I can't find instructions anywhere, not with Google and not in the IPython notebook docs how to do this? -Anybody knows?","Doh, one has to click on the very slim divider line. The subframe then closes...",1.2,True,2,1789 +Anybody knows?","You have to press the q key. +That works for me.",0.9866142981514304,False,2,1789 2012-04-06 17:36:06.800,How to close the doc reading part of the IPython notebook?,"In an IPython notebook, when you look at some docs with ? or help(), a split frame is opened at the bottom of the screen where the documentation shows up. While I find this useful as a guide for continuing to play with some Python code, I would like to close this spit frame when I'm done reading the docs, so to get back the screen space. But I can't find instructions anywhere, not with Google and not in the IPython notebook docs how to do this? -Anybody knows?","You have to press the q key. -That works for me.",0.9866142981514304,False,2,1789 +Anybody knows?","Doh, one has to click on the very slim divider line. The subframe then closes...",1.2,True,2,1789 2012-04-07 11:45:31.420,How do I replace the GLUT title bar icon when using pyopengl?,"I am trying to learn OpenGL, and I'm using PyOpenGL and GLUT. What really bugs me, is that I can't figure out how to change the title bar icon. Has anyone had any success in changing this?","You don't. @@ -19617,11 +19617,11 @@ The last 2 are a lot better in my opinion, but I still stick to web services as 2012-04-11 02:09:29.020,How do I navigate a website through software?,"I need to navigate though a website that is written mostly in Javascript. There are no hard links at all, as the page is simply modified through the script. I can do what I need to using Javascript injections one after another, but chrome starts searching for my input instead of injecting it after a certain string length. I've tried to use frames to do this in HTML, but chrome won't let me use Javascript inside the frame since the source is from a different domain. Is there a good way that I can do this? I've looked into using Java or Python, but I don't see anything that lets you work with Javascript. EDIT: Thanks for telling me about different software, but I don't want to use other third-party software. I would really like to know how to execute Javascript injections in a systematic manner from a HTML page. I can do it from the browser, so why can't I do it from an HTML document?","You can use a tool like Selenium to emulate a user clicking things in a web browser (I believe it actually ""drives"" a real instance of whatever browser you choose.) Selenium has a domain-specific language for specifying what actions you want to perform, and Python bindings for controlling it programmatically. I haven't actually used it, so I can't say much more about it, but you should go check it out.",0.3869120172231254,False,1,1798 -2012-04-11 04:01:55.863,How do I initialize a one-dimensional array of two-dimensional elements in Python?,"I want to initialize an array that has X two-dimensional elements. For example, if X = 3, I want it to be [[0,0], [0,0], [0,0]]. I know that [0]*3 gives [0, 0, 0], but how do I do this for two-dimensional elements?","I believe that it's [[0,0],]*3",0.0,False,2,1799 2012-04-11 04:01:55.863,How do I initialize a one-dimensional array of two-dimensional elements in Python?,"I want to initialize an array that has X two-dimensional elements. For example, if X = 3, I want it to be [[0,0], [0,0], [0,0]]. I know that [0]*3 gives [0, 0, 0], but how do I do this for two-dimensional elements?","Using the construct [[0,0]]*3 works just fine and returns the following: [[0, 0], [0, 0], [0, 0]]",0.0,False,2,1799 +2012-04-11 04:01:55.863,How do I initialize a one-dimensional array of two-dimensional elements in Python?,"I want to initialize an array that has X two-dimensional elements. For example, if X = 3, I want it to be [[0,0], [0,0], [0,0]]. I know that [0]*3 gives [0, 0, 0], but how do I do this for two-dimensional elements?","I believe that it's [[0,0],]*3",0.0,False,2,1799 2012-04-11 12:09:27.993,Apply decorator to context processor,"I'm using Fandjango for a Django Facebook Canvas app. To use fandjango, you need to wrap all view functions with @facebook_authorization_required, which makes sure you're authorized, then gives you the variable request.facebook.user. What I want is to make a context processor which defines a few more variables based on this, i.e., I want all my templates to be able to use fb_user as a shortcut for request.facebook.user. @@ -19705,10 +19705,10 @@ Given a context menu already created, I'm looking for a functional example of ho ""If you are given a context menu (QMenu to be specific) you can access it."" - Avaris ""You can't do this without modifying that file [the one containing the context menu creation code]. It assumes it has given a list of QActions (see line 301) and it wouldn't be expecting QMenu. Though, if you can get to the plugin_menu reference in your plugin, that's a different story."" - Avaris So either you can access to manipulate the menu in the same file (and same place in that file) where the menu creation/definition code is, or you can gain access to do so via that file (in the same place) exposing the menu via an API. On the flip side, if you don't have such API access, and/or modify that file/function, then there's no way to do this.",1.2,True,1,1811 +2012-04-18 11:10:43.087,OpenERP: insert Data code,"I am new in OpenERP, I have installed OpenERP v6. I want to know how can I insert data in database? Which files I have to modify to do the job? (files for the SQL code)",The addition of columns in the .py files of the corresponding modules you want to chnage will insert coumns to the pgadmin3 also defenition of classes will create tables...when the fields are displayed in xml file and values are entered to the fields through the interface the values get stored to the table values to the database...,0.0,False,2,1812 2012-04-18 11:10:43.087,OpenERP: insert Data code,"I am new in OpenERP, I have installed OpenERP v6. I want to know how can I insert data in database? Which files I have to modify to do the job? (files for the SQL code)","OpenERP works with PostgreSQl as the Back-end Structure. Postgresql is managed by pgadmin3 (Postgres GUI),you can write sql queries there and can add/delete records from there. It is not advisable to insert/remove data directly into Database!!!!",0.0,False,2,1812 -2012-04-18 11:10:43.087,OpenERP: insert Data code,"I am new in OpenERP, I have installed OpenERP v6. I want to know how can I insert data in database? Which files I have to modify to do the job? (files for the SQL code)",The addition of columns in the .py files of the corresponding modules you want to chnage will insert coumns to the pgadmin3 also defenition of classes will create tables...when the fields are displayed in xml file and values are entered to the fields through the interface the values get stored to the table values to the database...,0.0,False,2,1812 2012-04-18 21:02:01.900,How to get number of visitors of a page on GAE?,"I need to get the number of unique visitors(say, for the last 5 minutes) that are currently looking at an article, so I can display that number, and sort the articles by most popular. ex. Similar to how most forums display 'There are n people viewing this thread' How can I achieve this on Google App Engine? I am using Python 2.7. @@ -19741,7 +19741,7 @@ And I am very unexperienced and just started to learn programming. I am not fami so the questions are: how do i run python interpreter in Emacs? -are there different kind of python interpreter? if so, why do they have different interpreters for one language?",C-c C-z can do this. It is the key-binding for the command python-switch-to-python,0.6133572603953825,False,2,1817 +are there different kind of python interpreter? if so, why do they have different interpreters for one language?",In emacs 24.2 there is python-switch-to-python,0.0,False,2,1817 2012-04-20 06:27:08.403,How do I run a python interpreter in Emacs?,"I just downloaded GNU emacs23.4, and I already have python3.2 installed in Windows7. I have been using Python IDLE to edit python files. The problem is that I can edit python files with Emacs but I do not know how to run python interpreter in Emacs. When i click on ""switch to interpreter"", then it says ""Searching for program: no such file or directory, python"" @@ -19750,7 +19750,7 @@ And I am very unexperienced and just started to learn programming. I am not fami so the questions are: how do i run python interpreter in Emacs? -are there different kind of python interpreter? if so, why do they have different interpreters for one language?",In emacs 24.2 there is python-switch-to-python,0.0,False,2,1817 +are there different kind of python interpreter? if so, why do they have different interpreters for one language?",C-c C-z can do this. It is the key-binding for the command python-switch-to-python,0.6133572603953825,False,2,1817 2012-04-20 15:31:27.853,how to implement 'daisychaining' of pluggable function in python?,"here is the problem: 1) suppose that I have some measure data (like 1Msample read from my electronics) and I need to process them by a processing chain. 2) this processing chain consists of different operations, which can be swapped/omitted/have different parameters. A typical example would be to take this data, first pass them via a lookup table, then do exponential fit, then multiply by some calibration factors @@ -19849,9 +19849,9 @@ Other than that, you may have to provide the actual path instead of using @sys.. for instance, u select 3 invoices and it returns the sum of the quantity in the invoice lines. i think the function to perform the sum is correct, and even if it wasnt, i just need help in displaying the result of the function when called in a popup box. for that, i've added an action similar to ""Confirm Invoices"" found in the invoice object. to make myself clearer, when the confirm invoice is pressed, its function is called and the popup previously opened is of course closed because of this line found in the function: return {'type': 'ir.actions.act_window_close'} how can i tell it in my function instead (of closing) to display the result stored after executing the function?","If your purpose is to debug, the simplest solution is to add print statements in your code and then run the server in a console.",0.0,False,1,1829 +2012-04-25 20:05:10.797,Removing selected characters from text file,"I have long a text file where each line looks something like /MM0001 (Table(12,)) or /MM0015 (Table(11,)). I want to keep only the four-digit number next to /MM. If it weren't for the ""table(12,)"" part I could just strip all the non-numeric characters, but I don't know how to extract the four-digit numbers only. Any advice on getting started?","If it's exactly that format, you could just print out line[3:7]",1.2,True,2,1830 2012-04-25 20:05:10.797,Removing selected characters from text file,"I have long a text file where each line looks something like /MM0001 (Table(12,)) or /MM0015 (Table(11,)). I want to keep only the four-digit number next to /MM. If it weren't for the ""table(12,)"" part I could just strip all the non-numeric characters, but I don't know how to extract the four-digit numbers only. Any advice on getting started?","You could parse text line by line and then use 4th to 7th char of every line. ln[3:7]",0.2012947653214861,False,2,1830 -2012-04-25 20:05:10.797,Removing selected characters from text file,"I have long a text file where each line looks something like /MM0001 (Table(12,)) or /MM0015 (Table(11,)). I want to keep only the four-digit number next to /MM. If it weren't for the ""table(12,)"" part I could just strip all the non-numeric characters, but I don't know how to extract the four-digit numbers only. Any advice on getting started?","If it's exactly that format, you could just print out line[3:7]",1.2,True,2,1830 2012-04-25 23:52:42.283,Jump Through Polygon/Floor Collision Detection,"I am trying to implement a Mario type plat-former in pyGame. I have Collision detection working with Polygons no problem. I am curious how I can get the player to be able to jump through the floor above him, which is a polygon floating in air. What is the theory on how to handle that?","you could make it so that when your character hits a block, they move up at the current speed until they are no longer colliding with the polygon. That way, when you hit the ground from above,you don't go downward through it, but when you hit the bottom, you do. I would recommend a while loop set to the collide function.",0.3869120172231254,False,1,1831 2012-04-26 07:24:36.250,Grabbing pixel attributes in Python,"I am using Python3 on Windows 7. I want to grab all the attributes like color intensity, color etc. Of all the pixels of the screen area that I select with mouse. The selection can be of any shape but right now rectangular and square will do. @@ -19884,6 +19884,10 @@ On system1, run pip freeze --local > requirements.txt and copy that file to syst Your python code can be simply copied to the new system; I'd find -name '*.pyc' -delete though since you usually do not want to move compiled code (even if it's just python bytecode) between machines.",1.2,True,1,1835 2012-04-27 10:35:43.423,how to do Ldap Server Authentication?,"I have set up a Ldap Server somewhere. I can bind to it, can add, modify, delete entry in the database. Now when it come to authentication isnt it as simple as giving the username and password to the server, asking it to search for an entry matching the two? And furthermore, isnt it the 'userPassword' field that contains the password for a user in there? Now, +I tried to set up splunk to authenticate from my Ldap server, i provided the username and password, but it failed authentication. Isnt it that 'userPassword' field that splunk checks? What should be the possible reason?","Typically you would search using the username value provided on uid or cn values within the LDAP Tree. +-jim",0.1352210990936997,False,2,1836 +2012-04-27 10:35:43.423,how to do Ldap Server Authentication?,"I have set up a Ldap Server somewhere. I can bind to it, can add, modify, delete entry in the database. Now when it come to authentication isnt it as simple as giving the username and password to the server, asking it to search for an entry matching the two? And furthermore, isnt it the 'userPassword' field that contains the password for a user in there? +Now, I tried to set up splunk to authenticate from my Ldap server, i provided the username and password, but it failed authentication. Isnt it that 'userPassword' field that splunk checks? What should be the possible reason?","LDAP servers are generally not going to allow you to search on the userPassword attribute, for obvious security reasons. (and the password attribute is likely stored in hashed form anyway, so a straight search would not work.) Instead, the usual way to do LDAP authentication is: @@ -19892,10 +19896,6 @@ Bind to LDAP with your application's account, search for username to get the ful Make a new LDAP connection, and attempt to bind using the user's dn & password (If you know how to construct the dn from the username, you can skip step 2, but it's generally a good idea to search first - that way you're less sensitive to things like changes in the OU structure of the LDAP directory)",1.2,True,2,1836 -2012-04-27 10:35:43.423,how to do Ldap Server Authentication?,"I have set up a Ldap Server somewhere. I can bind to it, can add, modify, delete entry in the database. Now when it come to authentication isnt it as simple as giving the username and password to the server, asking it to search for an entry matching the two? And furthermore, isnt it the 'userPassword' field that contains the password for a user in there? -Now, -I tried to set up splunk to authenticate from my Ldap server, i provided the username and password, but it failed authentication. Isnt it that 'userPassword' field that splunk checks? What should be the possible reason?","Typically you would search using the username value provided on uid or cn values within the LDAP Tree. --jim",0.1352210990936997,False,2,1836 2012-04-28 12:20:57.647,How to kill the cherrypy process?,"I am using cherrypy in python script.I think I have to register a callback method from the main application so that i can stop cherrypy main process from a worker thread,but how do i kill the main process within the that process. So i want to know how to stop cherrypy from within the main process.","If your process is using CherryPy to block (via quickstart or engine.block), then you could simply call: cherrypy.engine.exit() from your page handler. That would be the cleanest option since it would properly terminate CherryPy and plugins you may have subscribed to.",0.0,False,1,1837 2012-04-29 21:27:51.837,Creating a customized language using Python,"I have started playing with Sage recently, and I've come to suspect that the standard Python int is wrapped in a customized class called Integer in Sage. If I type in type(1) in Python, I get , however, if I type in the same thing in the sage prompt I get . @@ -19912,6 +19912,13 @@ The field will only be visible for managers",0.1016881243684853,False,1,1839 2012-05-01 12:34:16.483,What type of project will help me learn thread programming,"I want to learn threading and multiprocessing in Python. I don't know what kind of project to take up for this. I want to be able to deal with all the related objects like Locks, Mutexes, Conditions, Semaphores, etc. Please suggest a project type that's best for me. +P.S. Along with the project, please suggest any tools to debug / profile / load-test my app so that I can gauge how good my threaded implementations are.","I propose you attempt to program a very simple database server. Each client can connect to the server and do create, read, update, delete on a set of entities. Implementation-wise, the server should have one thread for each client all operating a global set of entities, which are protected using locks. +For learning how to use conditional variables, the server should also implement a notify method, which allows a client to be notified when an entity changed. +Good luck! +NOTE: Using threads is not the most efficient way to program a simple database server, but I think it is a good project for self-improvement.",0.0,False,2,1840 +2012-05-01 12:34:16.483,What type of project will help me learn thread programming,"I want to learn threading and multiprocessing in Python. I don't know what kind of project to take up for this. +I want to be able to deal with all the related objects like Locks, Mutexes, Conditions, Semaphores, etc. +Please suggest a project type that's best for me. P.S. Along with the project, please suggest any tools to debug / profile / load-test my app so that I can gauge how good my threaded implementations are.","a few ideas: web crawler - have a pool of threads getting work from a dispatcher via a queue, download web pages and return the results somewhere. @@ -19920,19 +19927,12 @@ mp3 file organizer - rebuild a music library's structure from mp3 tag data, and I'll edit with some more ideas if I think of any. EDIT: Since python is limited to one CPU per process, no matter how many threads, if you want to parallelize CPU consuming stuff, threading will get you nowhere, use the multiprocessing interface instead, it's almost identical to the threading API, but dispatches stuff to sub processes that can use more CPU cores.",0.9950547536867304,False,2,1840 -2012-05-01 12:34:16.483,What type of project will help me learn thread programming,"I want to learn threading and multiprocessing in Python. I don't know what kind of project to take up for this. -I want to be able to deal with all the related objects like Locks, Mutexes, Conditions, Semaphores, etc. -Please suggest a project type that's best for me. -P.S. Along with the project, please suggest any tools to debug / profile / load-test my app so that I can gauge how good my threaded implementations are.","I propose you attempt to program a very simple database server. Each client can connect to the server and do create, read, update, delete on a set of entities. Implementation-wise, the server should have one thread for each client all operating a global set of entities, which are protected using locks. -For learning how to use conditional variables, the server should also implement a notify method, which allows a client to be notified when an entity changed. -Good luck! -NOTE: Using threads is not the most efficient way to program a simple database server, but I think it is a good project for self-improvement.",0.0,False,2,1840 2012-05-02 10:39:00.433,How to run nginx + python (without django),"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. I 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. -I 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!","All the same you must use wsgi server, as nginx does not support fully this protocol.",0.0,False,2,1841 +I 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!","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.",1.2,True,2,1841 2012-05-02 10:39:00.433,How to run nginx + python (without django),"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. I 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. -I 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!","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.",1.2,True,2,1841 +I 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!","All the same you must use wsgi server, as nginx does not support fully this protocol.",0.0,False,2,1841 2012-05-02 20:29:11.373,How can I change the order of the BoxLayout in kivy?,I am testing kivy and I want to create a BoxLayout so to stack some buttons. My problem is that the children that are added to the layout follow a bottom-top logic while I want the opposite. Do you know how can I reverse the order? Thanks!,"There is a tricky way to do that. Use a gridlayout and set cols to 1",0.2012947653214861,False,1,1842 2012-05-03 02:48:34.140,Pointers on using celery with sorl-thumbnails with remote storages?,"I'm surprised I don't see anything but ""use celery"" when searching for how to use celery tasks with sorl-thumbnails and S3. @@ -19960,15 +19960,15 @@ indexname='text'---->Today is a great day for running in the park. Now i want to perform a search on the indexes where only 'day' or 'run' is appearing in the text. I have implemented query like : q = 'text:(day or run*)' -But this query is not returning me any results from indexes.Is this correct way?or how can i improve my query by applying regex ?",Your use case is very basic and doesn't require regex at all with Solr. It looks like you just may have a syntax issue. q=text:day OR text:run should do exactly what you're looking for.,0.2012947653214861,False,2,1844 +But this query is not returning me any results from indexes.Is this correct way?or how can i improve my query by applying regex ?","Regex and wildcards are slow in search engines. You'll get better performance by pre-processing the terms in a language-sensitive way. +You can match ""run"" to ""running"" with a stemmer, an analysis step that reduces different forms of a word to a common stem. When the query and the index term are both stemmed, then they will match. +You should also look into the Extended Dismax (edismax) search handler. That will do some of the work of turning ""day run"" into a search for the individual words and the phrase, something like 'day OR run OR ""day run""'. Then it can further expand that against multiple fields with different weights, all automatically.",0.0,False,2,1844 2012-05-03 06:52:29.270,Apply regex on Solr query?,"I have got indexes created on tables having data of the form: indexname='text'---->Today is a great day for running in the park. Now i want to perform a search on the indexes where only 'day' or 'run' is appearing in the text. I have implemented query like : q = 'text:(day or run*)' -But this query is not returning me any results from indexes.Is this correct way?or how can i improve my query by applying regex ?","Regex and wildcards are slow in search engines. You'll get better performance by pre-processing the terms in a language-sensitive way. -You can match ""run"" to ""running"" with a stemmer, an analysis step that reduces different forms of a word to a common stem. When the query and the index term are both stemmed, then they will match. -You should also look into the Extended Dismax (edismax) search handler. That will do some of the work of turning ""day run"" into a search for the individual words and the phrase, something like 'day OR run OR ""day run""'. Then it can further expand that against multiple fields with different weights, all automatically.",0.0,False,2,1844 +But this query is not returning me any results from indexes.Is this correct way?or how can i improve my query by applying regex ?",Your use case is very basic and doesn't require regex at all with Solr. It looks like you just may have a syntax issue. q=text:day OR text:run should do exactly what you're looking for.,0.2012947653214861,False,2,1844 2012-05-03 16:40:55.700,"Python installation mess on Mac OS X, cannot run python","I stupidly downloaded python 3.2.2 and since then writing 'python' in the terminal yields 'command not found'. Also, when starting the terminal I get this: Last login: Wed May 2 23:17:28 on ttys001 -bash: export: `folder]:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/usr/local/git/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Applications/android-sdk-mac_86/tools:/Applications/android-sdk-mac_86/platform-tools:/usr/local/git/bin:/usr/X11/bin:/usr/local/ant/bin': not a valid identifier @@ -19987,10 +19987,6 @@ Why not just use a collection to list expired events in the other location?",1.2 2012-05-04 14:59:11.117,Django: How can I find methods/functions filling in the specific template,"Say, I find some bug in a web interface. I open firebug and discover element and class, id of this element. By them I can then identify a template which contains variables, tags and so on. How can I move forward and reveal in which .py files these variables are filled in? I know how it works in Lift framework: when you've found a template there are elements with attributes bound to snippets. So you can easily proceed to specific snippets and edit code. -How does it work in django? May be, I suppose wrong process... then point me to the right algorithm, please.","In well designed django, you should only have to edit the template. Good design provides clean separation. It's possible the developer may have been forced todo something unusual...but you could try to edit the template and see what happens (make backup 1st)",0.2012947653214861,False,2,1848 -2012-05-04 14:59:11.117,Django: How can I find methods/functions filling in the specific template,"Say, I find some bug in a web interface. I open firebug and discover element and class, id of this element. By them I can then identify a template which contains variables, tags and so on. -How can I move forward and reveal in which .py files these variables are filled in? -I know how it works in Lift framework: when you've found a template there are elements with attributes bound to snippets. So you can easily proceed to specific snippets and edit code. How does it work in django? May be, I suppose wrong process... then point me to the right algorithm, please.","Determining template variable resolution is all about Context. Use the URL to identify the view being invoked. @@ -19999,6 +19995,10 @@ Look at settings.py for the list of TEMPLATE_CONTEXT_PROCESSORS. These are routi Check to see if there are any magic template tags being called (either in the template in question, in a template it extends, or in a template that includes the template) that might be modifying the Context. Sometimes I need use an old-school django snippet called {%expr%} that can do evaluation in the template, but I always use it as close to the point of need as possible to highlight the fact it is being used. Note that because of the way Django template variables are resolved, {{foo.something}} could be either a value or a callable method. I have serious issues with this syntax, but that's the way they wrote it.",1.2,True,2,1848 +2012-05-04 14:59:11.117,Django: How can I find methods/functions filling in the specific template,"Say, I find some bug in a web interface. I open firebug and discover element and class, id of this element. By them I can then identify a template which contains variables, tags and so on. +How can I move forward and reveal in which .py files these variables are filled in? +I know how it works in Lift framework: when you've found a template there are elements with attributes bound to snippets. So you can easily proceed to specific snippets and edit code. +How does it work in django? May be, I suppose wrong process... then point me to the right algorithm, please.","In well designed django, you should only have to edit the template. Good design provides clean separation. It's possible the developer may have been forced todo something unusual...but you could try to edit the template and see what happens (make backup 1st)",0.2012947653214861,False,2,1848 2012-05-05 16:19:40.270,Multiple key press detection wxPython,"I am creating a Project Manager using wxPython it has a splitter window. On one side is a tree that shows the names of and opens the files and on the other size is a textctrl that is used to edit the file. One problem I am having is that I would like it to go back 4 spaces when SHIFT and TAB are pressed, I have code working that add's 4 spaces when TAB is pressed. I am also have a problem that when I add a file that is in a different folder to my programs cwd the tree adds a new node and the file appears under this node and I am struggling to get the tree to save to a file. @@ -20046,8 +20046,10 @@ The people I'm working with have traditionally tackled everything in Excel (gene I've been learning SQLite but am starting to fear that the kinds of things I want to do will be pretty complicated. I've also been learning Python (for unrelated reasons) and am kind of wondering if an ORM tool and some Python code might be the better way to go. And then there's something like Access (which I don't have but would possibly be willing to get if it's a sweet spot for this kind of thing). -In summary, I'd love to know how hard these kinds of analysis would be to do overall and which tools would best be suited for the job. I'm completely open to the idea that I'm thinking about some of or all of the problem in a way that's backwards and would welcome any advice on any aspect of what I've written here.","You have a quite small dataset, so you do not need any kind of ORM really, just load all data in Python and chew a report of it. -SQL as a language is horrible for a more complex data analysis (e.g. where you really want to crosstabulate things etc).",0.1016881243684853,False,3,1855 +In summary, I'd love to know how hard these kinds of analysis would be to do overall and which tools would best be suited for the job. I'm completely open to the idea that I'm thinking about some of or all of the problem in a way that's backwards and would welcome any advice on any aspect of what I've written here.","Go with SQL! It is very powerful for data analysis. It will allow you to ask questions in the future about the data. Questions that you have not yet thought of. +Although SQL as a language may seem a bit cumbersome, it is much easier to use than a ""real"" programming language. In your case, SQL interfaces to Excel, so users can get access to the data through a tool they are familiar with. +If you do go with SQL, a real database (SQLLite) is a better solution than MSAccess. +I feel strongly enough in SQL as an analysis tool that I wrote a book on the subject, ""Data Analysis Using SQL and Excel"". You might check out the Amazon comments (http://www.amazon.com/Data-Analysis-Using-SQL-Excel/dp/0470099518/ref=pd_sim_b_1) to understand how effective it can be.",0.0,False,3,1855 2012-05-09 18:49:49.863,Best approach to doing analysis of sets of tags?,"I have thousands of survey responses that have been tagged according to the content of the response. Each response can have one tag or many (up to 20), and the tags are independent of one another rather than being structured into category-subcategory or something. I want to be able to do analysis like the following: @@ -20061,10 +20063,8 @@ The people I'm working with have traditionally tackled everything in Excel (gene I've been learning SQLite but am starting to fear that the kinds of things I want to do will be pretty complicated. I've also been learning Python (for unrelated reasons) and am kind of wondering if an ORM tool and some Python code might be the better way to go. And then there's something like Access (which I don't have but would possibly be willing to get if it's a sweet spot for this kind of thing). -In summary, I'd love to know how hard these kinds of analysis would be to do overall and which tools would best be suited for the job. I'm completely open to the idea that I'm thinking about some of or all of the problem in a way that's backwards and would welcome any advice on any aspect of what I've written here.","Go with SQL! It is very powerful for data analysis. It will allow you to ask questions in the future about the data. Questions that you have not yet thought of. -Although SQL as a language may seem a bit cumbersome, it is much easier to use than a ""real"" programming language. In your case, SQL interfaces to Excel, so users can get access to the data through a tool they are familiar with. -If you do go with SQL, a real database (SQLLite) is a better solution than MSAccess. -I feel strongly enough in SQL as an analysis tool that I wrote a book on the subject, ""Data Analysis Using SQL and Excel"". You might check out the Amazon comments (http://www.amazon.com/Data-Analysis-Using-SQL-Excel/dp/0470099518/ref=pd_sim_b_1) to understand how effective it can be.",0.0,False,3,1855 +In summary, I'd love to know how hard these kinds of analysis would be to do overall and which tools would best be suited for the job. I'm completely open to the idea that I'm thinking about some of or all of the problem in a way that's backwards and would welcome any advice on any aspect of what I've written here.","You have a quite small dataset, so you do not need any kind of ORM really, just load all data in Python and chew a report of it. +SQL as a language is horrible for a more complex data analysis (e.g. where you really want to crosstabulate things etc).",0.1016881243684853,False,3,1855 2012-05-09 18:49:49.863,Best approach to doing analysis of sets of tags?,"I have thousands of survey responses that have been tagged according to the content of the response. Each response can have one tag or many (up to 20), and the tags are independent of one another rather than being structured into category-subcategory or something. I want to be able to do analysis like the following: @@ -20141,54 +20141,6 @@ Redis Any other option ? -Which from above is the right way to go ? -How will you compare memcache and redis ? -Update: - -My dictionary is about 5 MB in size and will grow over time. -Using Redis/Memcache adds an overhead of hitting a socket every-time, so would dump.py will be better since it would take time to load it to memory but after that it would only do memory lookups. -My dictionary needs to be updated every day, considering that dump.py will be problem, since we have to restart the django-server to reload where as I guess it would reflect on the fly in redis and memcache. -One uses a system like redis only when you have large amount of data and you have to lookup very frequently, in that case socket gives a overhead so, how do we achieve the advantage ? - -Please share your experiences on this !","Memcached, though a great product, is trumped by Redis in my book. It offers lots of things that memcached doesn't, like persistence. -It also offers more complex data structures like hashses. What is your particular data dump? How big is it, and how large / what type of values?",0.2012947653214861,False,3,1863 -2012-05-15 06:13:26.763,Maintain a large dictionary in memory for Django-Python?,"I have a big key-value pair dump, that I need to lookup for my django-Python webapp. -So, I have following options: - -Store it as json dump and load it as a python dict. -Store it in a dump.py and import the dict from it. -Use some targeted systems for this problem: [ Are these really meant for this usecase ? ] - -Mem-cache -Redis -Any other option ? - - -Which from above is the right way to go ? -How will you compare memcache and redis ? -Update: - -My dictionary is about 5 MB in size and will grow over time. -Using Redis/Memcache adds an overhead of hitting a socket every-time, so would dump.py will be better since it would take time to load it to memory but after that it would only do memory lookups. -My dictionary needs to be updated every day, considering that dump.py will be problem, since we have to restart the django-server to reload where as I guess it would reflect on the fly in redis and memcache. -One uses a system like redis only when you have large amount of data and you have to lookup very frequently, in that case socket gives a overhead so, how do we achieve the advantage ? - -Please share your experiences on this !","In past for a similar problem I have used the idea of a dump.py . I would think that all of the other data structures would require a layer to convert objects of one kind into python objects . However I would still think that this would depend on data size and the amount of data you are handling . Memcache and redis should have better indexing and look up when it comes to really large data sets and things like regex based lookup . So my recommendation would be -json -- if you are serving the data over http to some other service -python file - if data structure is not too large and you need not any special kind of look ups -memcache and redis -- if the data becomes really large",0.1016881243684853,False,3,1863 -2012-05-15 06:13:26.763,Maintain a large dictionary in memory for Django-Python?,"I have a big key-value pair dump, that I need to lookup for my django-Python webapp. -So, I have following options: - -Store it as json dump and load it as a python dict. -Store it in a dump.py and import the dict from it. -Use some targeted systems for this problem: [ Are these really meant for this usecase ? ] - -Mem-cache -Redis -Any other option ? - - Which from above is the right way to go ? How will you compare memcache and redis ? Update: @@ -20200,11 +20152,61 @@ One uses a system like redis only when you have large amount of data and you hav Please share your experiences on this !","5Mb isn't that large. You could keep it in memory in process, and I recommend that you do, until it becomes clear from profiling and testing that that approach isn't meeting your needs. Always do the simplest thing possible. Socket communication doesn't of itself introduce much of an overhead. You could probably pare it back a little by using a unix domain socket. In any case, if you're not keeping your data in process, you're going to have to talk over some kind of pipe.",0.1016881243684853,False,3,1863 +2012-05-15 06:13:26.763,Maintain a large dictionary in memory for Django-Python?,"I have a big key-value pair dump, that I need to lookup for my django-Python webapp. +So, I have following options: + +Store it as json dump and load it as a python dict. +Store it in a dump.py and import the dict from it. +Use some targeted systems for this problem: [ Are these really meant for this usecase ? ] + +Mem-cache +Redis +Any other option ? + + +Which from above is the right way to go ? +How will you compare memcache and redis ? +Update: + +My dictionary is about 5 MB in size and will grow over time. +Using Redis/Memcache adds an overhead of hitting a socket every-time, so would dump.py will be better since it would take time to load it to memory but after that it would only do memory lookups. +My dictionary needs to be updated every day, considering that dump.py will be problem, since we have to restart the django-server to reload where as I guess it would reflect on the fly in redis and memcache. +One uses a system like redis only when you have large amount of data and you have to lookup very frequently, in that case socket gives a overhead so, how do we achieve the advantage ? + +Please share your experiences on this !","In past for a similar problem I have used the idea of a dump.py . I would think that all of the other data structures would require a layer to convert objects of one kind into python objects . However I would still think that this would depend on data size and the amount of data you are handling . Memcache and redis should have better indexing and look up when it comes to really large data sets and things like regex based lookup . So my recommendation would be +json -- if you are serving the data over http to some other service +python file - if data structure is not too large and you need not any special kind of look ups +memcache and redis -- if the data becomes really large",0.1016881243684853,False,3,1863 +2012-05-15 06:13:26.763,Maintain a large dictionary in memory for Django-Python?,"I have a big key-value pair dump, that I need to lookup for my django-Python webapp. +So, I have following options: + +Store it as json dump and load it as a python dict. +Store it in a dump.py and import the dict from it. +Use some targeted systems for this problem: [ Are these really meant for this usecase ? ] + +Mem-cache +Redis +Any other option ? + + +Which from above is the right way to go ? +How will you compare memcache and redis ? +Update: + +My dictionary is about 5 MB in size and will grow over time. +Using Redis/Memcache adds an overhead of hitting a socket every-time, so would dump.py will be better since it would take time to load it to memory but after that it would only do memory lookups. +My dictionary needs to be updated every day, considering that dump.py will be problem, since we have to restart the django-server to reload where as I guess it would reflect on the fly in redis and memcache. +One uses a system like redis only when you have large amount of data and you have to lookup very frequently, in that case socket gives a overhead so, how do we achieve the advantage ? + +Please share your experiences on this !","Memcached, though a great product, is trumped by Redis in my book. It offers lots of things that memcached doesn't, like persistence. +It also offers more complex data structures like hashses. What is your particular data dump? How big is it, and how large / what type of values?",0.2012947653214861,False,3,1863 2012-05-15 08:55:21.377,install python and make in cygwin,"I have installed Cygwin Terminal in OS Windows. But I need to install also python and make in cygwin.All of these programs are needed to run petsc library. -Does Someone know how to install these components in cygwin?","Here is a command line version to install python in cygwin -wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg -install apt-cyg /bin -apt-cyg install python",0.3275988531455109,False,5,1864 +Does Someone know how to install these components in cygwin?",@spacediver is right on. Run cygwin's setup.exe again and when you get to the packages screen make sure you select make and python (and any other libs/apps you may need - perhaps gcc or g++).,0.3869120172231254,False,5,1864 +2012-05-15 08:55:21.377,install python and make in cygwin,"I have installed Cygwin Terminal in OS Windows. But I need to install also python and make in cygwin.All of these programs are needed to run petsc library. +Does Someone know how to install these components in cygwin?","Look into cygwin native package manager, devel category. You should find make and python there.",0.6730655149877884,False,5,1864 +2012-05-15 08:55:21.377,install python and make in cygwin,"I have installed Cygwin Terminal in OS Windows. But I need to install also python and make in cygwin.All of these programs are needed to run petsc library. +Does Someone know how to install these components in cygwin?","In my case, it was happened due to python is not well installed. So python.exe is referenced in the shell so it can't find the file because the system is different. +Please check cygwin python is well installed.",0.0,False,5,1864 2012-05-15 08:55:21.377,install python and make in cygwin,"I have installed Cygwin Terminal in OS Windows. But I need to install also python and make in cygwin.All of these programs are needed to run petsc library. Does Someone know how to install these components in cygwin?","After running into this problem myself, I was overlooking all of the relevant answers saying to check the setup.exe again. This was the solution to me, there are a few specific things to check. @@ -20212,12 +20214,10 @@ Check /bin for ""make.exe"". If it's not there, you have not installed it correc Run the setup.exe. Don't be afraid, as new package installs append to your installation and do not over write In the setup.exe, make sure you run the install from the Internet and NOT your local folder. This was where I was running into problems. Search ""make"" and make sure you select to Install it, do not leave this as ""Default"".",0.4431875092007125,False,5,1864 2012-05-15 08:55:21.377,install python and make in cygwin,"I have installed Cygwin Terminal in OS Windows. But I need to install also python and make in cygwin.All of these programs are needed to run petsc library. -Does Someone know how to install these components in cygwin?","In my case, it was happened due to python is not well installed. So python.exe is referenced in the shell so it can't find the file because the system is different. -Please check cygwin python is well installed.",0.0,False,5,1864 -2012-05-15 08:55:21.377,install python and make in cygwin,"I have installed Cygwin Terminal in OS Windows. But I need to install also python and make in cygwin.All of these programs are needed to run petsc library. -Does Someone know how to install these components in cygwin?","Look into cygwin native package manager, devel category. You should find make and python there.",0.6730655149877884,False,5,1864 -2012-05-15 08:55:21.377,install python and make in cygwin,"I have installed Cygwin Terminal in OS Windows. But I need to install also python and make in cygwin.All of these programs are needed to run petsc library. -Does Someone know how to install these components in cygwin?",@spacediver is right on. Run cygwin's setup.exe again and when you get to the packages screen make sure you select make and python (and any other libs/apps you may need - perhaps gcc or g++).,0.3869120172231254,False,5,1864 +Does Someone know how to install these components in cygwin?","Here is a command line version to install python in cygwin +wget rawgit.com/transcode-open/apt-cyg/master/apt-cyg +install apt-cyg /bin +apt-cyg install python",0.3275988531455109,False,5,1864 2012-05-15 19:16:42.843,Modular serialization with pickle (Python),"I want to perform serialisation of some object graph in a modular way. That is I don't want to serialize the whole graph. The reason is that this graph is big. I can keep timestamped version of some part of the graph, and i can do some lazy access to postpone loading of the parts i don't need right now. I thought i could manage this with metaprogramming in Python. But it seems that metaprogramming is not strong enough in Python. Here's what i do for now. My graph is composed of several different objects. Some of them are instances of a special class. This class describes the root object to be pickled. This is where the modularity come in. Each time i pickle something it starts from one of those instances and i never pickle two of them at the same time. Whenever there is a reference to another instance, accessible by the root object, I replace this reference by a persistant_id, thus ensuring that i won't have two of them in the same pickling stream. The problem comes when unpickling the stream. I can found a persistant_id of an instance which is not loaded yet. When this is the case, i have to wait for the target instance to be loaded before allowing access to it. And i don't see anyway to do that : @@ -20254,13 +20254,7 @@ For that reason, it's not very useful to explore branches from moves that you ma while python time.time() will give something like 1337203880.462787 how can i convert time.time()'s value to something match up to System.nanoTime()?","Divide the output of System.nanoTime() by 10^9. This is because it is in nanoseconds, while the output of time.time() is in seconds.",0.0,False,1,1868 2012-05-16 23:52:03.663,Inserting image into IPython notebook markdown,"I am starting to depend heavily on the IPython notebook app to develop and document algorithms. It is awesome; but there is something that seems like it should be possible, but I can't figure out how to do it: -I would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm. I know enough to add something like to the markdown, but that is about as far as my knowledge goes. I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is. (I'm working on a mac.) So, is it possible to do what I'm trying to do without too much trouble?","minrk's answer is right. -However, I found that the images appeared broken in Print View (on my Windows machine running the Anaconda distribution of IPython version 0.13.2 in a Chrome browser) -The workaround for this was to use instead. -This made the image appear correctly in both Print View and the normal iPython editing view. -UPDATE: as of my upgrade to iPython v1.1.0 there is no more need for this workaround since the print view no longer exists. In fact, you must avoid this workaround since it prevents the nbconvert tool from finding the files.",0.0872412088103126,False,5,1869 -2012-05-16 23:52:03.663,Inserting image into IPython notebook markdown,"I am starting to depend heavily on the IPython notebook app to develop and document algorithms. It is awesome; but there is something that seems like it should be possible, but I can't figure out how to do it: -I would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm. I know enough to add something like to the markdown, but that is about as far as my knowledge goes. I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is. (I'm working on a mac.) So, is it possible to do what I'm trying to do without too much trouble?",Last version of jupyter notebook accepts copy/paste of image natively,0.283556384140347,False,5,1869 +I would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm. I know enough to add something like to the markdown, but that is about as far as my knowledge goes. I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is. (I'm working on a mac.) So, is it possible to do what I'm trying to do without too much trouble?",You can find your current working directory by 'pwd' command in jupyter notebook without quotes.,-0.1160922760327606,False,5,1869 2012-05-16 23:52:03.663,Inserting image into IPython notebook markdown,"I am starting to depend heavily on the IPython notebook app to develop and document algorithms. It is awesome; but there is something that seems like it should be possible, but I can't figure out how to do it: I would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm. I know enough to add something like to the markdown, but that is about as far as my knowledge goes. I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is. (I'm working on a mac.) So, is it possible to do what I'm trying to do without too much trouble?","Getting an image into Jupyter NB is a much simpler operation than most people have alluded to here. @@ -20280,7 +20274,13 @@ This simple ""Drag-and-Drop-from-Windows-File-System"" method still works fine i This stopped working in Jupyter Classic Notebook v6.1.5 sometime last year. I reported an bug notice to the Jupyter Classic Notebook developers. It works again in the latest version of Jupyter Classic Notebook. I just tried it in v6.4 on 7/15/2021. Thank you Jupyter NB Classic Developers !!",0.9997153180676276,False,5,1869 2012-05-16 23:52:03.663,Inserting image into IPython notebook markdown,"I am starting to depend heavily on the IPython notebook app to develop and document algorithms. It is awesome; but there is something that seems like it should be possible, but I can't figure out how to do it: -I would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm. I know enough to add something like to the markdown, but that is about as far as my knowledge goes. I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is. (I'm working on a mac.) So, is it possible to do what I'm trying to do without too much trouble?",You can find your current working directory by 'pwd' command in jupyter notebook without quotes.,-0.1160922760327606,False,5,1869 +I would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm. I know enough to add something like to the markdown, but that is about as far as my knowledge goes. I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is. (I'm working on a mac.) So, is it possible to do what I'm trying to do without too much trouble?",Last version of jupyter notebook accepts copy/paste of image natively,0.283556384140347,False,5,1869 +2012-05-16 23:52:03.663,Inserting image into IPython notebook markdown,"I am starting to depend heavily on the IPython notebook app to develop and document algorithms. It is awesome; but there is something that seems like it should be possible, but I can't figure out how to do it: +I would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm. I know enough to add something like to the markdown, but that is about as far as my knowledge goes. I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is. (I'm working on a mac.) So, is it possible to do what I'm trying to do without too much trouble?","minrk's answer is right. +However, I found that the images appeared broken in Print View (on my Windows machine running the Anaconda distribution of IPython version 0.13.2 in a Chrome browser) +The workaround for this was to use instead. +This made the image appear correctly in both Print View and the normal iPython editing view. +UPDATE: as of my upgrade to iPython v1.1.0 there is no more need for this workaround since the print view no longer exists. In fact, you must avoid this workaround since it prevents the nbconvert tool from finding the files.",0.0872412088103126,False,5,1869 2012-05-16 23:52:03.663,Inserting image into IPython notebook markdown,"I am starting to depend heavily on the IPython notebook app to develop and document algorithms. It is awesome; but there is something that seems like it should be possible, but I can't figure out how to do it: I would like to insert a local image into my (local) IPython notebook markdown to aid in documenting an algorithm. I know enough to add something like to the markdown, but that is about as far as my knowledge goes. I assume I could put the image in the directory represented by 127.0.0.1:8888 (or some subdirectory) to be able to access it, but I can't figure out where that directory is. (I'm working on a mac.) So, is it possible to do what I'm trying to do without too much trouble?","I never could get ""insert image"" into a markdown cell to work. However, the drag and drop entered the png file saved in the same directory as my notebook. It brought this text into the cell """" @@ -20351,17 +20351,17 @@ I have modulus n and private exponent d. From what I understand after reading so I 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). So here is my question. Do I have to compute e somehow in order to sign a message? It 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? -Thanks in advance.","No, you can't compute e from d. -RSA 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. -Of course, if you have the private key that means that you generated the keypair, which means that you have the public key somewhere.",0.3869120172231254,False,2,1876 +Thanks in advance.","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). +[EDIT] Simply sign with the private key and verify with the public key to see if the public key is correct. +Note: 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.",0.2655860252697744,False,2,1876 2012-05-21 16:49:42.467,I have modulus and private exponent. How to construct RSA private key and sign a message?,"I am newbie in cryptography and pycrypto. I have modulus n and private exponent d. From what I understand after reading some docs private key consists of n and d. I 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). So here is my question. Do I have to compute e somehow in order to sign a message? It 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? -Thanks in advance.","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). -[EDIT] Simply sign with the private key and verify with the public key to see if the public key is correct. -Note: 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.",0.2655860252697744,False,2,1876 +Thanks in advance.","No, you can't compute e from d. +RSA 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. +Of course, if you have the private key that means that you generated the keypair, which means that you have the public key somewhere.",0.3869120172231254,False,2,1876 2012-05-22 07:32:18.040,queues remain unknown or just don't know how to call them,"I've added a new queue to a python GAE app, and would like to add tasks to it, but always get an UnknownQueueError when I run my tests. On the other hand, I see the queue present in the GAE admin console (both local and remote). So the question is (1) do I miss something when I add a task to my queue? (2) if not, then how can I run custom queues in a test? Here is my queue.yaml @@ -20381,6 +20381,12 @@ any ideas?",If your are running a unitest and using init_taskqueue_stub() you ne 2012-05-24 10:50:00.980,Using a Ruby gem from a Django application,"Lets say I have a few Ruby gems that I'd like to use from my Python (Django) application. I know this isn't the most straightforward question but let's assume that rewriting the Ruby gem in Python is a lot of work, how can I use it? Should I create an XML-RPC wrapper around it using Rails and call it? Is there something like a ruby implementation in Python within which I could run my gem code? Are there other methods that I may have missed? I've never tacked anything like this before I was a bit lost in this area. +Thanks","It depends a little on what you need to do. The XML-RPC suggestion has already been made. +You might actually be able to use them together in a JVM, assuming you can accept running Django with jython and use jruby. But that is a bit of work, which may or may not be worth the effort. +It would perhaps be easier if you described exactly what the Ruby gem is and what problem it is supposed to solve. You might get suggestions that could help you avoid the problem altogether.",0.5457054096481145,False,2,1879 +2012-05-24 10:50:00.980,Using a Ruby gem from a Django application,"Lets say I have a few Ruby gems that I'd like to use from my Python (Django) application. I know this isn't the most straightforward question but let's assume that rewriting the Ruby gem in Python is a lot of work, how can I use it? +Should I create an XML-RPC wrapper around it using Rails and call it? Is there something like a ruby implementation in Python within which I could run my gem code? +Are there other methods that I may have missed? I've never tacked anything like this before I was a bit lost in this area. Thanks","I suggest you either: Expose a ruby service using REST or XML-RPC. @@ -20391,12 +20397,6 @@ Shell out to a ruby script from Django. To transfer data between Python and Ruby I suggest you use JSON, XML or plain text (depending on what kind of data you need to transfer). I would recommend to use option 2 (start a ruby script from the Python process), as this introduces fewer moving parts to the solution.",1.2,True,2,1879 -2012-05-24 10:50:00.980,Using a Ruby gem from a Django application,"Lets say I have a few Ruby gems that I'd like to use from my Python (Django) application. I know this isn't the most straightforward question but let's assume that rewriting the Ruby gem in Python is a lot of work, how can I use it? -Should I create an XML-RPC wrapper around it using Rails and call it? Is there something like a ruby implementation in Python within which I could run my gem code? -Are there other methods that I may have missed? I've never tacked anything like this before I was a bit lost in this area. -Thanks","It depends a little on what you need to do. The XML-RPC suggestion has already been made. -You might actually be able to use them together in a JVM, assuming you can accept running Django with jython and use jruby. But that is a bit of work, which may or may not be worth the effort. -It would perhaps be easier if you described exactly what the Ruby gem is and what problem it is supposed to solve. You might get suggestions that could help you avoid the problem altogether.",0.5457054096481145,False,2,1879 2012-05-24 21:13:17.310,Ubuntu Linux: terminal limits the output when I get the full Twitter Streaming API,"I have this python script that outputs the Twitter Stream to my terminal console. Now here is the interesting thing: * On snowleopard I get all the data I want. * On Ubuntu (my pc) this data is limited and older data is deleted. @@ -20486,14 +20486,14 @@ Alternatively, you could create several ""detached"" signatures, each of just th For my current situation I think I want to use alpha values but am not quite clear how. In my game I have two sprites with .png files loaded to each surface. Upon collision I would like both images to disappear (go completely transparent). I would really appreciate it if someone could explain the basics of alpha value and how to specifically use them in pygame and if it is possible to use these alpha values to solve my problem. -Thanks!","Colorkey lets you pick one color in a sprite (surface); any pixel of that color will be completely transparent. (If you remember .gif transparency, it's the same idea.) -'alpha' is a measure of opacity - 0 for completely transparent, 255 for completely opaque - and can be applied to an entire sprite (as an alpha plane) or per pixel (slower, but gives much more control). -To make the sprites disappear, I would just set them to non-visible, rather than playing around with alpha values.",0.5457054096481145,False,2,1891 +Thanks!","Although if you want the sprites to fade until they've vanished, gradually reduce the alpha value after they've collided. When alpha reaches 0, use del sprite if you don't need the sprites anymore.",0.0,False,2,1891 2012-05-30 19:52:53.463,Pygame alpha values,"I am new to using pygame and I was wondering if someone could explain the use of alpha values? I don't quite understand the difference between that and colorkey. For my current situation I think I want to use alpha values but am not quite clear how. In my game I have two sprites with .png files loaded to each surface. Upon collision I would like both images to disappear (go completely transparent). I would really appreciate it if someone could explain the basics of alpha value and how to specifically use them in pygame and if it is possible to use these alpha values to solve my problem. -Thanks!","Although if you want the sprites to fade until they've vanished, gradually reduce the alpha value after they've collided. When alpha reaches 0, use del sprite if you don't need the sprites anymore.",0.0,False,2,1891 +Thanks!","Colorkey lets you pick one color in a sprite (surface); any pixel of that color will be completely transparent. (If you remember .gif transparency, it's the same idea.) +'alpha' is a measure of opacity - 0 for completely transparent, 255 for completely opaque - and can be applied to an entire sprite (as an alpha plane) or per pixel (slower, but gives much more control). +To make the sprites disappear, I would just set them to non-visible, rather than playing around with alpha values.",0.5457054096481145,False,2,1891 2012-05-30 22:08:01.730,Where does Python Imaging LIbrary Save Objects,"I am using the Image.save method from PIL and I cannot find where the file is being placed. I have done a system search yet still no luck. My code looks like this: print imageObj.save(fileName, ""JPEG"") @@ -20599,10 +20599,6 @@ If the user has a Python interpreter on their system, they they can simply run t If 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. However. 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.",0.0,False,1,1903 2012-06-06 18:43:18.950,Recommendation system - using different metrics,"I'm looking to implement an item-based news recommendation system. There are several ways I want to track a user's interest in a news item; they include: rating (1-5), favorite, click-through, and time spent on news item. -My question: what are some good methods to use these different metrics for the recommendation system? Maybe merge and normalize them in some way?","Recommender systems in the land of research generally work on a scale of 1 - 5. It's quite nice to get such an explicit signal from a user. However I'd imagine the reality is that most users of your system would never actually give a rating, in which case you have nothing to work with. -Therefore I'd track page views but also try and incorporate some explicit feedback mechanism (1-5, thumbs up or down etc.) -Your algorithm will have to take this into consideration.",0.0,False,2,1904 -2012-06-06 18:43:18.950,Recommendation system - using different metrics,"I'm looking to implement an item-based news recommendation system. There are several ways I want to track a user's interest in a news item; they include: rating (1-5), favorite, click-through, and time spent on news item. My question: what are some good methods to use these different metrics for the recommendation system? Maybe merge and normalize them in some way?","For recommendation system, there are two problems: how to quantify the user's interest in a certain item based on the numbers you collected @@ -20611,6 +20607,10 @@ how to use the quantified interest data to recommend new items to the user I guess you are more interested in the first problem. To solve the first problem, you need either linear combination or some other fancy functions to combine all the numbers. There is really no a single universal function for all systems. It heavily depends on the type of your users and your items. If you want a high quality recommandation system, you need to have some data to do machine learning to train your functions. For the second problem, it's somehow the same thing, plus you need to analyze all the items to abstract some relationships between each other. You can google ""Netflix prize"" for some interesting info.",0.0,False,2,1904 +2012-06-06 18:43:18.950,Recommendation system - using different metrics,"I'm looking to implement an item-based news recommendation system. There are several ways I want to track a user's interest in a news item; they include: rating (1-5), favorite, click-through, and time spent on news item. +My question: what are some good methods to use these different metrics for the recommendation system? Maybe merge and normalize them in some way?","Recommender systems in the land of research generally work on a scale of 1 - 5. It's quite nice to get such an explicit signal from a user. However I'd imagine the reality is that most users of your system would never actually give a rating, in which case you have nothing to work with. +Therefore I'd track page views but also try and incorporate some explicit feedback mechanism (1-5, thumbs up or down etc.) +Your algorithm will have to take this into consideration.",0.0,False,2,1904 2012-06-07 09:39:09.730,How to simply create a list of CheckBox which has a dropdown list like a ComboBox with PyQt?,"I'm new to PyQt and I have to work on an application which use it. For the moment, I don't have any problem, but I'm stuck on something. I have to create a ""ComboBox with its items checkable, like a CheckBox"". This ComboBox should contain many image format, like ""jpg"", ""exr"" or ""tga"", and I will have to pick up the text of the checked option and put it in a variable. The problem is that I can't find a thing about making items checkable using a ComboBox (if you know how to, It would gladly help me !) Since I can't do it with a ComboBox, maybe I can do it with a QList I thought, but I can't find anything either which is understandable for a beginner like me. I have read stuff about flags and ""Qt.ItemIsUserCheckable"" but I don't know how to use it in a easy way :( Can you help me ? Thanks ! @@ -20774,9 +20774,9 @@ The problem you describe is called multivariate regression, and usually for regr You could try something like group lasso (http://www.di.ens.fr/~fbach/grouplasso/index.htm - matlab) or sparse group lasso (http://spams-devel.gforge.inria.fr/ - seems to have a python interface), which solve the multivariate regression problem with different types of regularization.",0.6730655149877884,False,1,1924 2012-06-18 21:07:09.300,IDLE not integrated in desktop,"Just installed Python 2.7.3 on a Windows7 machine. How do I get .py files to be associated with python (they are with notepad ATM) and how do I get the context menu shortcut for ""edit in IDLE""? Somehow I didn't get that on this particular computer.","try making a .py file and then try to open it, and a window should appear asking you what to open it with, and then select idle in your program files.",1.2,True,1,1925 -2012-06-19 05:33:27.033,How do you run the Tornado web server locally?,Is it possible to run Tornado such that it listens to a local port (e.g. localhost:8000). I can't seem to find any documentation explaining how to do this.,If you want to daemonize tornado - use supervisord. If you want to access tornado on address like http://mylocal.dev/ - you should look at nginx and use it like reverse proxy. And on specific port it can be binded like in Lafada's answer.,0.0,False,2,1926 2012-06-19 05:33:27.033,How do you run the Tornado web server locally?,Is it possible to run Tornado such that it listens to a local port (e.g. localhost:8000). I can't seem to find any documentation explaining how to do this.,"Once you've defined an application (like in the other answers) in a file (for example server.py), you simply save and run that file. python server.py",0.1016881243684853,False,2,1926 +2012-06-19 05:33:27.033,How do you run the Tornado web server locally?,Is it possible to run Tornado such that it listens to a local port (e.g. localhost:8000). I can't seem to find any documentation explaining how to do this.,If you want to daemonize tornado - use supervisord. If you want to access tornado on address like http://mylocal.dev/ - you should look at nginx and use it like reverse proxy. And on specific port it can be binded like in Lafada's answer.,0.0,False,2,1926 2012-06-19 06:00:48.470,How to read other files in hadoop jobs?,"I need to read in a dictionary file to filter content specified in the hdfs_input, and I have uploaded it to the cluster using the put command, but I don't know how to access it in my program. I tried to access it using path on the cluster like normal files, but it gives the error information: IOError: [Errno 2] No such file or directory Besides, is there any way to maintain only one copy of the dictionary for all the machines that runs the job ? @@ -20810,7 +20810,9 @@ What formats would be best for this? I feel a full-blown database such as SQL wo From what I've seen, XML does not seem like the best option, as many seem to find it complex and difficult to work with effectively. JSON and YAML seem like either might work, but I don't know how easy it would be to edit either externally. Speed is not a primary concern in this case. While faster implementations are of course desirable, it is not a limiting factor to what I can use. -I've looked around both here and via Google, and while I've seen quite a bit on the topic, I have not been able to find anything specifically helpful to me. Will formats like JSON or YAML be sufficient for this, or would I be better served with a full-blown database?","Though there are good answers here already, I would simply recommend JSON for your purposes for the sole reason that since you're a new programmer it will be the most straightforward to read and translate as it has the most direct mapping to native Python data types (lists [] and dictionaries {}). Readability goes a long way and is one of the tenets of Python programming.",0.2497086294969975,False,3,1931 +I've looked around both here and via Google, and while I've seen quite a bit on the topic, I have not been able to find anything specifically helpful to me. Will formats like JSON or YAML be sufficient for this, or would I be better served with a full-blown database?","I would be tempted to research a little into some GUI that could output graphviz (DOT format) with annotations, so you could create the rooms and links between them (a sort of graph). Then later, you might want another format to support heftier info. +But should make it easy to create maps, links between rooms (containing items or traps etc..), and you could use common libraries to produce graphics of the maps in png or something. +Just a random idea off the top of my head - feel free to ignore!",0.0,False,3,1931 2012-06-20 23:59:54.870,Optimal format for simple data storage in python,"As a relatively new programmer, I have several times encountered situations where it would be beneficial for me to read and assemble program data from an external source rather than have it written in the code. This is mostly the case when there are a large number of objects of the same type. In such scenarios, object definitions quickly take up a lot of space in the code and add unnecessary impediment to readability. As an example, I've been working on text-based RPG, which has a large number of rooms and items of which to keep track. Even a few items and rooms leads to massive blocks of object creation code. I think it would be easier in this case to use some format of external data storage, reading from a file. In such a file, items and rooms would be stored by name and attributes, so that they could parsed into an object with relative ease. @@ -20818,9 +20820,7 @@ What formats would be best for this? I feel a full-blown database such as SQL wo From what I've seen, XML does not seem like the best option, as many seem to find it complex and difficult to work with effectively. JSON and YAML seem like either might work, but I don't know how easy it would be to edit either externally. Speed is not a primary concern in this case. While faster implementations are of course desirable, it is not a limiting factor to what I can use. -I've looked around both here and via Google, and while I've seen quite a bit on the topic, I have not been able to find anything specifically helpful to me. Will formats like JSON or YAML be sufficient for this, or would I be better served with a full-blown database?","I would be tempted to research a little into some GUI that could output graphviz (DOT format) with annotations, so you could create the rooms and links between them (a sort of graph). Then later, you might want another format to support heftier info. -But should make it easy to create maps, links between rooms (containing items or traps etc..), and you could use common libraries to produce graphics of the maps in png or something. -Just a random idea off the top of my head - feel free to ignore!",0.0,False,3,1931 +I've looked around both here and via Google, and while I've seen quite a bit on the topic, I have not been able to find anything specifically helpful to me. Will formats like JSON or YAML be sufficient for this, or would I be better served with a full-blown database?","Though there are good answers here already, I would simply recommend JSON for your purposes for the sole reason that since you're a new programmer it will be the most straightforward to read and translate as it has the most direct mapping to native Python data types (lists [] and dictionaries {}). Readability goes a long way and is one of the tenets of Python programming.",0.2497086294969975,False,3,1931 2012-06-21 01:32:33.530,top user authentication method for google app engine,"Having ease of implementation a strong factor but security also an issue what would the best user authentication method for google app engine be? My goal is to have a small very specific social network. I know how to make my own but making it hack-proof is a little out of my league right now. I have looked at OpenID and a few others. I am using Jinja2 as my template system and writing all of my web app code in python. Thanks!","Your choices are Google's own authentication, OpenID, some third party solution or roll your own. Unless you really know what you are doing, do not choose option 4! Authentication is very involved, and if you make a single mistake or omission you're opening yourself up to a lot of pain. Option 3 is not great because you have to ensure the author really knows what they are doing, which either means trusting them or... really knowing what you're doing! @@ -20843,11 +20843,13 @@ My question is, having those 2 projects in completely independent folders, how d thanks EDIT: Just another quick one. If both were inside their respective folder but with the same root. Would there be a better/easier way to do this?","Put the directory containing your module (let's call it functions.py) into the PYTHONPATH environment variable. Then you'll be able to use import functions to get your functions. Pip also seems to have support for this: pip install -e src/mycheckout for exxample, but I don't quite understand the ramifications of that.",1.2,True,1,1936 -2012-06-23 01:15:42.310,How to tell if you have multiple Django's installed,"In the process of trying to install django, I had a series of failures. I followed many different tutorials online and ended up trying to install it several times. I think I may have installed it twice (which the website said was not a good thing), so how do I tell if I actually have multiple versions installed? I have a Mac running Lion.",Check out virtualenv and virtualenvwrapper,0.5916962662253621,False,2,1937 2012-06-23 01:15:42.310,How to tell if you have multiple Django's installed,"In the process of trying to install django, I had a series of failures. I followed many different tutorials online and ended up trying to install it several times. I think I may have installed it twice (which the website said was not a good thing), so how do I tell if I actually have multiple versions installed? I have a Mac running Lion.","open terminal and type python then type import django then type django and it will tell you the path to the django you are importing. Goto that folder [it should look something like this: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/] and look for more than one instance of django(if there is more than one, they will be right next to each other). Delete the one(s) you don't want.",1.2,True,2,1937 +2012-06-23 01:15:42.310,How to tell if you have multiple Django's installed,"In the process of trying to install django, I had a series of failures. I followed many different tutorials online and ended up trying to install it several times. I think I may have installed it twice (which the website said was not a good thing), so how do I tell if I actually have multiple versions installed? I have a Mac running Lion.",Check out virtualenv and virtualenvwrapper,0.5916962662253621,False,2,1937 2012-06-23 15:46:23.330,How do I tell a Python script to use a particular version,"How do I, in the main.py module (presumably), tell Python which interpreter to use? What I mean is: if I want a particular script to use version 3 of Python to interpret the entire program, how do I do that? -Bonus: How would this affect a virtualenv? Am I right in thinking that if I create a virtualenv for my program and then tell it to use a different version of Python, then I may encounter some conflicts?","I had this problem and just decided to rename one of the programs from python.exe to python2.7.exe. Now I can specify on command prompt which program to run easily without introducing any scripts or changing environmental paths. -So i have two programs: python2.7 and python (the latter which is v.3.8 aka default).",-0.0509761841073563,False,3,1938 +Bonus: How would this affect a virtualenv? Am I right in thinking that if I create a virtualenv for my program and then tell it to use a different version of Python, then I may encounter some conflicts?","You can't do this within the Python program, because the shell decides which version to use if you a shebang line. +If you aren't using a shell with a shebang line and just type python myprogram.py it uses the default version unless you decide specifically which Python version when you type pythonXXX myprogram.py which version to use. +Once your Python program is running you have already decided which Python executable to use to get the program running. +virtualenv is for segregating python versions and environments, it specifically exists to eliminate conflicts.",0.0,False,3,1938 2012-06-23 15:46:23.330,How do I tell a Python script to use a particular version,"How do I, in the main.py module (presumably), tell Python which interpreter to use? What I mean is: if I want a particular script to use version 3 of Python to interpret the entire program, how do I do that? Bonus: How would this affect a virtualenv? Am I right in thinking that if I create a virtualenv for my program and then tell it to use a different version of Python, then I may encounter some conflicts?","While working with different versions of Python on Windows, I am using this method to switch between versions. @@ -20863,24 +20865,22 @@ and will find the python.exe at the path you did not suppressed, and will use this version after on) 5) switch between versions by playing with suffixes",-0.0509761841073563,False,3,1938 2012-06-23 15:46:23.330,How do I tell a Python script to use a particular version,"How do I, in the main.py module (presumably), tell Python which interpreter to use? What I mean is: if I want a particular script to use version 3 of Python to interpret the entire program, how do I do that? -Bonus: How would this affect a virtualenv? Am I right in thinking that if I create a virtualenv for my program and then tell it to use a different version of Python, then I may encounter some conflicts?","You can't do this within the Python program, because the shell decides which version to use if you a shebang line. -If you aren't using a shell with a shebang line and just type python myprogram.py it uses the default version unless you decide specifically which Python version when you type pythonXXX myprogram.py which version to use. -Once your Python program is running you have already decided which Python executable to use to get the program running. -virtualenv is for segregating python versions and environments, it specifically exists to eliminate conflicts.",0.0,False,3,1938 -2012-06-24 21:07:07.857,"Where should I declare a list of 5,000+ words?","I am writing a game in python in which I must periodically pull a random word from a list of words. When I prototyped my game I declared a word_list = ['cat','dog','rat','house'] of ten words at the top of one of my modules. I then use choice(word_list) to get a random word. However, I must must change this temporary hack into something more elegant because I need to increase the size of the word list to 5,000+ words. If I do this in my current module it will look ridiculous. -Should I put all of these words in a flat txt file, and then read from that file as I need words? If so, how would I best do that? Put each word an a separate line and then read one random line? I'm not sure what the most efficient way is.","Read the words from the file at startup (or at least the line indexes), and use as required.",0.296905446847765,False,2,1939 +Bonus: How would this affect a virtualenv? Am I right in thinking that if I create a virtualenv for my program and then tell it to use a different version of Python, then I may encounter some conflicts?","I had this problem and just decided to rename one of the programs from python.exe to python2.7.exe. Now I can specify on command prompt which program to run easily without introducing any scripts or changing environmental paths. +So i have two programs: python2.7 and python (the latter which is v.3.8 aka default).",-0.0509761841073563,False,3,1938 2012-06-24 21:07:07.857,"Where should I declare a list of 5,000+ words?","I am writing a game in python in which I must periodically pull a random word from a list of words. When I prototyped my game I declared a word_list = ['cat','dog','rat','house'] of ten words at the top of one of my modules. I then use choice(word_list) to get a random word. However, I must must change this temporary hack into something more elegant because I need to increase the size of the word list to 5,000+ words. If I do this in my current module it will look ridiculous. Should I put all of these words in a flat txt file, and then read from that file as I need words? If so, how would I best do that? Put each word an a separate line and then read one random line? I'm not sure what the most efficient way is.","I would create a separated module called random_words, or something like that, hiding the list inside it and encapsulating the choice(word_list) inside an interface function. As to load them from a file, well, since I would need to type them anyway, and a python file is just a text file in the end, I would type them right there, probably one per line for easy maintenance.",0.2012947653214861,False,2,1939 +2012-06-24 21:07:07.857,"Where should I declare a list of 5,000+ words?","I am writing a game in python in which I must periodically pull a random word from a list of words. When I prototyped my game I declared a word_list = ['cat','dog','rat','house'] of ten words at the top of one of my modules. I then use choice(word_list) to get a random word. However, I must must change this temporary hack into something more elegant because I need to increase the size of the word list to 5,000+ words. If I do this in my current module it will look ridiculous. +Should I put all of these words in a flat txt file, and then read from that file as I need words? If so, how would I best do that? Put each word an a separate line and then read one random line? I'm not sure what the most efficient way is.","Read the words from the file at startup (or at least the line indexes), and use as required.",0.296905446847765,False,2,1939 2012-06-27 00:39:01.710,Split quadrilateral into sub-regions of a maximum area,"It is pretty easy to split a rectangle/square into smaller regions and enforce a maximum area of each sub-region. You can just divide the region into regions with sides length sqrt(max_area) and treat the leftovers with some care. With a quadrilateral however I am stumped. Let's assume I don't know the angle of any of the corners. Let's also assume that all four points are on the same plane. Also, I don't need for the the small regions to be all the same size. The only requirement I have is that the area of each individual region is less than the max area. Is there a particular data structure I could use to make this easier? Is there an algorithm I'm just not finding? Could I use quadtrees to do this? I'm not incredibly versed in trees but I do know how to implement the structure. I have GIS work in mind when I'm doing this, but I am fairly confident that that will have no impact on the algorithm to split the quad.",You could recursively split the quad in half on the long sides until the resulting area is small enough.,0.2012947653214861,False,1,1940 -2012-06-27 09:27:35.880,Python + Sqlite 3. How to construct queries?,"I'm trying to create a python script that constructs valid sqlite queries. I want to avoid SQL Injection, so I cannot use '%s'. I've found how to execute queries, cursor.execute('sql ?', (param)), but I want how to get the parsed sql param. It's not a problem if I have to execute the query first in order to obtain the last query executed.","If you're trying to transmit changes to the database to another computer, why do they have to be expressed as SQL strings? Why not pickle the query string and the parameters as a tuple, and have the other machine also use SQLite parameterization to query its database?",1.2,True,3,1941 2012-06-27 09:27:35.880,Python + Sqlite 3. How to construct queries?,"I'm trying to create a python script that constructs valid sqlite queries. I want to avoid SQL Injection, so I cannot use '%s'. I've found how to execute queries, cursor.execute('sql ?', (param)), but I want how to get the parsed sql param. It's not a problem if I have to execute the query first in order to obtain the last query executed.","If you're not after just parameter substitution, but full construction of the SQL, you have to do that using string operations on your end. The ? replacement always just stands for a value. Internally, the SQL string is compiled to SQLite's own bytecode (you can find out what it generates with EXPLAIN thesql) and ? replacements are done by just storing the value at the correct place in the value stack; varying the query structurally would require different bytecode, so just replacing a value wouldn't be enough. Yes, this does mean you have to be ultra-careful. If you don't want to allow updates, try opening the DB connection in read-only mode.",0.1016881243684853,False,3,1941 +2012-06-27 09:27:35.880,Python + Sqlite 3. How to construct queries?,"I'm trying to create a python script that constructs valid sqlite queries. I want to avoid SQL Injection, so I cannot use '%s'. I've found how to execute queries, cursor.execute('sql ?', (param)), but I want how to get the parsed sql param. It's not a problem if I have to execute the query first in order to obtain the last query executed.","If you're trying to transmit changes to the database to another computer, why do they have to be expressed as SQL strings? Why not pickle the query string and the parameters as a tuple, and have the other machine also use SQLite parameterization to query its database?",1.2,True,3,1941 2012-06-27 09:27:35.880,Python + Sqlite 3. How to construct queries?,"I'm trying to create a python script that constructs valid sqlite queries. I want to avoid SQL Injection, so I cannot use '%s'. I've found how to execute queries, cursor.execute('sql ?', (param)), but I want how to get the parsed sql param. It's not a problem if I have to execute the query first in order to obtain the last query executed.","I want how to get the parsed 'sql param'. It's all open source so you have full access to the code doing the parsing / sanitization. Why not just reading this code and find out how it works and if there's some (possibly undocumented) implementation that you can reuse ?",0.0,False,3,1941 @@ -20904,12 +20904,12 @@ build using mingw build python 2.7 using VS 2008 express. i'm not sure regarding which version is good to build 3.2 but it could be VS 2010. you can compile python x64 from source using your desired VS, but u'll have competability issues with other pre built packages.",0.0,False,1,1944 +2012-07-01 05:20:58.823,Finding a unique url from a large list of URLs in O(n) time in a single pass,Recently I was asked this question in an interview. I gave an answer in O(n) time but in two passes. Also he asked me how to do the same if the url list cannot fit into the memory. Any help is very much appreciated.,"This is actually a classic interview question and the answer they were expecting was that you first sort the urls and then make a binary search. +If it doesn't fit in memory, you can do the same thing with a file.",-0.0814518047658113,False,2,1945 2012-07-01 05:20:58.823,Finding a unique url from a large list of URLs in O(n) time in a single pass,Recently I was asked this question in an interview. I gave an answer in O(n) time but in two passes. Also he asked me how to do the same if the url list cannot fit into the memory. Any help is very much appreciated.,"If it all fits in memory, then the problem is simple: Create two sets (choose your favorite data structure), both initially empty. One will contain unique URLs and the other will contain URLs that occur multiple times. Scan the URL list once. For each URL, if it exists in the unique set, remove it from the unique set and put it in the multiple set; otherwise, if it does not exist in the multiple set, add it to the unique set. If the set does not fit into memory, the problem is difficult. The requirement of O(n) isn't hard to meet, but the requirement of a ""single pass"" (which seems to exclude random access, among other things) is tough; I don't think it's possible without some constraints on the data. You can use the set approach with a size limit on the sets, but this would be easily defeated by unfortunate orderings of the data and would in any event only have a certain probability (<100%) of finding a unique element if one exists. EDIT: If you can design a set data structure that exists in mass storage (so it can be larger than would fit in memory) and can do find, insert, and deletes in O(1) (amortized) time, then you can just use that structure with the first approach to solve the second problem. Perhaps all the interviewer was looking for was to dump the URLs into a data base with a UNIQUE index for URLs and a count column.",1.2,True,2,1945 -2012-07-01 05:20:58.823,Finding a unique url from a large list of URLs in O(n) time in a single pass,Recently I was asked this question in an interview. I gave an answer in O(n) time but in two passes. Also he asked me how to do the same if the url list cannot fit into the memory. Any help is very much appreciated.,"This is actually a classic interview question and the answer they were expecting was that you first sort the urls and then make a binary search. -If it doesn't fit in memory, you can do the same thing with a file.",-0.0814518047658113,False,2,1945 2012-07-01 12:51:34.863,How do I center a wx.MessageDialog to the frame?,I've tried setting dlg.CenterOnParent() but that doesn't work. I assume it's because my MessageDialog is not setting the frame as the parent. In that case how would I do this?,"When you create a wx widget, the normal pattern of the create function is wx.SomeUIObject(parent, id, ...). The parent could be set when you create the dialog.",1.2,True,1,1946 2012-07-01 18:29:13.890,Test for existence of field in django class,"Given a django class and a field name how can you test to see whether the class has a field with the given name? The field name is a string in this case.","For example: @@ -21008,15 +21008,11 @@ Sometimes the answer is so obvious :)",1.2,True,1,1959 I can run the script on a CRON job to periodically grab new information, but how do I then get that data into the Django app? The Django server is running on a Linux box under Apache / FastCGI if that makes a difference. [Edit] - in response to Srikar's question When you are saying "" get that data into the Django app"" what exactly do you mean?... -The Django app will be responsible for storing the data in a convenient form so that it can then be displayed via a series of views. So the app will include a model with suitable members to store the incoming data. I'm just unsure how you hook into Django to make new instances of those model objects and tell Django to store them.","When you are saying "" get that data into the DJango app"" what exactly do you mean? -I am guessing that you are using some sort of database (like mysql). Insert whatever data you have collected from your cronjob into the respective tables that your Django app is accessing. Also insert this cron data into the same tables that your users are accessing. So that way your changes are immediately reflected to the users using the app as they will be accessing the data from the same table.",0.0,False,4,1960 -2012-07-05 17:30:21.783,How can I periodically run a Python script to import data into a Django app?,"I have a script which scans an email inbox for specific emails. That part's working well and I'm able to acquire the data I'm interested in. I'd now like to take that data and add it to a Django app which will be used to display the information. -I can run the script on a CRON job to periodically grab new information, but how do I then get that data into the Django app? -The Django server is running on a Linux box under Apache / FastCGI if that makes a difference. -[Edit] - in response to Srikar's question When you are saying "" get that data into the Django app"" what exactly do you mean?... -The Django app will be responsible for storing the data in a convenient form so that it can then be displayed via a series of views. So the app will include a model with suitable members to store the incoming data. I'm just unsure how you hook into Django to make new instances of those model objects and tell Django to store them.","Best way? -Make a view on the django side to handle receiving the data, and have your script do a HTTP POST on a URL registered to that view. -You could also import the model and such from inside your script, but I don't think that's a very good idea.",0.0,False,4,1960 +The Django app will be responsible for storing the data in a convenient form so that it can then be displayed via a series of views. So the app will include a model with suitable members to store the incoming data. I'm just unsure how you hook into Django to make new instances of those model objects and tell Django to store them.","Forget about this being a Django app for a second. It is just a load of Python code. +What this means is, your Python script is absolutely free to import the database models you have in your Django app and use them as you would in a standard module in your project. +The only difference here, is that you may need to take care to import everything Django needs to work with those modules, whereas when a request enters through the normal web interface it would take care of that for you. +Just import Django and the required models.py/any other modules you need for it work from your app. It is your code, not a black box. You can import it from where ever the hell you want. +EDIT: The link from Rohan's answer to the Django docs for custom management commands is definitely the least painful way to do what I said above.",0.0509761841073563,False,4,1960 2012-07-05 17:30:21.783,How can I periodically run a Python script to import data into a Django app?,"I have a script which scans an email inbox for specific emails. That part's working well and I'm able to acquire the data I'm interested in. I'd now like to take that data and add it to a Django app which will be used to display the information. I can run the script on a CRON job to periodically grab new information, but how do I then get that data into the Django app? The Django server is running on a Linux box under Apache / FastCGI if that makes a difference. @@ -21029,11 +21025,15 @@ If your script doesn't already use a db it would be simple to create a model wit I can run the script on a CRON job to periodically grab new information, but how do I then get that data into the Django app? The Django server is running on a Linux box under Apache / FastCGI if that makes a difference. [Edit] - in response to Srikar's question When you are saying "" get that data into the Django app"" what exactly do you mean?... -The Django app will be responsible for storing the data in a convenient form so that it can then be displayed via a series of views. So the app will include a model with suitable members to store the incoming data. I'm just unsure how you hook into Django to make new instances of those model objects and tell Django to store them.","Forget about this being a Django app for a second. It is just a load of Python code. -What this means is, your Python script is absolutely free to import the database models you have in your Django app and use them as you would in a standard module in your project. -The only difference here, is that you may need to take care to import everything Django needs to work with those modules, whereas when a request enters through the normal web interface it would take care of that for you. -Just import Django and the required models.py/any other modules you need for it work from your app. It is your code, not a black box. You can import it from where ever the hell you want. -EDIT: The link from Rohan's answer to the Django docs for custom management commands is definitely the least painful way to do what I said above.",0.0509761841073563,False,4,1960 +The Django app will be responsible for storing the data in a convenient form so that it can then be displayed via a series of views. So the app will include a model with suitable members to store the incoming data. I'm just unsure how you hook into Django to make new instances of those model objects and tell Django to store them.","Best way? +Make a view on the django side to handle receiving the data, and have your script do a HTTP POST on a URL registered to that view. +You could also import the model and such from inside your script, but I don't think that's a very good idea.",0.0,False,4,1960 +2012-07-05 17:30:21.783,How can I periodically run a Python script to import data into a Django app?,"I have a script which scans an email inbox for specific emails. That part's working well and I'm able to acquire the data I'm interested in. I'd now like to take that data and add it to a Django app which will be used to display the information. +I can run the script on a CRON job to periodically grab new information, but how do I then get that data into the Django app? +The Django server is running on a Linux box under Apache / FastCGI if that makes a difference. +[Edit] - in response to Srikar's question When you are saying "" get that data into the Django app"" what exactly do you mean?... +The Django app will be responsible for storing the data in a convenient form so that it can then be displayed via a series of views. So the app will include a model with suitable members to store the incoming data. I'm just unsure how you hook into Django to make new instances of those model objects and tell Django to store them.","When you are saying "" get that data into the DJango app"" what exactly do you mean? +I am guessing that you are using some sort of database (like mysql). Insert whatever data you have collected from your cronjob into the respective tables that your Django app is accessing. Also insert this cron data into the same tables that your users are accessing. So that way your changes are immediately reflected to the users using the app as they will be accessing the data from the same table.",0.0,False,4,1960 2012-07-05 17:46:17.607,Scraper Google App Engine for Steam,"So basically, at the moment, we are trying to write a basic HTML 5 page that, when you press a button, returns whether the user, on Steam, is in-game, offline, or online. We have looked at the Steam API, and to find this information, it requires the person's 64 bit ID (steamID64) and we, on the website, are only given the username. In order to find their 64 bit id, we have tried to scrape off of a website (steamidconverter.com) to get the user's 64 bit id from their username. We tried doing this through the javascript, but of course we ran into the cross domain block, not allowing us to access that data from our google App Engine website. I have experience in Python, so I attempted to figure out how to get the HTML from that website (in the form of steamidconverter.com/(personsusername)) with Python. That was a success in scraping, thanks to another post on Stack Overflow. BUT, I have no idea how to get that data back to the javascript and get it to do the rest of the work. I am stumped and really need help. This is all on google App Engine. All it is at the moment, is a button that runs a simple javascript that attempts to use JQuery to get the contents of the page back, but fails. I don't know how to integrate the two! @@ -21088,7 +21088,7 @@ For example, 3) process.stdin.write('input_2') 4) And then read the output of step 3 But if I use process.communicate after giving first input then it closes the output PIPE and i am unable to give second input as the PIPE is closed. -Kindly help please.","flush() stdin, then read() stdout.",0.2012947653214861,False,2,1965 +Kindly help please.","Instead of process.communicate(), use process.stdout.read()",0.0,False,2,1965 2012-07-09 05:04:13.100,Python Sub-process (Output PIPE),"How can I read from output PIPE multiple times without using process.communicate() as communicate closes the PIPE after reading the output but I need to have sequential inputs and outputs. For example, 1) process.stdin.write('input_1') @@ -21096,7 +21096,7 @@ For example, 3) process.stdin.write('input_2') 4) And then read the output of step 3 But if I use process.communicate after giving first input then it closes the output PIPE and i am unable to give second input as the PIPE is closed. -Kindly help please.","Instead of process.communicate(), use process.stdout.read()",0.0,False,2,1965 +Kindly help please.","flush() stdin, then read() stdout.",0.2012947653214861,False,2,1965 2012-07-09 09:26:37.047,Getting ejabberd to notify an external module on client presence change,"I have an ejabberd server at jabber.domain.com, with an xmpp component written in python (using sleekxmpp) at presence.domain.com. I wanted the component to get a notification each time a client changed his presence from available to unavailable and vice-versa. The clients themselves don't have any contacts. @@ -21104,10 +21104,9 @@ Currently, I have set up my clients to send their available presence stanzas to I was hoping the clients wouldn't be aware of the component at presence.domain.com, and they would just connect to jabber.domain.com and the component should somehow get notified by the server about the clients presence. Is there a way to do that? Is my component setup correct? or should I think about using an xmpp plugin/module/etc.. -Thanks","It is not difficult to write a custom ejabberd module for this. It will need to register to presence change hooks in ejabberd, and on each presence packet route a notification towards your external component. -There is a pair of hooks 'set_presence_hook' and 'unset_presence_hook' that your module can register to, to be informed when the users starts/end a session. -If you need to track other presence statuses, there is also a hook 'c2s_update_presence' that fires on any presence packets sent by your users. -Other possibility, without using a custom module, is using shared rosters. Add admin@presence.domain.com to the shared rosters of all your users, but in this case they will see this item reflected on their roster.",1.2,True,2,1966 +Thanks","It is possible for a component to subscribe to a user's presence exactly the same way a user does. Also it is possible for the user to subscribe to a component's presence. You just have to follow the usual pattern, i.e. the component/user sends a of type subscribe which the user/component can accept by sending a of type subscribed. +You can also have the user just send a presence to the component directly. +There is no need to write custom hooks or create proxy users.",0.0,False,2,1966 2012-07-09 09:26:37.047,Getting ejabberd to notify an external module on client presence change,"I have an ejabberd server at jabber.domain.com, with an xmpp component written in python (using sleekxmpp) at presence.domain.com. I wanted the component to get a notification each time a client changed his presence from available to unavailable and vice-versa. The clients themselves don't have any contacts. @@ -21115,20 +21114,21 @@ Currently, I have set up my clients to send their available presence stanzas to I was hoping the clients wouldn't be aware of the component at presence.domain.com, and they would just connect to jabber.domain.com and the component should somehow get notified by the server about the clients presence. Is there a way to do that? Is my component setup correct? or should I think about using an xmpp plugin/module/etc.. -Thanks","It is possible for a component to subscribe to a user's presence exactly the same way a user does. Also it is possible for the user to subscribe to a component's presence. You just have to follow the usual pattern, i.e. the component/user sends a of type subscribe which the user/component can accept by sending a of type subscribed. -You can also have the user just send a presence to the component directly. -There is no need to write custom hooks or create proxy users.",0.0,False,2,1966 +Thanks","It is not difficult to write a custom ejabberd module for this. It will need to register to presence change hooks in ejabberd, and on each presence packet route a notification towards your external component. +There is a pair of hooks 'set_presence_hook' and 'unset_presence_hook' that your module can register to, to be informed when the users starts/end a session. +If you need to track other presence statuses, there is also a hook 'c2s_update_presence' that fires on any presence packets sent by your users. +Other possibility, without using a custom module, is using shared rosters. Add admin@presence.domain.com to the shared rosters of all your users, but in this case they will see this item reflected on their roster.",1.2,True,2,1966 2012-07-10 00:11:22.507,Embed .exe in wxpython,"I am looking for a way to embed an .exe into a frame. (MDI) I am not sure how this can be done. I am using wxpython 2.9 and there is nothing online about this (until now).","Embedding one GUI application inside another is not a simple thing. Applications are written to provide their own main frame, for example. You could try to position Notepad to a particular place on the screen instead. If you're really talking about Notepad, then you have a different course of action. Notepad is nothing more than a text control with some code to save and load the contents to a file.",0.0,False,1,1967 2012-07-10 03:11:24.307,Integrating multiple dictionaries in python (big data),"I am working on a research project in big data mining. I have written the code currently to organize the data I have into a dictionary. However, The amount of data is so huge that while forming the dictionary, my computer runs out of memory. I need to periodically write my dictionary to main memory and create multiple dictionaries this way. I then need to compare the resulting multiple dictionaries, update the keys and values accordingly and store the whole thing in one big dictionary on disk. Any idea how I can do this in python? I need an api that can quickly write a dict to disk and then compare 2 dicts and update keys. I can actually write the code to compare 2 dicts, that's not a problem but I need to do it without running out of memory.. My dict looks like this: -""orange"" : [""It is a fruit"",""It is very tasty"",...]",You should use a database such as PostgreSQL.,0.0,False,2,1968 -2012-07-10 03:11:24.307,Integrating multiple dictionaries in python (big data),"I am working on a research project in big data mining. I have written the code currently to organize the data I have into a dictionary. However, The amount of data is so huge that while forming the dictionary, my computer runs out of memory. I need to periodically write my dictionary to main memory and create multiple dictionaries this way. I then need to compare the resulting multiple dictionaries, update the keys and values accordingly and store the whole thing in one big dictionary on disk. Any idea how I can do this in python? I need an api that can quickly write a dict to disk and then compare 2 dicts and update keys. I can actually write the code to compare 2 dicts, that's not a problem but I need to do it without running out of memory.. -My dict looks like this: ""orange"" : [""It is a fruit"",""It is very tasty"",...]","First thought - switch to 64-bit python and increase your computer's virtual memory settings ;-) Second thought - once you have a large dictionary, you can sort on key and write it to file. Once all your data has been written, you can then iterate through all the files simultaneously, comparing and writing out the final data as you go.",0.0,False,2,1968 +2012-07-10 03:11:24.307,Integrating multiple dictionaries in python (big data),"I am working on a research project in big data mining. I have written the code currently to organize the data I have into a dictionary. However, The amount of data is so huge that while forming the dictionary, my computer runs out of memory. I need to periodically write my dictionary to main memory and create multiple dictionaries this way. I then need to compare the resulting multiple dictionaries, update the keys and values accordingly and store the whole thing in one big dictionary on disk. Any idea how I can do this in python? I need an api that can quickly write a dict to disk and then compare 2 dicts and update keys. I can actually write the code to compare 2 dicts, that's not a problem but I need to do it without running out of memory.. +My dict looks like this: +""orange"" : [""It is a fruit"",""It is very tasty"",...]",You should use a database such as PostgreSQL.,0.0,False,2,1968 2012-07-10 10:17:20.313,How to find x and y-offset for slider in python for a web-application,"Can anyone please tell me how to find the x-offset and y-offset default value of a Slider in a webpage using python for selenium webdriver. Thanks in Advance !",You can use the get_attribute(name) method on a webelement to retrieve attributes.,0.0,False,1,1969 2012-07-10 18:59:09.253,executing c program from a python program,"I'm new to programming and was wondering how I can have a python program execute and communicate with a c program. I am doing a mathematical computation in python, and was wondering if I could write up the main computation in C, that way the computation runs faster. I've been reading about ""calling c functions from python"", ""including C or C++ code directly in your Python code"", and ""using c libraries from python"". Is this the same thing? I want a python program to execute a c program and receive the results. @@ -21136,16 +21136,16 @@ What does it mean to ""call C library functions"" from python? Would it allow th thanks","There's also numpy which can be reasonably fast when dealing with ""array operations"" (sometimes called vector operations, but I find that term confusing with SIMD terminology). You'll probably need numpy if you decide to go the cython route, so if the algorithm isn't too complicated, you might want to see if it is good enough with numpy by itself first. Note that there are two different routes you can take here. You can use subprocess which basically issues system calls to some other program that you have written. This is slow because you need to start a new process and send the data into the process and then read the data back from the process. In other words, the data gets replicated multiple times for each call. The second route is calling a C function from python. Since Cpython (the reference and most common python implementation) is written in C, you can create C extensions. They're basically compiled libraries that adhere to a certain API. Then Cpython can load those libraries and use the functions inside, passing pointers to the data. In this way, the data isn't actually replicated -- You're working with the same block of memory in python that you're using in C. The downside here is that the C API is a little complex. That's where 3rd party extensions and existing libraries come in (numpy, cython, ctypes, etc). They all have different ways of pushing computations int C functions without you having to worry about the C API. Numpy removes loops so you can add, subtract, multiply arrays quickly (among MANY other things). Cython translates python code to C which you can then compile and import -- typically to gain speed here you need to provide additional hints which allow cython to optimize the generated code, ctypes is a little fragile since you have to re-specify your C function prototype, but otherwise it's pretty easy as long as you can compile your library into a shared object ... The list could go on. Also note that if you're not using numpy, you might want to check out pypy. It claims to run your python code faster than Cpython.",0.2012947653214861,False,1,1970 -2012-07-10 20:32:43.337,Integrate networkx in eclipse on windows,I'm using PyDev in eclipse with Python 2.7 on windows 7. I Installed networkx and it is properly running within Python shell but in eclipse it is showing error as it is unable to locate networkx can anyone tell me how to remove this error?,"I think there are two options: - -Rebuild your interpreter -Add it to your python path by appending the location of networkx to sys.path in python",0.0,False,2,1971 2012-07-10 20:32:43.337,Integrate networkx in eclipse on windows,I'm using PyDev in eclipse with Python 2.7 on windows 7. I Installed networkx and it is properly running within Python shell but in eclipse it is showing error as it is unable to locate networkx can anyone tell me how to remove this error?,"you need to rebuild your interpreter go to project > properties > pyDev-Interpreter/Grammar click the ""click here to configure"" remove the existing interpreter hit ""Auto config"" button and follow the prompts kind of a pain but the only way Ive found to autodiscover newly installed packages",1.2,True,2,1971 +2012-07-10 20:32:43.337,Integrate networkx in eclipse on windows,I'm using PyDev in eclipse with Python 2.7 on windows 7. I Installed networkx and it is properly running within Python shell but in eclipse it is showing error as it is unable to locate networkx can anyone tell me how to remove this error?,"I think there are two options: + +Rebuild your interpreter +Add it to your python path by appending the location of networkx to sys.path in python",0.0,False,2,1971 2012-07-11 06:57:11.423,how to darw the image faster in canvas,"I am capturing mobile snapshot(android) through monkeyrunner and with the help of some python script(i.e. for socket connection),i made it to display in an html page.but there is some time delay between the image i saw on my browser and that one on the android device.how can i synchronise these things so that the mobile screen snapshot should be visible at the sametime on the browser.","It takes time for the image to get from your phone to your server to your desktop client. There's nothing you can do to change that. The best you can hope to do is to benchmark your entire application, figure out where are your bottlenecks, and hope it's not the network connection itself.",0.3869120172231254,False,1,1972 2012-07-11 23:18:23.010,python handling subprocess,"I am running an os.system(cmd) in a for-loop. Since sometimes it hangs, I am trying to use process=subprocess.pOpen(cmd) in a for-loop. But I want to know the following: @@ -21153,21 +21153,21 @@ The best you can hope to do is to benchmark your entire application, figure out If I do sleep(60) and then check if the process is still running by using process.poll(), how do I differentiate between process actually running even after 1 minute and process that hung? If I kill the process which hung, will the for-loop still continue or will it exit? +Thanks!","A common way to detect things that have stopped working is to have them emit a signal at roughly regular intervals and have another process monitor the signal. If the monitor sees that no signal has arrived after, say, twice the interval it can take action such as killing and restarting the process. +This general idea can be used not only for software but also for hardware. I have used it to restart embedded controllers by simply charging a capacitor from an a.c. coupled signal from an output bit. A simple detector monitors the capacitor and if the voltage ever falls below a threshold it just pulls the reset line low and at the same time holds the capacitor charged for long enough for the controller to restart. +The principle for software is similar; one way is for the process to simply touch a file at intervals. The monitor checks the file modification time at intervals and if it is too old kills and restarts the process. +In OP's case the subprocess could write a status code to a file to say how far it has got in its work.",0.0,False,2,1973 +2012-07-11 23:18:23.010,python handling subprocess,"I am running an os.system(cmd) in a for-loop. Since sometimes it hangs, I am trying to use process=subprocess.pOpen(cmd) in a for-loop. But I want to know the following: + +If I do sleep(60) and then check if the process is still running by using process.poll(), how do I differentiate between process actually running even after 1 minute and process that hung? +If I kill the process which hung, will the for-loop still continue or will it exit? + Thanks!","I don't know of any general way to tell whether a process is hung or working. If a process hangs due to a locking issue, then it might consume 0% CPU and you might be able to guess that it is hung and not working; but if it hangs with an infinite loop, the process might make the CPU 100% busy but not accomplish any useful work. And you might have a process communicating on the network, talking to a really slow host with long timeouts; that would not be hung but would consume 0% CPU while waiting. I think that, in general, the only hope you have is to set up some sort of ""watchdog"" system, where your sub-process uses inter-process communication to periodically send a signal that means ""I'm still alive"". If you can't modify the program you are running as a sub-process, then at least try to figure out why it hangs, and see if you can then figure out a way to guess that it has hung. Maybe it normally has a balanced mix of CPU and I/O, but when it hangs it goes in a tight infinite loop and the CPU usage goes to 100%; that would be your clue that it is time to kill it and restart. Or, maybe it writes to a log file every 30 seconds, and you can monitor the size of the file and restart it if the file doesn't grow. Or, maybe you can put the program in a ""verbose"" mode where it prints messages as it works (either to stdout or stderr) and you can watch those. Or, if the program works as a daemon, maybe you can actively query it and see if it is alive; for example, if it is a database, send a simple query and see if it succeeds. So I can't give you a general answer, but I have some hope that you should be able to figure out a way to detect when your specific program hangs. Finally, the best possible solution would be to figure out why it hangs, and fix the problem so it doesn't happen anymore. This may not be possible, but at least keep it in mind. You don't need to detect the program hanging if the program never hangs anymore! P.S. I suggest you do a Google search for ""how to monitor a process"" and see if you get any useful ideas from that.",1.2,True,2,1973 -2012-07-11 23:18:23.010,python handling subprocess,"I am running an os.system(cmd) in a for-loop. Since sometimes it hangs, I am trying to use process=subprocess.pOpen(cmd) in a for-loop. But I want to know the following: - -If I do sleep(60) and then check if the process is still running by using process.poll(), how do I differentiate between process actually running even after 1 minute and process that hung? -If I kill the process which hung, will the for-loop still continue or will it exit? - -Thanks!","A common way to detect things that have stopped working is to have them emit a signal at roughly regular intervals and have another process monitor the signal. If the monitor sees that no signal has arrived after, say, twice the interval it can take action such as killing and restarting the process. -This general idea can be used not only for software but also for hardware. I have used it to restart embedded controllers by simply charging a capacitor from an a.c. coupled signal from an output bit. A simple detector monitors the capacitor and if the voltage ever falls below a threshold it just pulls the reset line low and at the same time holds the capacitor charged for long enough for the controller to restart. -The principle for software is similar; one way is for the process to simply touch a file at intervals. The monitor checks the file modification time at intervals and if it is too old kills and restarts the process. -In OP's case the subprocess could write a status code to a file to say how far it has got in its work.",0.0,False,2,1973 2012-07-12 04:47:02.677,Django Access File on Server,"I'm using Django to send iOS push notifications. To do that, I need to access a .pem certificate file currently stored on the server in my app directory along with views.py, models.py, admin.py, etc. When I try to send a push notification from a python shell on the server, everything works fine. But when I try to send a push notification by accessing a Django view, it doesn't send and gives me an SSLError. I think that this is because Django can't find the .pem certificate file. In short, I'm wondering how a Django view function can read in another file on the server.","Never mind, I tried it again using an absolute file path, and it worked after I restarted Django.",0.3869120172231254,False,1,1974 2012-07-12 21:20:27.727,how to use CustomTreeCtrl with the TR_HAS_VARIABLE_ROW_HEIGHT style to change the items height?,"I gave my CustomTreeCtrl the TR_HAS_VARIABLE_ROW_HEIGHT style. But I am not sure where to go from there to change the height of the items inside the tree. @@ -21192,11 +21192,11 @@ IronPython's strength right now lies in long-running processes where the JIT can 2012-07-14 00:33:54.570,Python get list of all enclosing files,"I have been at this for a few hours... how to use python to get all enclosing files from a folder... now by enclosing I mean all the files enclosed within a folder within a folder etc. So all the files beyond a certain point using Python. I have tried to use glob.glob() and listdir() to do this, but those will just only work within the first level of code. I could get this to work if there was a way that python could differentiate between a file and a folder? Any suggestions?",You want os.walk(). It will give you a list of files and folders in each directory under the starting directory.,1.2,True,1,1979 2012-07-16 02:14:11.033,"How do I specify new lines on Python, when writing on files?","In comparison to Java (in a string), you would do something like ""First Line\r\nSecond Line"". -So how would you do that in Python, for purposes of writing multiple lines to a regular file?","The same way with '\n', though you'd probably not need the '\r'. Is there a reason you have it in your Java version? If you do need/want it, you can use it in the same way in Python too.",0.1618299653758019,False,3,1980 +So how would you do that in Python, for purposes of writing multiple lines to a regular file?","Most escape characters in string literals from Java are also valid in Python, such as ""\r"" and ""\n"".",0.1084157444430997,False,3,1980 2012-07-16 02:14:11.033,"How do I specify new lines on Python, when writing on files?","In comparison to Java (in a string), you would do something like ""First Line\r\nSecond Line"". So how would you do that in Python, for purposes of writing multiple lines to a regular file?","In Python you can just use the new-line character, i.e. \n",0.2655860252697744,False,3,1980 2012-07-16 02:14:11.033,"How do I specify new lines on Python, when writing on files?","In comparison to Java (in a string), you would do something like ""First Line\r\nSecond Line"". -So how would you do that in Python, for purposes of writing multiple lines to a regular file?","Most escape characters in string literals from Java are also valid in Python, such as ""\r"" and ""\n"".",0.1084157444430997,False,3,1980 +So how would you do that in Python, for purposes of writing multiple lines to a regular file?","The same way with '\n', though you'd probably not need the '\r'. Is there a reason you have it in your Java version? If you do need/want it, you can use it in the same way in Python too.",0.1618299653758019,False,3,1980 2012-07-16 13:20:21.190,Python web framework suggestion for a web service,"I'm gonna write a web service which will allow upload/download of files, managing permissions and users. It will be the interface to which a Desktop app or Mobile App will communicate. I was wondering which of the web frameworks I should use to to that? It is a sort of remote storage for media files. I am going to host the web service on EC2 in a Linux environment. It should be fast (obviously) because It will have to handle tens of requests per second, transferring lots of data (GBs)... Communication will be done using JSon... But how to deal with binary data? If I use base64, it will grow by 33%... @@ -21226,11 +21226,11 @@ You could also change the symlinks that point to the old Python, but not sure wh I would recommend the safest path, that is to first pip freeze > installed.txt and then recreate your virtualenv with your new Python and pip install -r installed.txt in it.",0.1352210990936997,False,1,1984 2012-07-17 20:16:38.040,"Flask SQLAlchemy query, specify column names","How do I specify the column that I want in my query using a model (it selects all columns by default)? I know how to do this with the sqlalchmey session: session.query(self.col1), but how do I do it with with models? I can't do SomeModel.query(). Is there a way?","result = ModalName.query.add_columns(ModelName.colname, ModelName.colname)",0.0814518047658113,False,1,1985 2012-07-18 16:11:20.843,Is it possible to TDD when writing a test runner?,"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. -Assuming it's possible, how can it be done?","Yes. One of the examples Kent Beck works through in his book ""Test Driven Development: By Example"" is a test runner.",0.9999092042625952,False,2,1986 -2012-07-18 16:11:20.843,Is it possible to TDD when writing a test runner?,"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. Assuming it's possible, how can it be done?","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? Bootstrapping 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. So 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.",1.2,True,2,1986 +2012-07-18 16:11:20.843,Is it possible to TDD when writing a test runner?,"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. +Assuming it's possible, how can it be done?","Yes. One of the examples Kent Beck works through in his book ""Test Driven Development: By Example"" is a test runner.",0.9999092042625952,False,2,1986 2012-07-19 18:48:04.390,Scanning MySQL table for updates Python,"I am creating a GUI that is dependent on information from MySQL table, what i want to be able to do is to display a message every time the table is updated with new data. I am not sure how to do this or even if it is possible. I have codes that retrieve the newest MySQL update but I don't know how to have a message every time new data comes into a table. Thanks!","Quite simple and straightforward solution will be just to poll the latest autoincrement id from your table, and compare it with what you've seen at the previous poll. If it is greater -- you have new data. This is called 'active polling', it's simple to implement and will suffice if you do this not too often. So you have to store the last id value somewhere in your GUI. And note that this stored value will reset when you restart your GUI application -- be sure to think what to do at the start of the GUI. Probably you will need to track only insertions that occur while GUI is running -- then, at the GUI startup you need just to poll and store current id value, and then poll peroidically and react on its changes.",1.2,True,1,1987 2012-07-20 08:11:06.813,How can I save my secret keys and password securely in my version control system?,"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. But passwords--like any other setting--seem like they should be versioned. So what is the proper way to keep passwords version controlled? @@ -21307,12 +21307,12 @@ On application deployment, script is ran that transforms the template file into 2012-07-20 19:04:05.503,MySQL Joins Between Databases On Different Servers Using Python?,"Database A resides on server server1, while database B resides on server server2. Both servers {A, B} are physically close to each other, but are on different machines and have different connection parameters (different username, different password etc). In such a case, is it possible to perform a join between a table that is in database A, to a table that is in database B? -If so, how do I go about it, programatically,","Without doing something like replicating database A onto the same server as database B and then doing the JOIN, this would not be possible.",0.0,False,2,1989 +If so, how do I go about it, programatically,","I don't know python, so I'm going to assume that when you do a query it comes back to python as an array of rows. +You could query table A and after applying whatever filters you can, return that result to the application. Same to table B. Create a 3rd Array, loop through A, and if there is a joining row in B, add that joined row to the 3rd array. In the end the 3rd array would have the equivalent of a join of the two tables. It's not going to be very efficient, but might work okay for small recordsets.",0.0,False,2,1989 2012-07-20 19:04:05.503,MySQL Joins Between Databases On Different Servers Using Python?,"Database A resides on server server1, while database B resides on server server2. Both servers {A, B} are physically close to each other, but are on different machines and have different connection parameters (different username, different password etc). In such a case, is it possible to perform a join between a table that is in database A, to a table that is in database B? -If so, how do I go about it, programatically,","I don't know python, so I'm going to assume that when you do a query it comes back to python as an array of rows. -You could query table A and after applying whatever filters you can, return that result to the application. Same to table B. Create a 3rd Array, loop through A, and if there is a joining row in B, add that joined row to the 3rd array. In the end the 3rd array would have the equivalent of a join of the two tables. It's not going to be very efficient, but might work okay for small recordsets.",0.0,False,2,1989 +If so, how do I go about it, programatically,","Without doing something like replicating database A onto the same server as database B and then doing the JOIN, this would not be possible.",0.0,False,2,1989 2012-07-21 06:48:35.803,sqlite timezone now,"I am using python and sqlite3 to handle a website. I need all timezones to be in localtime, and I need daylight savings to be accounted for. The ideal method to do this would be to use sqlite to set a global datetime('now') to be +10 hours. If I can work out how to change sqlite's 'now' with a command, then I was going to use a cronjob to adjust it (I would happily go with an easier method if anyone has one, but cronjob isn't too hard)","you can try this code, I am in Taiwan , so I add 8 hours: DateTime('now','+8 hours')",0.3869120172231254,False,1,1990 @@ -21434,17 +21434,17 @@ On installation there are several assertions about wrong win structures size. If Does anybody know how to handle this situation? Is there a pure pywinauto version to work without additional patches? And finally, if no answer, is there a powerful Python lib you may suggest for gui automation? With a support of 64 bit? -Thanks in advance.","Azurin, you always can use python32bit + pywinauto on your x64 OS. If you realy need python64 you also can use py2exe to compile a test in .exe and use it everywhere, even on OSes where python is not installed. :)",0.1016881243684853,False,2,2008 -2012-07-30 10:26:54.803,Looking for a way to use Pywinauto on Win x64,"I am using pywinauto for gui automation for quite a long time already. Now I have to move to x64 OS. There seems to be no official version for 64 bit OS. There are clones which claim they support 64, but in practice they don't. -On installation there are several assertions about wrong win structures size. If commented out, the lib manages to install, but some API doesn't work. E.g. win32functions.GetMenuItemInfo() returns Error 87: wrong parameter. This API depends on struct MENUITEMINFOW (which size initially didn't pass the assertion). -Does anybody know how to handle this situation? -Is there a pure pywinauto version to work without additional patches? -And finally, if no answer, is there a powerful Python lib you may suggest for gui automation? With a support of 64 bit? Thanks in advance.","win32structure.py ensure HANDLE is c_void_p redefine other handles like HBITMAP to HANDLE ensure pointers are pointers and not long",-0.2012947653214861,False,2,2008 +2012-07-30 10:26:54.803,Looking for a way to use Pywinauto on Win x64,"I am using pywinauto for gui automation for quite a long time already. Now I have to move to x64 OS. There seems to be no official version for 64 bit OS. There are clones which claim they support 64, but in practice they don't. +On installation there are several assertions about wrong win structures size. If commented out, the lib manages to install, but some API doesn't work. E.g. win32functions.GetMenuItemInfo() returns Error 87: wrong parameter. This API depends on struct MENUITEMINFOW (which size initially didn't pass the assertion). +Does anybody know how to handle this situation? +Is there a pure pywinauto version to work without additional patches? +And finally, if no answer, is there a powerful Python lib you may suggest for gui automation? With a support of 64 bit? +Thanks in advance.","Azurin, you always can use python32bit + pywinauto on your x64 OS. If you realy need python64 you also can use py2exe to compile a test in .exe and use it everywhere, even on OSes where python is not installed. :)",0.1016881243684853,False,2,2008 2012-07-30 16:03:35.777,Group chat application in python using threads or asycore,"I am developing a group chat application to learn how to use sockets, threads (maybe), and asycore module(maybe). What my thought was have a client-server architecture so that when a client connects to the server the server sends the client a list of other connects (other client 'user name', ip addres) and then a person can connect to one or more people at a time and the server would set up a P2P connection between the client(s). I have the socket part working, but the server can only handle one client connection at a time. What would be the best, most common, practical way to go about handling multiple connections? @@ -21627,16 +21627,6 @@ The data stored in the builder directory is in pickles. Looking at the code, I t How to run a python script/bytecode/.pyc (any compiled python code) without going through the terminal. Basically on Nautilus: ""on double click of the python script, it'll run"" or ""on select then [Enter], it'll run!"". That's my goal at least. When i check the ""Allow executing of file as a program"" then press [enter] on the file. It gives me this message: -Could not display ""/home/ghelo/Music/arrange.pyc"". - There is no application installed for Python bytecode files. - Do you want to search for an application to open this file? - -Using Ubuntu 12.04, by the way and has to be python 2, one of the packages doesn't work on python 3. If there's a difference between how to do it on the two version, include it, if it's not to much t ask, thank you. -I know it doesn't matter, but it's a script auto renaming & arranging my music files. Guide me accordingly, stupid idiot here. :)",You should make the .py files executable and click on them. The .pyc files cannot be run directly.,0.4961739557460144,False,2,2033 -2012-08-07 14:55:04.177,How to run Python script with one icon click?,"Sorry, for the vague question, don't know actually how to ask this nor the rightful terminologies for it. -How to run a python script/bytecode/.pyc (any compiled python code) without going through the terminal. Basically on Nautilus: ""on double click of the python script, it'll run"" or ""on select then [Enter], it'll run!"". That's my goal at least. -When i check the ""Allow executing of file as a program"" then press [enter] on the file. It gives me this message: - Could not display ""/home/ghelo/Music/arrange.pyc"". There is no application installed for Python bytecode files. Do you want to search for an application to open this file? @@ -21651,6 +21641,16 @@ A simpler way to make a python exectuable (explained): 2) Write the code. If the script is directly invoked, __name__ variable becomes equal to the string '__main__' thus the idiom: if __name__ == '__main__':. You can add all the logic that relates to your script being directly invoked in this if-block. This keeps your executable importable. 3) Make it executable 'chmod +x main.py' 4) Call the script: ./main.py args args",1.2,True,2,2033 +2012-08-07 14:55:04.177,How to run Python script with one icon click?,"Sorry, for the vague question, don't know actually how to ask this nor the rightful terminologies for it. +How to run a python script/bytecode/.pyc (any compiled python code) without going through the terminal. Basically on Nautilus: ""on double click of the python script, it'll run"" or ""on select then [Enter], it'll run!"". That's my goal at least. +When i check the ""Allow executing of file as a program"" then press [enter] on the file. It gives me this message: + +Could not display ""/home/ghelo/Music/arrange.pyc"". + There is no application installed for Python bytecode files. + Do you want to search for an application to open this file? + +Using Ubuntu 12.04, by the way and has to be python 2, one of the packages doesn't work on python 3. If there's a difference between how to do it on the two version, include it, if it's not to much t ask, thank you. +I know it doesn't matter, but it's a script auto renaming & arranging my music files. Guide me accordingly, stupid idiot here. :)",You should make the .py files executable and click on them. The .pyc files cannot be run directly.,0.4961739557460144,False,2,2033 2012-08-07 21:41:06.547,Checking the quality of an Incoming Video with python,"I am new to python and programming in general. I was wondering if there is a way to validate that you are getting a video feed and not just a black screen from an incoming call. I have automated a script in Python that makes a call and answers the call, but some of the issues we are testing is how often we get black screen instead of the video call. I have been reading up on OpenCV and played around with it some, but am not getting anywhere near the results I am looking for. Is there another way in python to detect video? If so I would greatly appreciate being pointed in the right direction. Thanks","I do something similar with C++ in OpenCV. There are a couple of ways to go about this. I use TCP/IP protocols - make sure I don't have packet loss. @@ -21715,8 +21715,8 @@ action_move_create() action_number() this 3 function are called at time of validating invoice. You can override any one from this or you can add your own function . in workflow for the ""open"" activity.",1.2,True,1,2042 -2012-08-15 13:23:36.320,Website sync of contacts and reminders with iCloud,"I'm building custom CRM web based system and have integrated synchronization of contacts and reminders with Google apps and need do the same with Apple iCloud. Is there any way how to do it? I haven't find any official API for this purpose, CRM is written in PHP, but I'm able to use python for this purpose as well.","To the best of my knowledge, there is no way to interface with iCloud directly; it can only be done through an iOS or Mac OS app, and by calling the correct iCloud Objective-C APIs with UI/NSDocument classes. Since you are not using Cocoa, let alone Objective-C, you will most likely not be able to do this. I may be wrong of course, as I haven't conducted an in-depth search into this.",0.1016881243684853,False,2,2043 2012-08-15 13:23:36.320,Website sync of contacts and reminders with iCloud,"I'm building custom CRM web based system and have integrated synchronization of contacts and reminders with Google apps and need do the same with Apple iCloud. Is there any way how to do it? I haven't find any official API for this purpose, CRM is written in PHP, but I'm able to use python for this purpose as well.","I would recommend that you sync using the google contacts api. Then, you can tell iPhone people to use that instead of iCloud.",0.0,False,2,2043 +2012-08-15 13:23:36.320,Website sync of contacts and reminders with iCloud,"I'm building custom CRM web based system and have integrated synchronization of contacts and reminders with Google apps and need do the same with Apple iCloud. Is there any way how to do it? I haven't find any official API for this purpose, CRM is written in PHP, but I'm able to use python for this purpose as well.","To the best of my knowledge, there is no way to interface with iCloud directly; it can only be done through an iOS or Mac OS app, and by calling the correct iCloud Objective-C APIs with UI/NSDocument classes. Since you are not using Cocoa, let alone Objective-C, you will most likely not be able to do this. I may be wrong of course, as I haven't conducted an in-depth search into this.",0.1016881243684853,False,2,2043 2012-08-15 13:35:18.467,Background python program inspect GUI events,"I am thinking of writing a python program that runs in the background and can inspect user's GUI events. My requirements is very simple: 1) When user right click the mouse, it can show an option; and when this option is chosen, my program should know this event. @@ -21728,13 +21728,13 @@ I need to use PayPal that requires me to use port 80. But using Mac OS X 10.8 I can't have it working because of permission issues. I've already tried running PyCharm with SUDO command. Does anyone know how to run Pycharm using port 80, or any other solution? -Thanks.","For the ones who are looking for the answer of this question, please check your Pycharm Run/Debug Configurations. Run->Edit Configurations ->Port",0.1016881243684853,False,2,2045 +Thanks.","To give PyCharm permissions, one has to run as Administor (Windows) or using sudo if on OSX/Linux: sudo /Applications/PyCharm.app/Contents/MacOS/pycharm. Note that this truly runs PyCharm as a new user, so you'll have to register the app again and set up your customizations again if you have any (ie theme, server profiles etc)",0.2012947653214861,False,2,2045 2012-08-16 13:49:03.683,How to run PyCharm using port 80,"I can't run my PyCharm IDE using port 80. I need to use PayPal that requires me to use port 80. But using Mac OS X 10.8 I can't have it working because of permission issues. I've already tried running PyCharm with SUDO command. Does anyone know how to run Pycharm using port 80, or any other solution? -Thanks.","To give PyCharm permissions, one has to run as Administor (Windows) or using sudo if on OSX/Linux: sudo /Applications/PyCharm.app/Contents/MacOS/pycharm. Note that this truly runs PyCharm as a new user, so you'll have to register the app again and set up your customizations again if you have any (ie theme, server profiles etc)",0.2012947653214861,False,2,2045 +Thanks.","For the ones who are looking for the answer of this question, please check your Pycharm Run/Debug Configurations. Run->Edit Configurations ->Port",0.1016881243684853,False,2,2045 2012-08-16 14:29:29.977,When to disconnect from mongodb,"I am fairly new to databases and have just figured out how to use MongoDB in python2.7 on Ubuntu 12.04. An application I'm writing uses multiple python modules (imported into a main module) that connect to the database. Basically, each module starts by opening a connection to the DB, a connection which is then used for various operations. However, when the program exits, the main module is the only one that 'knows' about the exiting, and closes its connection to MongoDB. The other modules do not know this and have no chance of closing their connections. Since I have little experience with databases, I wonder if there are any problems leaving connections open when exiting. Should I: @@ -21790,13 +21790,13 @@ I cannot find any documentation that describes whether sklearn supports complex Can anyone suggest how I can get a regression algorithm to operate with complex numbers as targets?",Several regressors support multidimensional regression targets. Just view the complex numbers as 2d points.,0.4961739557460144,False,3,2049 2012-08-17 02:48:36.830,Is it possible to use complex numbers as target labels in scikit learn?,"I am trying to use sklearn to predict a variable that represents rotation. Because of the unfortunate jump from -pi to pi at the extremes of rotation, I think a much better method would be to use a complex number as the target. That way an error from 1+0.01j to 1-0.01j is not as devastating. I cannot find any documentation that describes whether sklearn supports complex numbers as targets to classifiers. In theory the distance metric should work just fine, so it should work for at least some regression algorithms. +Can anyone suggest how I can get a regression algorithm to operate with complex numbers as targets?","Good question. How about transforming angles into a pair of labels, viz. x and y co-ordinates. These are continuous functions of angle (cos and sin). You can combine the results from separate x and y classifiers for an angle? $\theta = \sign(x) \arctan(y/x)$. However that result will be unstable if both classifiers return numbers near zero.",0.1352210990936997,False,3,2049 +2012-08-17 02:48:36.830,Is it possible to use complex numbers as target labels in scikit learn?,"I am trying to use sklearn to predict a variable that represents rotation. Because of the unfortunate jump from -pi to pi at the extremes of rotation, I think a much better method would be to use a complex number as the target. That way an error from 1+0.01j to 1-0.01j is not as devastating. +I cannot find any documentation that describes whether sklearn supports complex numbers as targets to classifiers. In theory the distance metric should work just fine, so it should work for at least some regression algorithms. Can anyone suggest how I can get a regression algorithm to operate with complex numbers as targets?","So far I discovered that most classifiers, like linear regressors, will automatically convert complex numbers to just the real part. kNN and RadiusNN regressors, however, work well - since they do a weighted average of the neighbor labels and so handle complex numbers gracefully. Using a multi-target classifier is another option, however I do not want to decouple the x and y directions since that may lead to unstable solutions as Colonel Panic mentions, when both results come out close to 0. I will try other classifiers with complex targets and update the results here.",1.2,True,3,2049 -2012-08-17 02:48:36.830,Is it possible to use complex numbers as target labels in scikit learn?,"I am trying to use sklearn to predict a variable that represents rotation. Because of the unfortunate jump from -pi to pi at the extremes of rotation, I think a much better method would be to use a complex number as the target. That way an error from 1+0.01j to 1-0.01j is not as devastating. -I cannot find any documentation that describes whether sklearn supports complex numbers as targets to classifiers. In theory the distance metric should work just fine, so it should work for at least some regression algorithms. -Can anyone suggest how I can get a regression algorithm to operate with complex numbers as targets?","Good question. How about transforming angles into a pair of labels, viz. x and y co-ordinates. These are continuous functions of angle (cos and sin). You can combine the results from separate x and y classifiers for an angle? $\theta = \sign(x) \arctan(y/x)$. However that result will be unstable if both classifiers return numbers near zero.",0.1352210990936997,False,3,2049 2012-08-17 05:25:01.070,Does Eclipse have indentation guides?,"Recently, I use Eclipse to edit my python code. But lacking indentation guides, I feel not very well. So how to add the auto indentation guides for Eclipse? Is there certain plugin? What's more, I have tried the EditBox. But, you know, that is not very natural under some themes...............","As for me, all I do with Eclipse for working with Python: @@ -21808,11 +21808,11 @@ you can make tabs and spaces visual by displaying non-printable symbols. Hopefully, this is what you meant.",0.0814518047658113,False,1,2050 2012-08-17 12:09:13.097,python how to overcome global interpretor lock,"I have implemented tool to extract the data from clear quest server using python. I need to do lot of searches in clearquest so I have implemented it using threading. To do that i try to open individual clearquest session for each thread. When I try to run this I am getting Run Time error and none of the clearquest session opened correctly. -I did bit of research on internet and found that it's because of Global Interpretor Lock in python. I would like to know how to overcome this GIL...Any idea would be much appreciated","Instead of using threads, use different processes and use some sort of IPC to communicate between each process.",0.5457054096481145,False,2,2051 -2012-08-17 12:09:13.097,python how to overcome global interpretor lock,"I have implemented tool to extract the data from clear quest server using python. I need to do lot of searches in clearquest so I have implemented it using threading. -To do that i try to open individual clearquest session for each thread. When I try to run this I am getting Run Time error and none of the clearquest session opened correctly. I did bit of research on internet and found that it's because of Global Interpretor Lock in python. I would like to know how to overcome this GIL...Any idea would be much appreciated","I don't think you'll have RuntimeErrors because of the GIL. Can you paste the traceback? If you have some critical parts of the code that are not re entrant, you'll have to isolate them using some concurrency primitives. The main issue with the GIL is that it will forcibly serialise computation. The result is reduced throughput and scaling.",0.3869120172231254,False,2,2051 +2012-08-17 12:09:13.097,python how to overcome global interpretor lock,"I have implemented tool to extract the data from clear quest server using python. I need to do lot of searches in clearquest so I have implemented it using threading. +To do that i try to open individual clearquest session for each thread. When I try to run this I am getting Run Time error and none of the clearquest session opened correctly. +I did bit of research on internet and found that it's because of Global Interpretor Lock in python. I would like to know how to overcome this GIL...Any idea would be much appreciated","Instead of using threads, use different processes and use some sort of IPC to communicate between each process.",0.5457054096481145,False,2,2051 2012-08-17 23:03:05.907,How do I communicate between 2 Python programs using sockets that are on separate NATs?,"I want to send and receive messages between two Python programs using sockets. I can do this using the private IPs when the computers are connected to the same router, but how do I do it when there are 2 NATs separating them? Thanks (my first SO question)","Redis, could work but not the exact same functionality.",0.0,False,1,2052 2012-08-18 06:32:30.260,Making a 2d game in Python - which library should be used?,"I'm looking to make a 2d side scrolling game in Python, however I'm not sure what library to use. I know of PyGame (Hasn't been updated in 3 years), Pyglet, and PyOpenGL. My problem is I can't find any actually shipped games that were made with Python, let alone these libraries - so I don't know how well they perform in real world situations, or even if any of them are suitable for use in an actual game and not a competition. @@ -21910,26 +21910,26 @@ Is it a good idea to solve this? If it is - how to do it and don't screw a datab If it isn't a good way, how to do it right?","You can perform actions from different thread manually (eg with Queue and executors pool), but you should note, that Django's ORM manages database connections in thread-local variables. So each new thread = new connection to database (which will be not good idea for 50-100 threads for one request - too many connections). On the other hand, you should check database ""bandwith"".",1.2,True,1,2066 2012-08-26 20:57:45.717,pause system functionality until my python script is done,"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? Thanks -I 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.","There will always be a way for the user to get past your script. -Let'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. -There 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.",0.3869120172231254,False,2,2067 -2012-08-26 20:57:45.717,pause system functionality until my python script is done,"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? -Thanks I 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.","You want the equivalent of a ""modal"" window, but this is not (directly) possible in a multiuser, multitasking environment. The 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. At 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. And 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. What 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.",0.2655860252697744,False,2,2067 +2012-08-26 20:57:45.717,pause system functionality until my python script is done,"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? +Thanks +I 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.","There will always be a way for the user to get past your script. +Let'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. +There 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.",0.3869120172231254,False,2,2067 2012-08-27 18:11:03.897,is snmp required,"is snmp really required to manage devices ? i'd like to script something with python to manage devices (mainly servers), such as disk usage, process list etc. i'm learning how to do and many article speak about snmp protocole. I can't use, for example, psutil, or subprocess or os modules, and send information via udp ? -Thanks a lot",The SNMP is a standard monitoring (and configuration) tool used widely in managing network devices (but not only). I don't understand your question fully - is it a problem that you cannot use SNMP because device does not support it (what does it support then?) To script anything you have to know what interface is exposed to you (if not a MIB files then what?). Did you read about NETCONF?,1.2,True,2,2068 +Thanks a lot","No, it's not required, but your question is sort of like asking if you're required to use http to serve web pages. Technically you don't need it, but if you don't use it you're giving up interoperability with a lot of existing client software.",0.2012947653214861,False,2,2068 2012-08-27 18:11:03.897,is snmp required,"is snmp really required to manage devices ? i'd like to script something with python to manage devices (mainly servers), such as disk usage, process list etc. i'm learning how to do and many article speak about snmp protocole. I can't use, for example, psutil, or subprocess or os modules, and send information via udp ? -Thanks a lot","No, it's not required, but your question is sort of like asking if you're required to use http to serve web pages. Technically you don't need it, but if you don't use it you're giving up interoperability with a lot of existing client software.",0.2012947653214861,False,2,2068 +Thanks a lot",The SNMP is a standard monitoring (and configuration) tool used widely in managing network devices (but not only). I don't understand your question fully - is it a problem that you cannot use SNMP because device does not support it (what does it support then?) To script anything you have to know what interface is exposed to you (if not a MIB files then what?). Did you read about NETCONF?,1.2,True,2,2068 2012-08-27 22:18:52.980,PHP Exec() and Python script scaleability,"I have a php application that executes Python scripts via exec() and cgi. I 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. I 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. @@ -21947,12 +21947,12 @@ now you can remove your old classes from the sources",0.1352210990936997,False,2 tu = (""func1"", ""func2"", ""func3"") And with the operation I am looking for I would get this for the first string: moduleA.func1() -I know how to concatenate strings, but is there a way to join into a callable string?","getattr(moduleA, 'func1')() == moduleA.func1()",1.2,True,2,2071 +I know how to concatenate strings, but is there a way to join into a callable string?","If you mean get a function or method on a class or module, all entities (including classes, modules, functions, and methods) are objects, so you can do a func = getattr(thing 'func1') to get the function, then func() to call it.",0.0,False,2,2071 2012-08-28 21:00:42.300,Join two strings into a callable string 'moduleA' + 'func1' into moduleA.func1(),"I got this: tu = (""func1"", ""func2"", ""func3"") And with the operation I am looking for I would get this for the first string: moduleA.func1() -I know how to concatenate strings, but is there a way to join into a callable string?","If you mean get a function or method on a class or module, all entities (including classes, modules, functions, and methods) are objects, so you can do a func = getattr(thing 'func1') to get the function, then func() to call it.",0.0,False,2,2071 +I know how to concatenate strings, but is there a way to join into a callable string?","getattr(moduleA, 'func1')() == moduleA.func1()",1.2,True,2,2071 2012-08-29 08:16:34.980,MatPlotLib with Sublime Text 2 on OSX,"I want to use matplotlib from my Sublime Text 2 directly via the build command. Does anybody know how I accomplish that? I'm really confused about the whole multiple python installations/environments. Google didn't help. My python is installed via homebrew and in my terminal (which uses brew python), I have no problem importing matplotlib from there. But Sublime Text shows me an import Error (No module named matplotlib.pyplot). @@ -21968,13 +21968,6 @@ Beneath a help for this specific problem I would appreciate any helpful link to Then click CMD+B and your script with matplotlib stuff will work.",1.2,True,1,2072 2012-08-29 13:37:33.443,Meaning of @classmethod and @staticmethod for beginner?,"Could someone explain to me the meaning of @classmethod and @staticmethod in python? I need to know the difference and the meaning. As far as I understand, @classmethod tells a class that it's a method which should be inherited into subclasses, or... something. However, what's the point of that? Why not just define the class method without adding @classmethod or @staticmethod or any @ definitions? -tl;dr: when should I use them, why should I use them, and how should I use them?","@classmethod means: when this method is called, we pass the class as the first argument instead of the instance of that class (as we normally do with methods). This means you can use the class and its properties inside that method rather than a particular instance. -@staticmethod means: when this method is called, we don't pass an instance of the class to it (as we normally do with methods). This means you can put a function inside a class but you can't access the instance of that class (this is useful when your method does not use the instance).",1.0,False,3,2073 -2012-08-29 13:37:33.443,Meaning of @classmethod and @staticmethod for beginner?,"Could someone explain to me the meaning of @classmethod and @staticmethod in python? I need to know the difference and the meaning. -As far as I understand, @classmethod tells a class that it's a method which should be inherited into subclasses, or... something. However, what's the point of that? Why not just define the class method without adding @classmethod or @staticmethod or any @ definitions? -tl;dr: when should I use them, why should I use them, and how should I use them?",A slightly different way to think about it that might be useful for someone... A class method is used in a superclass to define how that method should behave when it's called by different child classes. A static method is used when we want to return the same thing regardless of the child class that we are calling.,0.0,False,3,2073 -2012-08-29 13:37:33.443,Meaning of @classmethod and @staticmethod for beginner?,"Could someone explain to me the meaning of @classmethod and @staticmethod in python? I need to know the difference and the meaning. -As far as I understand, @classmethod tells a class that it's a method which should be inherited into subclasses, or... something. However, what's the point of that? Why not just define the class method without adding @classmethod or @staticmethod or any @ definitions? tl;dr: when should I use them, why should I use them, and how should I use them?","I'm a beginner on this site, I have read all above answers, and got the information what I want. However, I don't have the right to upvote. So I want to get my start on StackOverflow with the answer as I understand it. @staticmethod doesn't need self or cls as the first parameter of the method @@ -21982,6 +21975,13 @@ tl;dr: when should I use them, why should I use them, and how should I use them? @staticmethod decorated function impact some kind 'immutable property' that subclass inheritance can't overwrite its base class function which is wrapped by a @staticmethod decorator. @classmethod need cls (Class name, you could change the variable name if you want, but it's not advised) as the first parameter of function @classmethod always used by subclass manner, subclass inheritance may change the effect of base class function, i.e. @classmethod wrapped base class function could be overwritten by different subclasses.",0.0340004944420038,False,3,2073 +2012-08-29 13:37:33.443,Meaning of @classmethod and @staticmethod for beginner?,"Could someone explain to me the meaning of @classmethod and @staticmethod in python? I need to know the difference and the meaning. +As far as I understand, @classmethod tells a class that it's a method which should be inherited into subclasses, or... something. However, what's the point of that? Why not just define the class method without adding @classmethod or @staticmethod or any @ definitions? +tl;dr: when should I use them, why should I use them, and how should I use them?",A slightly different way to think about it that might be useful for someone... A class method is used in a superclass to define how that method should behave when it's called by different child classes. A static method is used when we want to return the same thing regardless of the child class that we are calling.,0.0,False,3,2073 +2012-08-29 13:37:33.443,Meaning of @classmethod and @staticmethod for beginner?,"Could someone explain to me the meaning of @classmethod and @staticmethod in python? I need to know the difference and the meaning. +As far as I understand, @classmethod tells a class that it's a method which should be inherited into subclasses, or... something. However, what's the point of that? Why not just define the class method without adding @classmethod or @staticmethod or any @ definitions? +tl;dr: when should I use them, why should I use them, and how should I use them?","@classmethod means: when this method is called, we pass the class as the first argument instead of the instance of that class (as we normally do with methods). This means you can use the class and its properties inside that method rather than a particular instance. +@staticmethod means: when this method is called, we don't pass an instance of the class to it (as we normally do with methods). This means you can put a function inside a class but you can't access the instance of that class (this is useful when your method does not use the instance).",1.0,False,3,2073 2012-08-29 18:56:51.107,Widgets in a Tkinter popup taking Tab focus from widgets in another window,"I am noticing an issue in my Tkinter application when I create a new Toplevel popup (actually a subclass of tkSimpleDialog.Dialog) and try to navigate through its widgets with the Tab key. It works as expected, except whatever I had selected in a Listbox in my application's main window becomes unselected, as if the widget in the popup took the focus from it. Does anyone know why this is happening and how to prevent it? My Tkinter knowledge doesn't cover how interactions between windows affect the focus...","Solution: When creating the entry widgets in the popup, set their exportselection property to 0. Then selecting them won't affect any other selections.",1.2,True,1,2074 2012-08-29 19:32:44.717,Unicode characters in Django usernames,"I am developing a website using Django 1.4 and I use django-registration for the signup process. It turns out that Unicode characters are not allowed as usernames, whenever a user enters e.g. a Chinese character as part of username the registration fails with: @@ -22033,18 +22033,6 @@ I prefer using python and kscope (a kde based file search/code-review GUI tool t I do not have sys-adm authorization, so I prefer some code-review GUI tools that can be installed without the authorization. Would 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 ? Any help will really be appreciated. -Thanks","Your question is pretty broad so it's tough to give a specific answer. -It 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. -I 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. -If 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.",0.2012947653214861,False,2,2082 -2012-08-31 15:08:45.167,How to do code-review/debug/coding/test/version-control for C++ on perforce and VMS,"I am working on C++ programming with perforce (a version control tool) on VMS. -I need to handle tens or even hundreds of C++ files (managed by perforce) on VMS. -I am familiar with Linux, python but not DCL (a script language) on VMS. -I need to find a way to make programming/debug/code-review as easy as possible. -I prefer using python and kscope (a kde based file search/code-review GUI tool that can generate call graph) or similar tools on VMS. -I do not have sys-adm authorization, so I prefer some code-review GUI tools that can be installed without the authorization. -Would 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 ? -Any help will really be appreciated. Thanks","Indeed, it's not clear from your question what sort of programming you want to do on VMS: C++ or python?? Assuming your first goal is to get familiar with the code-base, i.e. you want the ease of cross-ref'ing the sources: @@ -22055,6 +22043,18 @@ If your ultimate goal is to do all development off VMS, then it may not really b From 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.). As 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. BTW, have a look into DECset, if installed on your VMS system.",0.0,False,2,2082 +2012-08-31 15:08:45.167,How to do code-review/debug/coding/test/version-control for C++ on perforce and VMS,"I am working on C++ programming with perforce (a version control tool) on VMS. +I need to handle tens or even hundreds of C++ files (managed by perforce) on VMS. +I am familiar with Linux, python but not DCL (a script language) on VMS. +I need to find a way to make programming/debug/code-review as easy as possible. +I prefer using python and kscope (a kde based file search/code-review GUI tool that can generate call graph) or similar tools on VMS. +I do not have sys-adm authorization, so I prefer some code-review GUI tools that can be installed without the authorization. +Would 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 ? +Any help will really be appreciated. +Thanks","Your question is pretty broad so it's tough to give a specific answer. +It 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. +I 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. +If 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.",0.2012947653214861,False,2,2082 2012-09-01 05:42:42.693,nose.run() seems to hold test files open after the first run,"I'm having the same problem on Windows and Linux. I launch any of various python 2.6 shells and run nose.py() to run my test suite. It works fine. However, the second time I run it, and every time thereafter I get exactly the same output, no matter how I change code or test files. My guess is that it's holding onto file references somehow, but even deleting the *.pyc files, I can never get the output of nose.run() to change until I restart the shell, or open another one, whereupon the problem starts again on the second run. I've tried both del nose and reload(nose) to no avail.","Solved* it with some outside help. I wouldn't consider this the proper solution, but by searching through sys.modules for all of my test_modules (which point to *.pyc files) and deling them, nose finally recognizes changes again. I'll have to delete them before each nose.run() call. These must be in-memory versions of the pyc files, as simply deleting them out in the shell wasn't doing it. Good enough for now. Edit: *Apparently I didn't entirely solve it. It does seem to work for a bit, and then all of a sudden it won't anymore, and I have to restart my shell. Now I'm even more confused.",0.0,False,1,2083 @@ -22089,6 +22089,12 @@ this works name_element.send_keys(""John Doe"") but this doesnt name_element.send_keys(username) +Does anyone know how I can accomplish this? Pretty big Python noob, but used Google extensively to try and find out.",I think username might be a variable in the python library you are using. Try calling it something else like Username1 and see if it works??,0.0,False,2,2088 +2012-09-05 21:00:22.823,Passing variables through Selenium send.keys instead of strings,"I'm trying to use Selenium for some app testing, and I need it to plug a variable in when filling a form instead of a hardcoded string. IE: +this works +name_element.send_keys(""John Doe"") +but this doesnt +name_element.send_keys(username) Does anyone know how I can accomplish this? Pretty big Python noob, but used Google extensively to try and find out.","Try this. username = r'John Doe' @@ -22096,12 +22102,6 @@ username = r'John Doe' name_element.send_keys(username) I was able to pass the string without casting it just fine in my test.",0.0814518047658113,False,2,2088 -2012-09-05 21:00:22.823,Passing variables through Selenium send.keys instead of strings,"I'm trying to use Selenium for some app testing, and I need it to plug a variable in when filling a form instead of a hardcoded string. IE: -this works -name_element.send_keys(""John Doe"") -but this doesnt -name_element.send_keys(username) -Does anyone know how I can accomplish this? Pretty big Python noob, but used Google extensively to try and find out.",I think username might be a variable in the python library you are using. Try calling it something else like Username1 and see if it works??,0.0,False,2,2088 2012-09-05 22:29:26.937,How do you add the scrapy framework to portable python?,"I need to create a portable python install on a usb but also install the scrapy framework on it, so I can work on and run my spiders on any computer. Has anyone else done this? Is it even possible? If so how do you add scrapy onto the portable python usb and then run the spiders? @@ -22143,11 +22143,11 @@ Ex: --addons ../addons,../your_module_path 6: Now open your .py file which you want to debug and set a break-point. 7: Now start your module's form from 'gtk' or 'web-client' and execution will stop when execution will reach to break-point. 8: Now enjoy by debugging your code by pressing ""F5, F6, F7"" and you can see value of your variables.",1.2,True,1,2092 -2012-09-07 12:46:51.010,Confused about the choice between Python 2 vs Python 3,"I am coming from Ruby, and am having trouble deciding between installing and using Python 2.x or Python 3.x I am guessing that this choice this depends on what platforms and frameworks I want to use, but how can I find a list of programs that are or are not Python 3 compatible? This might help me get past this dilemma.","Nowadays, quite a number of libraries support Python 3. There is not a single list of these, so you'll have to check the frameworks you'd like to use for Python 3 compatibility. Some support Python 3 only in some beta stage, but that doesn't mean those are bad. -I would start off nowadays with Python 3, and see where you get. Only if you know you need to support whatever you are developing on other platforms that you don't control, it may be better to start with Python 2.",0.0679224682270276,False,2,2093 2012-09-07 12:46:51.010,Confused about the choice between Python 2 vs Python 3,"I am coming from Ruby, and am having trouble deciding between installing and using Python 2.x or Python 3.x I am guessing that this choice this depends on what platforms and frameworks I want to use, but how can I find a list of programs that are or are not Python 3 compatible? This might help me get past this dilemma.","If you're looking to learn new things, and aren't looking to make a ""must work today"" type project, try Python3. It will be easier to move forward into the future with Python3, as it will become the standard over time. If you're making something quick and dirty, you'll typically get better library support with Python 2.7. Finally, if anything you are using includes full unicode support, don't sell yourself short -- go with Python3. The simplification of unicode alone is worth it.",0.5457054096481145,False,2,2093 +2012-09-07 12:46:51.010,Confused about the choice between Python 2 vs Python 3,"I am coming from Ruby, and am having trouble deciding between installing and using Python 2.x or Python 3.x I am guessing that this choice this depends on what platforms and frameworks I want to use, but how can I find a list of programs that are or are not Python 3 compatible? This might help me get past this dilemma.","Nowadays, quite a number of libraries support Python 3. There is not a single list of these, so you'll have to check the frameworks you'd like to use for Python 3 compatibility. Some support Python 3 only in some beta stage, but that doesn't mean those are bad. +I would start off nowadays with Python 3, and see where you get. Only if you know you need to support whatever you are developing on other platforms that you don't control, it may be better to start with Python 2.",0.0679224682270276,False,2,2093 2012-09-08 22:53:56.963,Putting password for fabric rsync_project() function,"I'd like to pass somehow user password for rsync_project() function (that is wrapper for regular rsync command) from Fabric library. I'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. Please provide me any suggestions how should I work with it.","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.",1.2,True,1,2094 @@ -22159,7 +22159,7 @@ Grouping static files (creating new folders, adding new/ existing files to it); checking my models Thus, I would like to know how secure is Django-Admin interface! -How secure it is when compared to our famous sites like Yahoo, Facebook, Google Login's.. (at least in terms of ""cracking"".. is django admin can be cracked easily?)","How secure is a Google Login ;) ? You can't tell as you can't look behind the scenes (Update: Of Google Login of course.). I would guess that Django's admin code is pretty safe, as it's used in lots of production systems. Still, beside the code, it also matters how you set it up. In the end, it depends on the level of security you need.",-0.3869120172231254,False,2,2095 +How secure it is when compared to our famous sites like Yahoo, Facebook, Google Login's.. (at least in terms of ""cracking"".. is django admin can be cracked easily?)","Besides serving static files through django is considered a bad idea, the django admin itself is pretty safe. You can take additional measure by securing it via .htaccess and force https access on it. You could also restrict access to a certain IP. If the admin is exposed to the whole internet you should at least be careful when choosing credentials. Since I don't know how secure Google and Yahoo really are, I can't compare to them.",0.0,False,2,2095 2012-09-09 07:36:52.993,How secure is Django Admin interface,"I have couple of apps on internet and want to serve static files for those apps using another Django App. I simply can't afford to use Amazon Web Services for my pet-projects. So, I want to setup an Admin interface where I can manage static files easily. The following are the actions I am thinking to include in admin. @@ -22168,7 +22168,7 @@ Grouping static files (creating new folders, adding new/ existing files to it); checking my models Thus, I would like to know how secure is Django-Admin interface! -How secure it is when compared to our famous sites like Yahoo, Facebook, Google Login's.. (at least in terms of ""cracking"".. is django admin can be cracked easily?)","Besides serving static files through django is considered a bad idea, the django admin itself is pretty safe. You can take additional measure by securing it via .htaccess and force https access on it. You could also restrict access to a certain IP. If the admin is exposed to the whole internet you should at least be careful when choosing credentials. Since I don't know how secure Google and Yahoo really are, I can't compare to them.",0.0,False,2,2095 +How secure it is when compared to our famous sites like Yahoo, Facebook, Google Login's.. (at least in terms of ""cracking"".. is django admin can be cracked easily?)","How secure is a Google Login ;) ? You can't tell as you can't look behind the scenes (Update: Of Google Login of course.). I would guess that Django's admin code is pretty safe, as it's used in lots of production systems. Still, beside the code, it also matters how you set it up. In the end, it depends on the level of security you need.",-0.3869120172231254,False,2,2095 2012-09-09 18:12:58.290,Error when installing mod_wsgi,"When installing mod_wsgi I get stuck after doing ./config Apparently I am missing the apxs2 Here is the result: @@ -22178,11 +22178,8 @@ checking Apache version... 2.2.22 checking for python... /usr/bin/python configure: creating ./config.status config.status: creating Makefile -What 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.","checking for apxs... /usr/sbin/apxs - ... - config.status: creating Makefile - -It succeeded. Go on to the next step.",0.3869120172231254,False,2,2096 +What 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.","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'. +So, do the actual make and see if that fails before assuming you have the wrong apxs.",0.0,False,2,2096 2012-09-09 18:12:58.290,Error when installing mod_wsgi,"When installing mod_wsgi I get stuck after doing ./config Apparently I am missing the apxs2 Here is the result: @@ -22192,8 +22189,11 @@ checking Apache version... 2.2.22 checking for python... /usr/bin/python configure: creating ./config.status config.status: creating Makefile -What 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.","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'. -So, do the actual make and see if that fails before assuming you have the wrong apxs.",0.0,False,2,2096 +What 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.","checking for apxs... /usr/sbin/apxs + ... + config.status: creating Makefile + +It succeeded. Go on to the next step.",0.3869120172231254,False,2,2096 2012-09-09 20:44:18.520,"pyqt4, function Mute / Un mute microphone and also speakers [PJSIP]","Hello friends and colleagues I am trying to make a function mute / un mute microphone and also speakers for my program softphone on pyt4 and using library PJSIP I found this in the code pjsip @@ -22327,12 +22327,12 @@ Can someone please point me to how I can use this existing task definition and u So far, a few mysql tables have been enough to handle this, but i fear it will quickly become messy as i add more features. My question: how can i best represent and persist this kind of multi dimensional data? Python specific tips would be helpful. -Thank you","An SQL database should work fine in your case. In fact, you can store all the training examples in just one database, each row representing a particular training set and each column representing a feature. You can add features by adding collumns as and when required. In a relational database, you might come across access errors when querying for your data for various inconsistency reasons. Try using a NoSQL database. I personally user MongoDB and Pymongo on python to store the training examples as dicts in JSON format. (Easier for web apps this way).",0.0,False,2,2103 +Thank you","I recommend using tensors, which is multidimensional arrays. You can use any data table or simply text files to store a tensor. Each line or row is a record / transaction with different features all listed.",0.0,False,2,2103 2012-09-10 16:05:07.727,Multi feature recommender system representation,"I'm looking to expand my recommender system to include other features (dimensions). So far, I'm tracking how a user rates some document, and using that to do the recommendations. I'm interested in adding more features, such as user location, age, gender, and so on. So far, a few mysql tables have been enough to handle this, but i fear it will quickly become messy as i add more features. My question: how can i best represent and persist this kind of multi dimensional data? Python specific tips would be helpful. -Thank you","I recommend using tensors, which is multidimensional arrays. You can use any data table or simply text files to store a tensor. Each line or row is a record / transaction with different features all listed.",0.0,False,2,2103 +Thank you","An SQL database should work fine in your case. In fact, you can store all the training examples in just one database, each row representing a particular training set and each column representing a feature. You can add features by adding collumns as and when required. In a relational database, you might come across access errors when querying for your data for various inconsistency reasons. Try using a NoSQL database. I personally user MongoDB and Pymongo on python to store the training examples as dicts in JSON format. (Easier for web apps this way).",0.0,False,2,2103 2012-09-11 17:43:54.570,IMAP in Corporate Gmail,"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?",IMAP server is still imap.gmail.com -- try with that?,0.3869120172231254,False,1,2104 2012-09-12 06:19:31.393,Terminate python application waiting on semaphore,"I would like to know why doesn't python2.7 drop blocking operations when ctrl+c is pressed, I am unable to kill my threaded application, there are several socket waits, semaphore waits and so on. In python3 ctrl+c dropped every blocking operation and garbage-collected everything, released all the sockets and whatsoever ... Is there (I am convinced there is, I just yet don't know how) a way to acomplish this? Signal handle? Thanks guys","I guess you are launching the threads and then the main thread is waiting to join them on termination. You should catch the exception generated by Ctrl-C in the main thread, in order to signal the spawned threads to terminate (changing a flag in each thread, for instance). In this manner, all the children thread will terminate and the main thread will complete the join call, reaching the bottom of your main.",1.2,True,1,2105 @@ -22383,6 +22383,14 @@ But in any case, an in-memory database (SQLite makes this easy) is the best choi 2012-09-16 04:55:40.777,Auto Text Summarization,"I have decided to develop a Auto Text Summarization Tool using Python/Django. Can someone please recommend books or articles on how to get started? Is there any open source algorithm or made project in the Auto Text Summarization so that I can gain the idea? +Also, would you like to suggest me the new challenging FYP for me in Django/Python?","About papers, I would like to add to the previous answer next ones: + +""Text Data Management and Analysis"" by ChengXiang Zhai and Sean Massung, chapter 16. +""Texts in Computer Science: Fundamentals of Predictive Text Mining"" by Sholom M. Weiss, +Nitin Indurkhya and Tong Zhang (second edition), chapter 9.",0.0,False,2,2113 +2012-09-16 04:55:40.777,Auto Text Summarization,"I have decided to develop a Auto Text Summarization Tool using Python/Django. +Can someone please recommend books or articles on how to get started? +Is there any open source algorithm or made project in the Auto Text Summarization so that I can gain the idea? Also, would you like to suggest me the new challenging FYP for me in Django/Python?","First off for Paper, I recommend: 1- Recent automatic text summarization techniques: a survey by M.Gambhir and V.Gupta 2- A Survey of Text Summarization Techniques, A.Nenkova @@ -22394,14 +22402,6 @@ The Mercenary: Stanford CoreNLP The Usurper: spaCy The Admiral: gensim First off learn about different kinds of summarizations and what suits you best. Also, remember to make sure you have a proper preprocessing tool for the language you are targeting as this is very important for the quality of your summarizer.",0.3869120172231254,False,2,2113 -2012-09-16 04:55:40.777,Auto Text Summarization,"I have decided to develop a Auto Text Summarization Tool using Python/Django. -Can someone please recommend books or articles on how to get started? -Is there any open source algorithm or made project in the Auto Text Summarization so that I can gain the idea? -Also, would you like to suggest me the new challenging FYP for me in Django/Python?","About papers, I would like to add to the previous answer next ones: - -""Text Data Management and Analysis"" by ChengXiang Zhai and Sean Massung, chapter 16. -""Texts in Computer Science: Fundamentals of Predictive Text Mining"" by Sholom M. Weiss, -Nitin Indurkhya and Tong Zhang (second edition), chapter 9.",0.0,False,2,2113 2012-09-17 07:49:03.207,How to input and process audio files to convert to text via pyspeech or dragonfly,"I have seen the documentation of pyspeech and dragonfly, but don't know how to input an audio file to be converted into text. I have tried it with microphone via speaking to it and the speech is converted into text, but If I want to input a previously recorded audio file. Can anyone help with an example?","Both PySpeech and Dragonfly are relatively thin wrappers over SAPI. Unfortunately, both of them use the shared recognizer, which doesn't support input selection. While I'm familiar with SAPI, I'm not that familiar with Python, so I haven't been able to assist anyone with moving PySpeech/Dragonfly over to an in-process recognizer.",0.0,False,1,2114 2012-09-18 03:43:37.437,Fast algorithm comparing unsorted data,"I have data that needs to stay in the exact sequence it is entered in (genome sequencing) and I want to search approximately one billion nodes of around 18 members each to locate patterns. Obviously speed is an issue with this large of a data set, and I actually don't have any data that I can currently use as a discrete key, since the basis of the search is to locate and isolate (but not remove) duplicates. @@ -22451,17 +22451,17 @@ This is what i currently have When I generate random tile I must watch for neighbor. Then I have to take into account the already two neighbors, etc. Recursion? I determined that the field may be the water, the earth, the mountains - but in one field may be the transition from water to land with one of the sides. An array will consist of a number specifying the type of tile. I want to do it in python - for learning. -Some advice please.","There is probably no need to use recursion. Since you do this as a learning exercise, I will only provide you with an outline of how to progress. -The hexagonal grid will need a coordinate system, for the rows and columns. -Create a function neighbours that, given the coordinates x,y of a tile returns all the neighbours of that tile. -Loop through the all the tiles using your coordinate system. For each tile, retrieve its neighbours. If a neighbour does not have a type you can ignore it, otherwise, determine the character of a tile based on the character of its neighbours.",0.0,False,2,2120 +Some advice please.","I think the most important thing is to denote your hexagons on the map in a way which makes checking neighbours easy... +One sensible choice could be to use 2D tuples, so that the hexagon (1,1)'s 6 neighbours are (1,0),(2,0),(2,2),(1,2),(0,2) and (1,1) - starting from north/up and going clockwise. +To populate the map you could then just iterate over all squares picking a random choice from the set of allowable tiles (based on it's current neighbours).",0.0,False,2,2120 2012-09-19 09:50:39.963,How to write own map generator?,"I would like to write for myself a simple map generator and I do not know how to bite. field will have to draw lots hexagonal. When I generate random tile I must watch for neighbor. Then I have to take into account the already two neighbors, etc. Recursion? I determined that the field may be the water, the earth, the mountains - but in one field may be the transition from water to land with one of the sides. An array will consist of a number specifying the type of tile. I want to do it in python - for learning. -Some advice please.","I think the most important thing is to denote your hexagons on the map in a way which makes checking neighbours easy... -One sensible choice could be to use 2D tuples, so that the hexagon (1,1)'s 6 neighbours are (1,0),(2,0),(2,2),(1,2),(0,2) and (1,1) - starting from north/up and going clockwise. -To populate the map you could then just iterate over all squares picking a random choice from the set of allowable tiles (based on it's current neighbours).",0.0,False,2,2120 +Some advice please.","There is probably no need to use recursion. Since you do this as a learning exercise, I will only provide you with an outline of how to progress. +The hexagonal grid will need a coordinate system, for the rows and columns. +Create a function neighbours that, given the coordinates x,y of a tile returns all the neighbours of that tile. +Loop through the all the tiles using your coordinate system. For each tile, retrieve its neighbours. If a neighbour does not have a type you can ignore it, otherwise, determine the character of a tile based on the character of its neighbours.",0.0,False,2,2120 2012-09-19 18:22:58.327,Django: How to upload directly files submitted by a user to another server?,"I'm using Django 1.4. There are two servers (app server and file server). The app server provide a web service using django, wsgi, and apache. @@ -22587,10 +22587,10 @@ more flexible, since I can use it in situations where I somehow already have the Are there any disadvantages to streams? Or should I always refactor a function from a file name argument to a stream argument (assuming, of course, the file is text-only)?","There are numerous functions in the python standard library which accept both -- strings which are filenames or open file objects (I assume that's what you're referring to as a ""stream""). It's really not hard to create a decorator that you can use to make your functions accept either one. One serious drawback to using ""streams"" is that you pass it to your function and then your function reads from it -- effectively changing it's state. Depending on your program, recovering that state could be messy if it's necessary. (e.g. you might need to litter you code with f.tell() and then f.seek().)",1.2,True,1,2130 2012-09-26 14:11:53.743,How does a python web server overcomes GIL,"Any web server might have to handle a lot of requests at the same time. As python interpreter actually has GIL constraint, how concurrency is implemented? -Do they use multiple processes and use IPC for state sharing?","As normal. Web serving is mostly I/O-bound, and the GIL is released during I/O operations. So either threading is used without any special accommodations, or an event loop (such as Twisted) is used.",0.1352210990936997,False,2,2131 -2012-09-26 14:11:53.743,How does a python web server overcomes GIL,"Any web server might have to handle a lot of requests at the same time. As python interpreter actually has GIL constraint, how concurrency is implemented? Do they use multiple processes and use IPC for state sharing?","You usually have many workers(i.e. gunicorn), each being dispatched with independent requests. Everything else(concurrency related) is handled by the database so it is abstracted from you. You don't need IPC, you just need a ""single source of truth"", which will be the RDBMS, a cache server(redis, memcached), etc.",0.2655860252697744,False,2,2131 +2012-09-26 14:11:53.743,How does a python web server overcomes GIL,"Any web server might have to handle a lot of requests at the same time. As python interpreter actually has GIL constraint, how concurrency is implemented? +Do they use multiple processes and use IPC for state sharing?","As normal. Web serving is mostly I/O-bound, and the GIL is released during I/O operations. So either threading is used without any special accommodations, or an event loop (such as Twisted) is used.",0.1352210990936997,False,2,2131 2012-09-27 03:14:19.030,How to automate the sending of files over the network using python?,"Here's what I need to do: I need to copy files over the network. The files to be copied is in the one machine and I need to send it to the remote machines. It should be automated and it should be made using python. I am quite familiar with os.popen and subprocess.Popen of python. I could use this to copy the files, BUT, the problem is once I have run the one-liner command (like the one shown below) @@ -22640,6 +22640,13 @@ I'm sure there are more substantial features you're not using that you could hac The only other real alternative would be to write a smaller interpreter for a Python-like language—e.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. Well, 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.",0.3869120172231254,False,1,2135 2012-09-28 09:00:37.293,Moving nodes from one tree to another with Dynatree,"I'm currently working on a django project and i'm using dynatree to build treeview. +I have two trees, first tree has items that user can select and the selected items will be moved to second tree. Is there a way that I can do so in dynatree?And there's an option for user to ""unselect"" the item so the selected item will move back to the first tree. So when user unselect the item, how can i move the item back to its original parent node? Thanks in advance..","I've solved my problem using the copy/paste concept of context menu. +And for the second problem, I used global variable to store the original parent node so when user unselect the item, it will move back to its original parent.",1.2,True,3,2136 +2012-09-28 09:00:37.293,Moving nodes from one tree to another with Dynatree,"I'm currently working on a django project and i'm using dynatree to build treeview. +I have two trees, first tree has items that user can select and the selected items will be moved to second tree. Is there a way that I can do so in dynatree?And there's an option for user to ""unselect"" the item so the selected item will move back to the first tree. So when user unselect the item, how can i move the item back to its original parent node? Thanks in advance..","There is a difference between 'selected' and 'active'. +Selection is typically done using checkboxes, while only one node can be activated (typically by a mouse click). +A 2nd click on an active node will not fire an 'onActivate' event, but you can implement the 'onClick' handler to catch this and call node.deactivate()",0.0,False,3,2136 +2012-09-28 09:00:37.293,Moving nodes from one tree to another with Dynatree,"I'm currently working on a django project and i'm using dynatree to build treeview. I have two trees, first tree has items that user can select and the selected items will be moved to second tree. Is there a way that I can do so in dynatree?And there's an option for user to ""unselect"" the item so the selected item will move back to the first tree. So when user unselect the item, how can i move the item back to its original parent node? Thanks in advance..","I have a dynamTree on a DIV dvAllLetterTemplates (which contains a master List) and a DIV dvUserLetterTemplates to which items are to be copied. //Select the Parent Node of the Destination Tree @@ -22659,13 +22666,6 @@ if (catNode != null) { $(""#dvAllLetterTemplates"").dynatree(""getTree"").redraw(); } }",0.1352210990936997,False,3,2136 -2012-09-28 09:00:37.293,Moving nodes from one tree to another with Dynatree,"I'm currently working on a django project and i'm using dynatree to build treeview. -I have two trees, first tree has items that user can select and the selected items will be moved to second tree. Is there a way that I can do so in dynatree?And there's an option for user to ""unselect"" the item so the selected item will move back to the first tree. So when user unselect the item, how can i move the item back to its original parent node? Thanks in advance..","There is a difference between 'selected' and 'active'. -Selection is typically done using checkboxes, while only one node can be activated (typically by a mouse click). -A 2nd click on an active node will not fire an 'onActivate' event, but you can implement the 'onClick' handler to catch this and call node.deactivate()",0.0,False,3,2136 -2012-09-28 09:00:37.293,Moving nodes from one tree to another with Dynatree,"I'm currently working on a django project and i'm using dynatree to build treeview. -I have two trees, first tree has items that user can select and the selected items will be moved to second tree. Is there a way that I can do so in dynatree?And there's an option for user to ""unselect"" the item so the selected item will move back to the first tree. So when user unselect the item, how can i move the item back to its original parent node? Thanks in advance..","I've solved my problem using the copy/paste concept of context menu. -And for the second problem, I used global variable to store the original parent node so when user unselect the item, it will move back to its original parent.",1.2,True,3,2136 2012-09-30 03:39:24.383,Installing a django site on GoDaddy,I have never deployed a Django site before. I am currently looking to set it up in my deluxe GoDaddy account. Does anyone have any documentation on how to go about installing python and django on GoDaddy?,"I am not familiar with GoDaddy's setup specifically, but in general, you cannot install Django on shared hosting unless it is supported specifically (a la Dreamhost). So unless GoDaddy specifically mentions Django (or possibly mod_wsgi or something) in their documentation, which is unlikely, you can assume it is not supported. Theoretically you can install Python and run Django from anywhere you have shell access and sufficient permissions, but you won't be able to actually serve your Django site as part of your shared hosting (i.e., on port 80 and responding to your selected hostname) because you don't have access to the webserver configuration. You will need either a VPS (GoDaddy offers them but it's not their core business; Linode and Rackspace are other options), or a shared host that specifically supports Django (e.g. Dreamhost), or an application host (Heroku or Google App Engine). I recommend Heroku personally, especially if you are not confident in setting up and maintaining your own webserver.",0.2401167094949473,False,1,2137 @@ -22719,20 +22719,20 @@ I trained a latent semantic indexing model, using gensim, on the wikipedia corpu So my question is: how to represent the users? An idea I had is the following: represent a user as the aggregation of all the documents viewed. But how to take into account the rating? Any ideas? -Thanks","I don't think that's working with lsa. -But you maybe could do some sort of k-NN classification, where each user's coordinates are the documents viewed. Each object (=user) sends out radiation (intensity is inversely proportional to the square of the distance). The intensity is calculated from the ratings on the single documents. -Then you can place a object (user) in in this hyperdimensional space, and see what other users give the most 'light'. -But: Can't Apache Lucene do that whole stuff for you?",0.2012947653214861,False,2,2147 -2012-10-06 20:31:45.100,User profiling for topic-based recommender system,"I'm trying to come up with a topic-based recommender system to suggest relevant text documents to users. -I trained a latent semantic indexing model, using gensim, on the wikipedia corpus. This lets me easily transform documents into the LSI topic distributions. My idea now is to represent users the same way. However, of course, users have a history of viewed articles, as well as ratings of articles. -So my question is: how to represent the users? -An idea I had is the following: represent a user as the aggregation of all the documents viewed. But how to take into account the rating? -Any ideas? Thanks","""represent a user as the aggregation of all the documents viewed"" : that might work indeed, given that you are in linear spaces. You can easily add all the documents vectors in one big vector. If you want to add the ratings, you could simply put a coefficient in the sum. Say you group all documents rated 2 in a vector D2, rated 3 in D3 etc... you then simply define a user vector as U=c2*D2+c3*D3+... You can play with various forms for c2, c3, but the easiest approach would be to simply multiply by the rating, and divide by the max rating for normalisation reasons. If your max rating is 5, you could define for instance c2=2/5, c3=3/5 ...",0.0,False,2,2147 +2012-10-06 20:31:45.100,User profiling for topic-based recommender system,"I'm trying to come up with a topic-based recommender system to suggest relevant text documents to users. +I trained a latent semantic indexing model, using gensim, on the wikipedia corpus. This lets me easily transform documents into the LSI topic distributions. My idea now is to represent users the same way. However, of course, users have a history of viewed articles, as well as ratings of articles. +So my question is: how to represent the users? +An idea I had is the following: represent a user as the aggregation of all the documents viewed. But how to take into account the rating? +Any ideas? +Thanks","I don't think that's working with lsa. +But you maybe could do some sort of k-NN classification, where each user's coordinates are the documents viewed. Each object (=user) sends out radiation (intensity is inversely proportional to the square of the distance). The intensity is calculated from the ratings on the single documents. +Then you can place a object (user) in in this hyperdimensional space, and see what other users give the most 'light'. +But: Can't Apache Lucene do that whole stuff for you?",0.2012947653214861,False,2,2147 2012-10-08 05:34:48.387,Django - How does order_by work?,"I'd like to know how Django's order_by works if the given order_by field's values are same for a set of records. Consider I have a score field in DB and I'm filtering the queryset using order_by('score'). How will records having the same values for score arrange themselves? Every time, they're ordered randomly within the subset of records having equal score and this breaks the pagination at client side. Is there a way to override this and return the records in a consistent order? I'm Using Django 1.4 and PostgreSQL.","order_by can have multiple params, I think order_by('score', '-create_time') will always return the same queryset.",1.2,True,1,2148 @@ -23072,9 +23072,9 @@ e.g. -text=A8980BQDFZDD1701209.3 => -A8980BQDFZDD",You can use rstrip. Check the 2012-11-04 03:43:37.487,Separate strings from other iterables in python 3,"I'm trying to determine whether a function argument is a string, or some other iterable. Specifically, this is used in building URL parameters, in an attempt to emulate PHP's ¶m[]=val syntax for arrays - so duck typing doesn't really help here, I can iterate through a string and produce things like ¶m[]=v¶m[]=a¶m[]=l, but this is clearly not what we want. If the parameter value is a string (or a bytes? I still don't know what the point of a bytes actually is), it should produce ¶m=val, but if the parameter value is (for example) a list, each element should receive its own ¶m[]=val. I've seen a lot of explanations about how to do this in 2.* involving isinstance(foo, basestring), but basestring doesn't exist in 3.*, and I've also read that isinstance(foo, str) will miss more complex strings (I think unicode?). So, what is the best way to do this without causing some types to be lost to unnecessary errors?","You've been seeing things that somewhat conflict based on Python 2 vs 3. In Python 3, isinstance(foo, str) is almost certainly what you want. bytes is for raw binary data, which you probably can't include in an argument string like that. The python 2 str type stored raw binary data, usually a string in some specific encoding like utf8 or latin-1 or something; the unicode type stored a more ""abstract"" representation of the characters that could then be encoded into whatever specific encoding. basestring was a common ancestor for both of them so you could easily say ""any kind of string"". In python 3, str is the more ""abstract"" type, and bytes is for raw binary data (like a string in a specific encoding, or whatever raw binary data you want to handle). You shouldn't use bytes for anything that would otherwise be a string, so there's not a real reason to check if it's either str or bytes. If you absolutely need to, though, you can do something like isinstance(foo, (str, bytes)).",1.2,True,1,2191 +2012-11-04 20:33:34.873,Can you run python as a windowed program?,"Hello fellow python users, I bring forth a question that I have been wondering for a while. I love python, and have made many programs with it. Now what I want to do is (or know how to do) make a python program, but run it in a window with buttons that you click on instead of typing in numbers to elect things. I would like to just know weather or not I can do this, and if I can, please tell me where to go to learn how. Ok, it's not for the iPhone, sorry that I wasn't clear on that, and I didn't realize that iPhone was one of the tags.","You can do this, the library is called tkinter.",0.0,False,2,2192 2012-11-04 20:33:34.873,Can you run python as a windowed program?,"Hello fellow python users, I bring forth a question that I have been wondering for a while. I love python, and have made many programs with it. Now what I want to do is (or know how to do) make a python program, but run it in a window with buttons that you click on instead of typing in numbers to elect things. I would like to just know weather or not I can do this, and if I can, please tell me where to go to learn how. Ok, it's not for the iPhone, sorry that I wasn't clear on that, and I didn't realize that iPhone was one of the tags.","There are many GUI libraries to choose from, but I like Tkinter because it's easy and there's nothing to install (it comes with Python). But some people prefer wxPython or others, such as PyQT. You'll have to decide which you like, or just go with Tkinter if you don't want to go through the trouble of installing libraries just to try them out.",0.0,False,2,2192 -2012-11-04 20:33:34.873,Can you run python as a windowed program?,"Hello fellow python users, I bring forth a question that I have been wondering for a while. I love python, and have made many programs with it. Now what I want to do is (or know how to do) make a python program, but run it in a window with buttons that you click on instead of typing in numbers to elect things. I would like to just know weather or not I can do this, and if I can, please tell me where to go to learn how. Ok, it's not for the iPhone, sorry that I wasn't clear on that, and I didn't realize that iPhone was one of the tags.","You can do this, the library is called tkinter.",0.0,False,2,2192 2012-11-05 13:27:41.747,using neo4J (server) from python with transaction,"I'm currently building a web service using python / flask and would like to build my data layer on top of neo4j, since my core data structure is inherently a graph. I'm a bit confused by the different technologies offered by neo4j for that case. Especially : @@ -23091,8 +23091,8 @@ Nigel",1.2,True,1,2193 2012-11-05 14:32:16.047,"""error: cannot locate an Oracle software installation"" When trying to install cx_Oracle","Newbie here trying to use python to do some database analysis. I keep getting the error: ""error: cannot locate an Oracle software installation"" When installing CX_oracle (via easy_install). The problem is I do not have oracle on my local machine, I'm trying to use python to connect to the main oracle server. I have have setup another program to do this(visualdb) and I had a .jar file I used as the driver but I'm not sure how to use it in this case. -Any suggestions?","I installed cx_Oracle, but I also had to install an Oracle client to use it (the cx_Oracle module is just a common and pythonic way to interface with the Oracle client in Python). -So you have to set the variable ORACLE_HOME to your Oracle client folder (on Unix: via a shell, for instance; on Windows: create a new variable if it does not exist in the Environment variables of the Configuration Panel). Your folder $ORACLE_HOME/network/admin (%ORACLE_HOME%\network\admin on Windows) is the place where you would place your tnsnames.ora file.",0.1352210990936997,False,3,2194 +Any suggestions?","Tip for Ubuntu users +After configuring .bashrc environment variables, like it was explained in other answers, don't forget to reload your terminal window, typing $SHELL.",0.0679224682270276,False,3,2194 2012-11-05 14:32:16.047,"""error: cannot locate an Oracle software installation"" When trying to install cx_Oracle","Newbie here trying to use python to do some database analysis. I keep getting the error: ""error: cannot locate an Oracle software installation"" When installing CX_oracle (via easy_install). The problem is I do not have oracle on my local machine, I'm trying to use python to connect to the main oracle server. I have have setup another program to do this(visualdb) and I had a .jar file I used as the driver but I'm not sure how to use it in this case. @@ -23101,8 +23101,8 @@ What worked for me: reinstalled python with 64 bit (had 32 for some reason), ins 2012-11-05 14:32:16.047,"""error: cannot locate an Oracle software installation"" When trying to install cx_Oracle","Newbie here trying to use python to do some database analysis. I keep getting the error: ""error: cannot locate an Oracle software installation"" When installing CX_oracle (via easy_install). The problem is I do not have oracle on my local machine, I'm trying to use python to connect to the main oracle server. I have have setup another program to do this(visualdb) and I had a .jar file I used as the driver but I'm not sure how to use it in this case. -Any suggestions?","Tip for Ubuntu users -After configuring .bashrc environment variables, like it was explained in other answers, don't forget to reload your terminal window, typing $SHELL.",0.0679224682270276,False,3,2194 +Any suggestions?","I installed cx_Oracle, but I also had to install an Oracle client to use it (the cx_Oracle module is just a common and pythonic way to interface with the Oracle client in Python). +So you have to set the variable ORACLE_HOME to your Oracle client folder (on Unix: via a shell, for instance; on Windows: create a new variable if it does not exist in the Environment variables of the Configuration Panel). Your folder $ORACLE_HOME/network/admin (%ORACLE_HOME%\network\admin on Windows) is the place where you would place your tnsnames.ora file.",0.1352210990936997,False,3,2194 2012-11-05 16:38:17.913,How to put files in folders using py2exe.,"Hi!I made a chess engine in python which i then compiled to .exe using py2exe. The problem is that it doesn't look very neat when i have all the strange files gathered together in the same folder (dist). I'd like to make a new folder inside the dist folder that contains all the helper files, so all my dist folder contains is the folder holding the helper files and the main launch application. However, i can't simply copy the helper files to a new folder, as the computer doesn't find them then and raises an error. How can it be solved? Also, i'm using inno setup to make an installation, but i can't figure out how to find a solution there, either. Thank you very much!","There is a feature in the configuration of py2exe that allows you to bundle all the Python files in a single library.zip file. That would considerably reduce the amount of files in the root directory, but there will still remain some files, regardless of all that. @@ -23216,13 +23216,9 @@ I was also worried about some claims of a limit of one 1 put() per entity group I tested this with an empty app without any traffic and I am wondering how much a real traffic would affect the ""eventual consistency"". I am aware I can test ""eventual consistency"" on local development. My question is: Do I really need to restructure my app to handle eventual consistency? -Or it would be acceptable to leave it the way it is because the eventual consistency is actually consistent in practice for 99%?","What's the worst case if you get inconsistent results? - -Does a user see some unimportant info that's out of date? That's probably ok. -Will you miscalculate something important, like the price of something? Or the number of items in stock in a store? In that case, you would want to avoid that chance occurence. - -From observation only, it seems like eventually consistent results show up more as your dataset gets larger, I suspect as your data is split across more tablets. -Also, if you're reading your entities back with get() requests by key/id, it'll always be consistent. Make sure you're doing a query to get eventually consistent results.",0.0,False,3,2217 +Or it would be acceptable to leave it the way it is because the eventual consistency is actually consistent in practice for 99%?","If you have a small app then your data probably live on the same part of the same disk and you have one instance. You probably won't notice eventual consistency. As your app grows, you notice it more. Usually it takes milliseconds to reach consistency, but I've seen cases where it takes an hour or more. +Generally, queries is where you notice it most. One way to reduce the impact is to query by keys only and then use ndb.get_multi() to load the entities. Fetching entities by keys ensures that you get the latest version of that entity. It doesn't guarantee that the keys list is strongly consistent, though. So you might get entities that don't match the query conditions, so loop through the entities and skip the ones that don't match. +From what I've noticed, the pain of eventual consistency grows gradually as your app grows. At some point you do need to take it seriously and update the critical areas of your code to handle it.",1.2,True,3,2217 2012-11-19 05:49:18.757,"In practice, how eventual is the ""eventual consistency"" in HRD?","I am in the process of migrating an application from Master/Slave to HRD. I would like to hear some comments from who already went through the migration. I tried a simple example to just post a new entity without ancestor and redirecting to a page to list all entities from that model. I tried it several times and it was always consistent. Them I put 500 indexed properties and again, always consistent... @@ -23241,9 +23237,13 @@ I was also worried about some claims of a limit of one 1 put() per entity group I tested this with an empty app without any traffic and I am wondering how much a real traffic would affect the ""eventual consistency"". I am aware I can test ""eventual consistency"" on local development. My question is: Do I really need to restructure my app to handle eventual consistency? -Or it would be acceptable to leave it the way it is because the eventual consistency is actually consistent in practice for 99%?","If you have a small app then your data probably live on the same part of the same disk and you have one instance. You probably won't notice eventual consistency. As your app grows, you notice it more. Usually it takes milliseconds to reach consistency, but I've seen cases where it takes an hour or more. -Generally, queries is where you notice it most. One way to reduce the impact is to query by keys only and then use ndb.get_multi() to load the entities. Fetching entities by keys ensures that you get the latest version of that entity. It doesn't guarantee that the keys list is strongly consistent, though. So you might get entities that don't match the query conditions, so loop through the entities and skip the ones that don't match. -From what I've noticed, the pain of eventual consistency grows gradually as your app grows. At some point you do need to take it seriously and update the critical areas of your code to handle it.",1.2,True,3,2217 +Or it would be acceptable to leave it the way it is because the eventual consistency is actually consistent in practice for 99%?","What's the worst case if you get inconsistent results? + +Does a user see some unimportant info that's out of date? That's probably ok. +Will you miscalculate something important, like the price of something? Or the number of items in stock in a store? In that case, you would want to avoid that chance occurence. + +From observation only, it seems like eventually consistent results show up more as your dataset gets larger, I suspect as your data is split across more tablets. +Also, if you're reading your entities back with get() requests by key/id, it'll always be consistent. Make sure you're doing a query to get eventually consistent results.",0.0,False,3,2217 2012-11-19 09:28:04.363,Pygame: Graphical Input + Text Input,"In Pygame, how can I get graphical input(e.g. clicking exit button) and also get input from the a terminal window simultaneously? To give you context, my game has a GUI but gets its game commands from a ""input()"" command. How can I look for input from the command line while also handling graphics? I'm not sure if this is possible, but if not, what other options do I have for getting text input from the user? @@ -23304,6 +23304,14 @@ I want to read this data and write it to shared memory so there can be other pro I've been reading about mmap and it seems I have to use a file... which I can't seem to understand why. I have an a.py that reads the data from the socket, but how can I write it to an shm? Once once it's written, I need to write b.py, c.py, d.py, etc., to read the very same shm and do things to it. +Any help or snippet of codes would greatly help.","First, note that what you're trying to build will require more than just shared memory: it's all well if a.py writes to shared memory, but how will b.py know when the memory is ready and can be read from? All in all, it is often simpler to solve this problem by connecting the multiple processes not via shared memory, but through some other mechanism. +(The reason for why mmap usually needs a file name is that it needs a name to connect the several processes. Indeed, if a.py and b.py both call mmap(), how would the system know that these two processes are asking for memory to be shared between them, and not some unrelated z.py? Because they both mmaped the same file. There are also Linux-specific extensions to give a name that doesn't correspond to a file name, but it's more a hack IMHO.) +Maybe the most basic alternative mechanism is pipes: they are usually connected with the help of the shell when the programs are started. That's how the following works (on Linux/Unix): python a.py | python b.py. Any output that a.py sends goes to the pipe, whose other end is the input for b.py. You'd write a.py so that it listens to the UDP socket and writes the data to stdout, and b.py so that it reads from stdin to process the data received. If the data needs to go to several processes, you can use e.g. named pipes, which have a nice (but Bash-specific) syntax: python a.py >(python b.py) >(python c.py) will start a.py with two arguments, which are names of pseudo-files that can be opened and written to. Whatever is written to the first pseudo-file goes as input for b.py, and similarly what is written to the second pseudo-file goes as input for c.py.",0.0,False,2,2225 +2012-11-21 05:51:28.630,how to write to shared memory in python from stream?,"I have a processes from several servers that send data to my local port 2222 via udp every second. +I want to read this data and write it to shared memory so there can be other processes to read the data from shared memory and do things to it. +I've been reading about mmap and it seems I have to use a file... which I can't seem to understand why. +I have an a.py that reads the data from the socket, but how can I write it to an shm? +Once once it's written, I need to write b.py, c.py, d.py, etc., to read the very same shm and do things to it. Any help or snippet of codes would greatly help.","mmap doesn't take a file name but rather a file descriptor. It performs the so-called memory mapping, i.e. it associates pages in the virtual memory space of the process with portions of the file-like object, represented by the file descriptor. This is a very powerful operation since it allows you: to access the content of a file simply as an array in memory; @@ -23315,14 +23323,6 @@ The modern POSIX way to use shared memory is to open a file-like memory object w (these are part of the C API; what Python modules provide is more or less thin wrappers around those calls and often have nearly the same signature) It is also possible to get shared memory by memory mapping the same regular file in all processes that need to share memory. As a matter of fact, Linux implements the POSIX shared memory operations by creating files on a special tmpfs file system. The tmpfs driver implements very lightweight memory mapping by directly mapping the pages that hold the file content into the address space of the process that executes mmap(2). Since tmpfs behaves as a normal filesystem, you can examine its content using ls, cat and other shell tools. You can even create shared memory objects this way or modify the content of the existent ones. The difference between a file in tmpfs and a regular filesystem file is that the latter is persisted to storage media (hard disk, network storage, flash drive, etc.) and occasionally changes are flushed to this storage media while the former lives entirely in RAM. Solaris also provides similar RAM-based filesystem, also called tmpfs. In modern operating systems memory mapping is used extensively. Executable files are memory-mapped in order to supply the content of those pages, that hold the executable code and the static data. Also shared libraries are memory-mapped. This saves physical memory since these mappings are shared, e.g. the same physical memory that holds the content of an executable file or a shared library is mapped in the virtual memory space of each process.",0.0,False,2,2225 -2012-11-21 05:51:28.630,how to write to shared memory in python from stream?,"I have a processes from several servers that send data to my local port 2222 via udp every second. -I want to read this data and write it to shared memory so there can be other processes to read the data from shared memory and do things to it. -I've been reading about mmap and it seems I have to use a file... which I can't seem to understand why. -I have an a.py that reads the data from the socket, but how can I write it to an shm? -Once once it's written, I need to write b.py, c.py, d.py, etc., to read the very same shm and do things to it. -Any help or snippet of codes would greatly help.","First, note that what you're trying to build will require more than just shared memory: it's all well if a.py writes to shared memory, but how will b.py know when the memory is ready and can be read from? All in all, it is often simpler to solve this problem by connecting the multiple processes not via shared memory, but through some other mechanism. -(The reason for why mmap usually needs a file name is that it needs a name to connect the several processes. Indeed, if a.py and b.py both call mmap(), how would the system know that these two processes are asking for memory to be shared between them, and not some unrelated z.py? Because they both mmaped the same file. There are also Linux-specific extensions to give a name that doesn't correspond to a file name, but it's more a hack IMHO.) -Maybe the most basic alternative mechanism is pipes: they are usually connected with the help of the shell when the programs are started. That's how the following works (on Linux/Unix): python a.py | python b.py. Any output that a.py sends goes to the pipe, whose other end is the input for b.py. You'd write a.py so that it listens to the UDP socket and writes the data to stdout, and b.py so that it reads from stdin to process the data received. If the data needs to go to several processes, you can use e.g. named pipes, which have a nice (but Bash-specific) syntax: python a.py >(python b.py) >(python c.py) will start a.py with two arguments, which are names of pseudo-files that can be opened and written to. Whatever is written to the first pseudo-file goes as input for b.py, and similarly what is written to the second pseudo-file goes as input for c.py.",0.0,False,2,2225 2012-11-21 23:10:06.700,"""Force"" User Input and Checking for correct Input Type","I have some functions calling for user input, sometimes string, int or whatever. so i noticed that if ENTER is pressed with NO INPUT i get an error. SO i did some research and i think i found that EVAL function may be what I'm looking for, but then again i read about its dangers. SO here are my questions: @@ -23372,8 +23372,12 @@ File ""/****/****/.local/lib/python/django/db/backends/mysql/base.py"", line 14, ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory Of course, Bluehost support is not too helpful. They advised that 1) I use the default python install, because that has MySQLdb installed already. Or that 2) I somehow import the MySQLdb package installed on the default python, from my python(dont know if this can even be done). I am concerned that if I use the default install I wont have permission to install my other packages. -Does anybody have any ideas how to get back to a working state, with as little infrastructure changes as possible?","I think you upgraded your OS installation which in turn upgraded libmysqlclient and broke native extension. What you can do is reinstall libmysqlclient16 again (how to do it depends your particular OS) and that should fix your issue. -Other approach would be to uninstall MySQLdb module and reinstall it again, forcing python to compile it against a newer library.",1.2,True,2,2233 +Does anybody have any ideas how to get back to a working state, with as little infrastructure changes as possible?","You were right. Bluehost upgraded MySQL. Here is what I did: +1) remove the ""build"" directory in the ""MySQL-python-1.2.3"" directory +2) remove the egg +3) build the module again ""python setup.py build"" +4) install the module again ""python setup.py install --prefix=$HOME/.local"" +Morale of the story for me is to remove the old stuff when reinstalling module",0.0,False,2,2233 2012-11-26 21:20:55.197,Python module issue,"I have a shared hosting environment on Bluehost. I am running a custom installation of python(+ django) with a few installed modules. All has been working, until yesterday a change was made on the server(I assume) which gave me this django error: ... File ""/****/****/.local/lib/python/django/utils/importlib.py"", line 35, in import_module @@ -23385,12 +23389,8 @@ File ""/****/****/.local/lib/python/django/db/backends/mysql/base.py"", line 14, ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient_r.so.16: cannot open shared object file: No such file or directory Of course, Bluehost support is not too helpful. They advised that 1) I use the default python install, because that has MySQLdb installed already. Or that 2) I somehow import the MySQLdb package installed on the default python, from my python(dont know if this can even be done). I am concerned that if I use the default install I wont have permission to install my other packages. -Does anybody have any ideas how to get back to a working state, with as little infrastructure changes as possible?","You were right. Bluehost upgraded MySQL. Here is what I did: -1) remove the ""build"" directory in the ""MySQL-python-1.2.3"" directory -2) remove the egg -3) build the module again ""python setup.py build"" -4) install the module again ""python setup.py install --prefix=$HOME/.local"" -Morale of the story for me is to remove the old stuff when reinstalling module",0.0,False,2,2233 +Does anybody have any ideas how to get back to a working state, with as little infrastructure changes as possible?","I think you upgraded your OS installation which in turn upgraded libmysqlclient and broke native extension. What you can do is reinstall libmysqlclient16 again (how to do it depends your particular OS) and that should fix your issue. +Other approach would be to uninstall MySQLdb module and reinstall it again, forcing python to compile it against a newer library.",1.2,True,2,2233 2012-11-27 13:25:05.293,Subprocess in Reading Serial Port Read,"Hi I am using Serial port communication to one of my device using python codes. It is sending a set of Hex code, Receives a set of data. process it. This data has to be stored in to a database. I have another script that has MYSQLdb library pushing it in to the database. @@ -23430,17 +23430,17 @@ Not really a good solution, but a solution.",0.0,False,1,2236 Now I want to add functionality to show if a person is online. Now one of the ways I figure out doing this is by keeping online status bit in the database. My question is how to do it dynamically. Say the page is loaded and a user (say connection) comes online. How do I dynamically change status of that connection on that page. -I wanted to know if there are any tools(libraries) available for this type of tracking. My site is in python using django framework. I think something can be done using javascript/ jquery . I want to know if I am going in the right direction or is there anything else I should look into?","As Sanjay says, prefer using memory solutions (online statuses have a quite brief use) like the Django cache (Redis or Memcache). -If you want a simple way of updating the online status of an user on an already loaded web page, use any lib like jQuery, AJAX-poll an URL giving the status of an user, and then update the tiny bit of your page showing your wanted status. -Don't poll this page too often, once every 15 seconds seems reasonable.",0.0,False,2,2237 -2012-11-28 16:38:03.607,Tracking online status?,"I am quite new to web development and am working on this social networking site. -Now I want to add functionality to show if a person is online. -Now one of the ways I figure out doing this is by keeping online status bit in the database. -My question is how to do it dynamically. Say the page is loaded and a user (say connection) comes online. How do I dynamically change status of that connection on that page. I wanted to know if there are any tools(libraries) available for this type of tracking. My site is in python using django framework. I think something can be done using javascript/ jquery . I want to know if I am going in the right direction or is there anything else I should look into?","Create a new model with a last_activity DateTimeField and a OneToOneField to User. Alternatively, if you are subclassing User, using a custom User in django 1.5, or using a user profile, just add the field to that model. Write a custom middleware that automatically updates the last_activity field for each user on every request. Write an is_online method in one of your models that uses a timedelta to determine a user's inactivity period to return a boolean for whether they are online. For example, if their last_activity was more than 15 minutes ago, return False. Write a view that is polled through jQuery ajax to return a particular user's online status.",0.2012947653214861,False,2,2237 +2012-11-28 16:38:03.607,Tracking online status?,"I am quite new to web development and am working on this social networking site. +Now I want to add functionality to show if a person is online. +Now one of the ways I figure out doing this is by keeping online status bit in the database. +My question is how to do it dynamically. Say the page is loaded and a user (say connection) comes online. How do I dynamically change status of that connection on that page. +I wanted to know if there are any tools(libraries) available for this type of tracking. My site is in python using django framework. I think something can be done using javascript/ jquery . I want to know if I am going in the right direction or is there anything else I should look into?","As Sanjay says, prefer using memory solutions (online statuses have a quite brief use) like the Django cache (Redis or Memcache). +If you want a simple way of updating the online status of an user on an already loaded web page, use any lib like jQuery, AJAX-poll an URL giving the status of an user, and then update the tiny bit of your page showing your wanted status. +Don't poll this page too often, once every 15 seconds seems reasonable.",0.0,False,2,2237 2012-11-28 17:38:01.940,Creating a haar classifier using opencv_traincascade,"I am having a little bit of trouble creating a haar classifier. I need to build up a classifier to detect cars. At the moment I made a program in python that reads in an image, I draw a rectangle around the area the object is in, Once the rectangle is drawn, it outputs the image name, the top left and bottom right coordinates of the rectangle. I am unsure of where to go from here and how to actually build up the classifier. Can anyone offer me any help? EDIT* I am looking for help on how to use the opencv_traincascade. I have looked at the documentation but I can't quite figure out how to use it to create the xml file to be used in the detection program.","This looks like you need to determine what features you would like to train your classifier on first, as using the haar classifier it benefits from those extra features. From there you will need to train the classifier, this requires you to get a lot of images that have cars and those that do not have cars in them and then run it over this and having it tweak the average it is shooting for in order to classify to the best it can with your selected features. @@ -23461,18 +23461,6 @@ A full implementation would also keep track of the time they are supposed to be 2012-11-30 22:29:36.167,How to make Python get the username in windows and then implement it in a script,"I know that using getpass.getuser() command, I can get the username, but how can I implement it in the following script automatically? So i want python to find the username and then implement it in the following script itself. Script: os.path.join('..','Documents and Settings','USERNAME','Desktop')) -(Python Version 2.7 being used)","os.getlogin() return the user that is executing the, so it can be: -path = os.path.join('..','Documents and Settings',os.getlogin(),'Desktop') -or, using getpass.getuser() -path = os.path.join('..','Documents and Settings',getpass.getuser(),'Desktop') -If I understand what you asked.",1.2,True,3,2242 -2012-11-30 22:29:36.167,How to make Python get the username in windows and then implement it in a script,"I know that using -getpass.getuser() command, I can get the username, but how can I implement it in the following script automatically? So i want python to find the username and then implement it in the following script itself. -Script: os.path.join('..','Documents and Settings','USERNAME','Desktop')) -(Python Version 2.7 being used)",os.getlogin() did not exist for me. I had success with os.getenv('username') however.,0.9997979416121844,False,3,2242 -2012-11-30 22:29:36.167,How to make Python get the username in windows and then implement it in a script,"I know that using -getpass.getuser() command, I can get the username, but how can I implement it in the following script automatically? So i want python to find the username and then implement it in the following script itself. -Script: os.path.join('..','Documents and Settings','USERNAME','Desktop')) (Python Version 2.7 being used)","you can try the following as well: import os @@ -23480,6 +23468,18 @@ print (os.environ['USERPROFILE']) The advantage of this is that you directly get an output like: C:\\Users\\user_name",0.0814518047658113,False,3,2242 +2012-11-30 22:29:36.167,How to make Python get the username in windows and then implement it in a script,"I know that using +getpass.getuser() command, I can get the username, but how can I implement it in the following script automatically? So i want python to find the username and then implement it in the following script itself. +Script: os.path.join('..','Documents and Settings','USERNAME','Desktop')) +(Python Version 2.7 being used)",os.getlogin() did not exist for me. I had success with os.getenv('username') however.,0.9997979416121844,False,3,2242 +2012-11-30 22:29:36.167,How to make Python get the username in windows and then implement it in a script,"I know that using +getpass.getuser() command, I can get the username, but how can I implement it in the following script automatically? So i want python to find the username and then implement it in the following script itself. +Script: os.path.join('..','Documents and Settings','USERNAME','Desktop')) +(Python Version 2.7 being used)","os.getlogin() return the user that is executing the, so it can be: +path = os.path.join('..','Documents and Settings',os.getlogin(),'Desktop') +or, using getpass.getuser() +path = os.path.join('..','Documents and Settings',getpass.getuser(),'Desktop') +If I understand what you asked.",1.2,True,3,2242 2012-12-01 00:34:49.430,"How do I manage a dynamic, changing main menu in wxPython?","I'm writing a document based application in wxPython, by which I mean that the user can have open multiple documents at once in multiple windows or tabs. There are multiple kinds of documents, and the documents can all be in different ""states"", meaning that there should be different menu options available in the main menu. I know how to disable and enable menu items using the wx.EVT_UPDATE_UI event, but I can't figure out how to pull off a main menu that changes structure and content drastically based on which document that currently has focus. One of my main issues is that the main menu is created in the top level window, and it has to invoke methods in grand children and great grand children that haven't even been created yet. @@ -23546,9 +23546,7 @@ The reason we want to use NoSQL is that MySQL is known to have problems in scalability when the databases grows. We 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). -We'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.","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. -If 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). -I strongly urge you to reconsider your decisions. They seem very ill-advised.",0.2012947653214861,False,2,2248 +We'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.","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.",0.6730655149877884,False,2,2248 2012-12-03 00:05:56.417,"How to utilize OpenBSD, Nginx, Python and NoSQL","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. We'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. @@ -23561,7 +23559,9 @@ The reason we want to use NoSQL is that MySQL is known to have problems in scalability when the databases grows. We 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). -We'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.","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.",0.6730655149877884,False,2,2248 +We'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.","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. +If 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). +I strongly urge you to reconsider your decisions. They seem very ill-advised.",0.2012947653214861,False,2,2248 2012-12-04 11:42:20.873,windows 8 incompatibility?,"I cannot get my code to run on my win8 laptop. I am working with a combination of: Stackless Python 2.7.2 @@ -23581,7 +23581,8 @@ sometimes i get the exception: TypeError: Error when calling the metaclass bases Especially the last two don't seem like a windows problem, but i don't see any other difference with my PC win7 install. Does anyone have any idea what is going on or how to fix this? Did i miss a step in the installation or is it some incompatibility maybe? Cheers, Lars -Does anyone have some input on this?","try using Hyper-V however Hyper-V is not installed by default in Windows 8. You need to go ""Turn Windows features on or off.""",0.0,False,2,2249 +Does anyone have some input on this?","I had the same problem with Pyside 1.1.2 and Qt 4.8.4. The solution for me was to set the compatibility mode of the Python executable to Windows 7 via right click on the executable -> Properties -> Compatiblity -> Run this program in compatibility mode for: Windows 7 +Hope that helps.",0.2012947653214861,False,2,2249 2012-12-04 11:42:20.873,windows 8 incompatibility?,"I cannot get my code to run on my win8 laptop. I am working with a combination of: Stackless Python 2.7.2 @@ -23601,8 +23602,7 @@ sometimes i get the exception: TypeError: Error when calling the metaclass bases Especially the last two don't seem like a windows problem, but i don't see any other difference with my PC win7 install. Does anyone have any idea what is going on or how to fix this? Did i miss a step in the installation or is it some incompatibility maybe? Cheers, Lars -Does anyone have some input on this?","I had the same problem with Pyside 1.1.2 and Qt 4.8.4. The solution for me was to set the compatibility mode of the Python executable to Windows 7 via right click on the executable -> Properties -> Compatiblity -> Run this program in compatibility mode for: Windows 7 -Hope that helps.",0.2012947653214861,False,2,2249 +Does anyone have some input on this?","try using Hyper-V however Hyper-V is not installed by default in Windows 8. You need to go ""Turn Windows features on or off.""",0.0,False,2,2249 2012-12-04 20:56:20.807,changing python windows command line,"I try to save a python script as a shortcut that I want to run. It opens it but then closes right away. I know why it is doing this, it is opening my windows command line in python3.2 the script is in python 2.7 I need both version on my PC, my question is how to I change the cmd default. @@ -23700,7 +23700,7 @@ Questions: Does anyone have any opinions (opinions, on the internet???) about Elastic Search clients for Python? Specifically, I've found pyes and pyelasticsearch, via elasticsearch.org---how do these two stack up? How good or bad is my current approach of dynamically building the query and running it via self.raw_results = simplejson.load(urllib2.urlopen(self.query))? -Any advice is greatly appreciated!",We use pyes. And its pretty neat. You can there go with the thrift protocol which is faster then the rest service.,1.2,True,2,2262 +Any advice is greatly appreciated!",It sounds like you have an issue unrelated to the client. If you can pare down what's being sent to ES and represent it in a simple curl command it will make what's actually running slowly more apparent. I suspect we just need to tweak your query to make sure it's optimal for your context.,0.0,False,2,2262 2012-12-11 15:52:06.567,Elastic search client for Python: advice?,"I'm writing some scripts for our sales people to query an index with elastic search through python. (Eventually the script will update lead info in our Salesforce DB.) I have been using the urllib2 module, with simplejson, to pull results. The problem is that this seems to be a not-so-good approach, evidenced by scripts which are taking longer and longer to run. Questions: @@ -23708,7 +23708,7 @@ Questions: Does anyone have any opinions (opinions, on the internet???) about Elastic Search clients for Python? Specifically, I've found pyes and pyelasticsearch, via elasticsearch.org---how do these two stack up? How good or bad is my current approach of dynamically building the query and running it via self.raw_results = simplejson.load(urllib2.urlopen(self.query))? -Any advice is greatly appreciated!",It sounds like you have an issue unrelated to the client. If you can pare down what's being sent to ES and represent it in a simple curl command it will make what's actually running slowly more apparent. I suspect we just need to tweak your query to make sure it's optimal for your context.,0.0,False,2,2262 +Any advice is greatly appreciated!",We use pyes. And its pretty neat. You can there go with the thrift protocol which is faster then the rest service.,1.2,True,2,2262 2012-12-11 23:36:19.927,Change variable permanently,"I'm writing a small program that helps you keep track of what page you're on in your books. I'm not a fan of bookmarks, so I thought ""What if I could create a program that would take user input, and then display the number or string of text that they wrote, which in this case would be the page number they're on, and allow them to change it whenever they need to?"" It would only take a few lines of code, but the problem is, how can I get it to display the same number the next time I open the program? The variables would reset, would they not? Is there a way to permanently change a variable in this way?","You need to store it on disk. Unless you want to be really fancy, you can just use something like CSV, JSON, or YAML to make structured data easier. Also check out the python pickle module.",0.1352210990936997,False,1,2263 2012-12-12 02:59:37.603,PYTHON - Search a directory,"Is it possible for the user to input a specific directory on their computer, and for Python to write the all of the file/folder names to a text document? And if so, how? @@ -23767,7 +23767,18 @@ Background: I 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. This 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? NOTE: The python object will not be modified after creation. However i need to be able to recreate this object if needed. -EDIT: 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.","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.",0.2012947653214861,False,3,2272 +EDIT: 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.","Your problem description is kind of vague and can be read in several different ways. +One 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. +Speeding this up depends a LOT on the data structure in question. +If 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. +Alternately, you could try using the mmap module to achieve something similar without having to read anything and incur the copy overhead. +If 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. +Since 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. +Now, 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. +What 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. +And 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. +Again, 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. +Anyway, 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.",0.0,False,3,2272 2012-12-16 23:50:46.180,Storing large python object in RAM for later use,"Is it possible to store python (or C++) data in RAM for latter use and how can this be achieved? Background: I 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. @@ -23783,18 +23794,7 @@ Background: I 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. This 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? NOTE: The python object will not be modified after creation. However i need to be able to recreate this object if needed. -EDIT: 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.","Your problem description is kind of vague and can be read in several different ways. -One 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. -Speeding this up depends a LOT on the data structure in question. -If 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. -Alternately, you could try using the mmap module to achieve something similar without having to read anything and incur the copy overhead. -If 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. -Since 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. -Now, 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. -What 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. -And 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. -Again, 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. -Anyway, 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.",0.0,False,3,2272 +EDIT: 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.","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.",0.2012947653214861,False,3,2272 2012-12-17 08:23:01.957,Find out how many uncommitted items are in the session,"I developed an application which parses a lot of data, but if I commit the data after parsing all the data, it will consume too much memory. However, I cannot commit it each time, because it costs too much hard disk I/O. Therefore, my question is how can I know how many uncommitted items are in the session?","This is a classic case of buffering. Try a reasonably large chunk and reduce it if there's too much disk I/O (or you don't like it causing long pauses, etc) or increase it if your profile shows too much CPU time in I/O calls. To implement, use an array, each ""write"" you append an item to the array. Have a separate ""flush"" function that writes the whole thing. Each append you check, and if it has reached maximum size, write them all, and clear the array. At the end, call the flush function to write partially filled array.",0.0,False,1,2273 @@ -23908,8 +23908,9 @@ curses.beep() curses.endwin() -Why is this happenning, and how can I use nodelay() safely?","I see no difference when running your small test program with or without the sc.nodelay() line. -Neither case prints anything on the screen...",0.0,False,2,2282 +Why is this happenning, and how can I use nodelay() safely?","While I didn't use curses in python, I am currently working with it in C99, compiled using clang on Mac OS Catalina. It seems that nodelay()` does not work unless you slow down the program step at least to 1/10 of a second, eg. usleep(100000). I suppose that buffering/buffer reading is not fast enough, and getch() or wgetch(win*) simply doesn't manage to get the keyboard input, which somehow causes it to fail (no message whatsoever, even a ""Segmentation fault""). +For this reason, it's better to use halfdelay(1), which equals nodelay(win*, true) combined with usleep(100000). +I know this is a very old thread (2012), but the problem is still present in 2022, so I decided to reply.",0.1352210990936997,False,2,2282 2012-12-22 17:13:04.503,nodelay() causes python curses program to exit,"I've written a curses program in python. It runs fine. However, when I use nodelay(), the program exits straight away after starting in the terminal, with nothing shown at all (just a new prompt). EDIT This code will reproduce the bug: @@ -23969,9 +23970,14 @@ curses.beep() curses.endwin() -Why is this happenning, and how can I use nodelay() safely?","While I didn't use curses in python, I am currently working with it in C99, compiled using clang on Mac OS Catalina. It seems that nodelay()` does not work unless you slow down the program step at least to 1/10 of a second, eg. usleep(100000). I suppose that buffering/buffer reading is not fast enough, and getch() or wgetch(win*) simply doesn't manage to get the keyboard input, which somehow causes it to fail (no message whatsoever, even a ""Segmentation fault""). -For this reason, it's better to use halfdelay(1), which equals nodelay(win*, true) combined with usleep(100000). -I know this is a very old thread (2012), but the problem is still present in 2022, so I decided to reply.",0.1352210990936997,False,2,2282 +Why is this happenning, and how can I use nodelay() safely?","I see no difference when running your small test program with or without the sc.nodelay() line. +Neither case prints anything on the screen...",0.0,False,2,2282 +2012-12-23 02:46:16.277,Storing MySQL Passwords,"So, a friend and I are currently writing a panel (in python/django) for managing gameservers. +Each client also gets a MySQL server with their game server. What we are stuck on at the moment is how clients will find out their MySQL password and how it will be 'stored'. +The passwords would be generated randomly and presented to the user in the panel, however, we obviously don't want them to be stored in plaintext or reversible encryption, so we are unsure what to do if a a client forgets their password. +Resetting the password is something we would try to avoid as some clients may reset the password while the gameserver is still trying to use it, which could cause corruption and crashes. +What would be a secure (but without sacrificing ease of use for the clients) way to go about this?","Your question embodies a contradiction in terms. Either you don't want reversibility or you do. You will have to choose. +The usual technique is to hash the passwords and to provide a way for the user to reset his own password on sufficient alternative proof of identity. You should never display a password to anybody, for legal non-repudiability reasons. If you don't know what that means, ask a lawyer.",0.2012947653214861,False,2,2283 2012-12-23 02:46:16.277,Storing MySQL Passwords,"So, a friend and I are currently writing a panel (in python/django) for managing gameservers. Each client also gets a MySQL server with their game server. What we are stuck on at the moment is how clients will find out their MySQL password and how it will be 'stored'. The passwords would be generated randomly and presented to the user in the panel, however, we obviously don't want them to be stored in plaintext or reversible encryption, so we are unsure what to do if a a client forgets their password. @@ -23983,12 +23989,6 @@ store with a reversible encryption, e.g. RSA (http://stackoverflow.com/questions do not store it; clients can only reset password, not view it The second choice is a secure way, as RSA is also used for TLS encryption within the HTTPS protocol used by your bank of choice ;)",1.2,True,2,2283 -2012-12-23 02:46:16.277,Storing MySQL Passwords,"So, a friend and I are currently writing a panel (in python/django) for managing gameservers. -Each client also gets a MySQL server with their game server. What we are stuck on at the moment is how clients will find out their MySQL password and how it will be 'stored'. -The passwords would be generated randomly and presented to the user in the panel, however, we obviously don't want them to be stored in plaintext or reversible encryption, so we are unsure what to do if a a client forgets their password. -Resetting the password is something we would try to avoid as some clients may reset the password while the gameserver is still trying to use it, which could cause corruption and crashes. -What would be a secure (but without sacrificing ease of use for the clients) way to go about this?","Your question embodies a contradiction in terms. Either you don't want reversibility or you do. You will have to choose. -The usual technique is to hash the passwords and to provide a way for the user to reset his own password on sufficient alternative proof of identity. You should never display a password to anybody, for legal non-repudiability reasons. If you don't know what that means, ask a lawyer.",0.2012947653214861,False,2,2283 2012-12-23 17:49:22.527,synchronizing file names across servers,"I have a development & production server and some large video files. The large files need to be renamed. I don't know how to automatically change the file names in the production environment when I change their name in the development environment. I think using git is very inefficient for large files. On the development environment I copied only the first 5 seconds of the videos. I'll be using Django with South to synchronize the database and git to synchronize the code.","If the names on the development and production server are the same, then record the rename commands in a shell-script. You can run that on both the development and the production server...",0.0,False,1,2284 @@ -23996,11 +23996,11 @@ You can run that on both the development and the production server...",0.0,False I am a little confused for copying of lists. Is it using shallow copy or deep copy? Also, what is the syntax for sublists? is it g=a[:]?","The new list is a copy of references. g[0] and a[0] both reference the same object. Thus this is a shallow copy. You can see the copy module's deepcopy method for recursively copying containers, but this isn't a common operation in my experience. Stylistically, I prefer the more explicit g = list(a) to create a copy of a list, but creating a full slice has the same effect.",0.5457054096481145,False,1,2285 -2012-12-25 08:57:30.693,How dynamic arrays store different datatypes?,How does the language know how much space to reserve for each element? Or does it reserve the maximum space possible required for a datatype? (Talk about large floating point numbers). In that case isn't it a bit inefficient?,Python reserves only enough space in a list for a reference to the various objects; it is up to the objects' allocators to reserve enough space for them when they are instantiated.,0.1016881243684853,False,3,2286 2012-12-25 08:57:30.693,How dynamic arrays store different datatypes?,How does the language know how much space to reserve for each element? Or does it reserve the maximum space possible required for a datatype? (Talk about large floating point numbers). In that case isn't it a bit inefficient?,"Arrays in Python are done via the array module. They do not store different datatypes, they store arrays of specific numerical values. I think you mean the list type. It doesn't contain values, it just contains references to objects, which can be any type of object at all. None of these reserves any space for any elements at all (well, they do, but that's internal implementation details). It adds the space for the elements needed when it they are added to the list/array. The list type is indeed less efficient than the array type, which is why the array type exists.",0.1016881243684853,False,3,2286 +2012-12-25 08:57:30.693,How dynamic arrays store different datatypes?,How does the language know how much space to reserve for each element? Or does it reserve the maximum space possible required for a datatype? (Talk about large floating point numbers). In that case isn't it a bit inefficient?,Python reserves only enough space in a list for a reference to the various objects; it is up to the objects' allocators to reserve enough space for them when they are instantiated.,0.1016881243684853,False,3,2286 2012-12-25 08:57:30.693,How dynamic arrays store different datatypes?,How does the language know how much space to reserve for each element? Or does it reserve the maximum space possible required for a datatype? (Talk about large floating point numbers). In that case isn't it a bit inefficient?,"In C language terms, a Python list is like a PyObject *mylist[100], except it's dynamically allocated. It's a contiguous chunk of memory storing references to Python objects.",0.0,False,3,2286 2012-12-25 17:04:55.777,Python data structure sort list alphabetically,"I am a bit confused regarding data structure in python; (),[], and {}. I am trying to sort a simple list, probably since I cannot identify the type of data I am failing to sort it. My list is simple: ['Stem', 'constitute', 'Sedge', 'Eflux', 'Whim', 'Intrigue'] @@ -24016,11 +24016,11 @@ If yes, how do I separate multiple paths given by this option.","you can specify In short, I want to implement ""get file by filename"" I can't seem to find any built-in functionality for this.","Every blob you upload, creates a new version of that blob (with that filename) in the blobstore. Ofcourse you can delete the old version(s) of the blob, if you uploaded a new version. But to make sure you have the latest version of a blob (of a filename) you have to store the filename in the datastore and make a reference to the latest version. This reference holds the blob_key.",0.2012947653214861,False,1,2290 2012-12-27 03:31:41.547,Is declaring [almost] everything with self. alright (Python)?,"I have a habit to declare new variables with self. in front to make it available to all methods. This is because sometimes I thought I don't need the variable in other methods. But halfway through I realized that I need it to be accessible in other methods. Then I have to add self. in front of all that variable. -So my question is, besides needing to type 5 characters more each time I use a variable, are there any other disadvantages? Or, how do you overcome my problem?","Set a property on self only when the value is part of the overall object state. If it's only part of the method state, then it should be method-local, and should not be a property of self.",1.2,True,2,2291 -2012-12-27 03:31:41.547,Is declaring [almost] everything with self. alright (Python)?,"I have a habit to declare new variables with self. in front to make it available to all methods. This is because sometimes I thought I don't need the variable in other methods. But halfway through I realized that I need it to be accessible in other methods. Then I have to add self. in front of all that variable. So my question is, besides needing to type 5 characters more each time I use a variable, are there any other disadvantages? Or, how do you overcome my problem?","It's not really allright. self makes your variable available to global object-scope. That way you need to make sure that names of your variables are unique throughout complete object, rather than in localized scopes, amongst other side-effects that might or might not be unwanted. In your particular case it might be not an issue, but it's a very bad practice in general. Know your scoping and use it wisely. :)",0.5457054096481145,False,2,2291 +2012-12-27 03:31:41.547,Is declaring [almost] everything with self. alright (Python)?,"I have a habit to declare new variables with self. in front to make it available to all methods. This is because sometimes I thought I don't need the variable in other methods. But halfway through I realized that I need it to be accessible in other methods. Then I have to add self. in front of all that variable. +So my question is, besides needing to type 5 characters more each time I use a variable, are there any other disadvantages? Or, how do you overcome my problem?","Set a property on self only when the value is part of the overall object state. If it's only part of the method state, then it should be method-local, and should not be a property of self.",1.2,True,2,2291 2012-12-27 07:57:38.660,how to disable pypy assert statement?,"$ ./pypy -O Python 2.7.2 (a3e1b12d1d01, Dec 04 2012, 13:33:26) [PyPy 1.9.1-dev0 with GCC 4.6.3] on linux2 @@ -24088,10 +24088,10 @@ sending keypresses to it to mimic keyboard navigation. These may work if your DataGridView has a small amount of data in it, but once the DataGridView starts needing scrollbars you're out of luck. Furthermore, clicking at offsets is sensitive to the sizes of the rows and columns, and if the columns can be resized then this approach will never be reliable.",0.5457054096481145,False,1,2296 2013-01-01 20:23:12.477,How to execute a python command line utility from the terminal in any directory,"I have just written a python script to do some batch file operations. I was wondering how i could keep it in some common path like rest of the command line utilities like cd, ls, grep etc. What i expect is something like this to be done from any directory - -$ script.py arg1 arg2","Just put the script directory into the PATH environment variable, or alternatively put the script in a location that is already in the PATH. On Unix systems, you usually use /home//bin for your own scripts and add that to the PATH.",1.2,True,2,2297 +$ script.py arg1 arg2","Add the directory it is stored in to your PATH variable? From your prompt, I'm guessing you're using an sh-like shell and from your tags, I'm further assuming OS X. Go into your .bashrc and make the necessary changes.",0.0,False,2,2297 2013-01-01 20:23:12.477,How to execute a python command line utility from the terminal in any directory,"I have just written a python script to do some batch file operations. I was wondering how i could keep it in some common path like rest of the command line utilities like cd, ls, grep etc. What i expect is something like this to be done from any directory - -$ script.py arg1 arg2","Add the directory it is stored in to your PATH variable? From your prompt, I'm guessing you're using an sh-like shell and from your tags, I'm further assuming OS X. Go into your .bashrc and make the necessary changes.",0.0,False,2,2297 +$ script.py arg1 arg2","Just put the script directory into the PATH environment variable, or alternatively put the script in a location that is already in the PATH. On Unix systems, you usually use /home//bin for your own scripts and add that to the PATH.",1.2,True,2,2297 2013-01-02 10:02:56.867,Python-controllable command line audio player for Linux,"I want to build use my Raspberry Pi as a media station. It should be able to play songs via commands over the network. These commands should be handled by a server written in Python. Therefor, I need a way to control audio playback via Python. I decided to use a command line music player for linux since those should offer the most flexibility for audio file formats. Also, Python libraries like PyAudio and PyMedia don't seem to work for me. I don't really have great expectations about the music player. It must be possible to play and pause sound files in as much codecs as possible and turn the volume up and down. Also it has to be a headless player since I am not running any desktop environment. There are a lot of players like that out there, it seems. mpg123 for example, works well for all I need. @@ -24104,16 +24104,16 @@ It seems like there is already a python client library available for mpd - pytho How would I create the model?","You can use OpenCv library for java , this library contain Template Matching Model already implemented but the better thing for image recognition is using learning machine or neural network",0.0,False,3,2299 2013-01-02 22:09:55.833,Creating an Image model,"I am developing Image recognition software that will detect letters. I was wondering how I could create a model of a letter (""J"" for example) so that when I take a picture with the letter ""J"" on it, the software will compare the image to the model and detect the letter ""J"". -How would I create the model?","It seems you want to do OCR (Optical Character Recognition). -If this is only part of a larger project, try OpenCV. Even if you are making a commercial product, it has a permissive BSD license. -If you have set out to make a library of your own, read some of the papers available through any good search engine. There are many tutorials for machine learning and neural nets, which could produce the image models you want.",0.2655860252697744,False,3,2299 -2013-01-02 22:09:55.833,Creating an Image model,"I am developing Image recognition software that will detect letters. I was wondering how I could create a model of a letter (""J"" for example) so that when I take a picture with the letter ""J"" on it, the software will compare the image to the model and detect the letter ""J"". How would I create the model?","If I were going to do this, I would use normalized floats. The letter A would be: [(0.0,0.0),(0.5,1.0),(1.0,0.0),(0.1,0.5)(0.9,0.5)] Update (further explanation) So my thought is that you should be able to uniquely identify a letter with an array of normalized points. Points would be at important features of the letter such as start, end, and midpoints of a line. Curves would be sliced up into multiple smaller line segments, which would also be represented by points. To use this model, the source image would be analyzed. You would then analyze the image for text. You could use edge detection and other methods to find text. You'd also have to analyze for any transforms on the text. After you figure out the transform of the text, you would split the text into characters, then analyze the character for the points of important features. Then you would write an algorithm to normalize the points, and determine which model represents the found points most accurately.",0.0,False,3,2299 +2013-01-02 22:09:55.833,Creating an Image model,"I am developing Image recognition software that will detect letters. I was wondering how I could create a model of a letter (""J"" for example) so that when I take a picture with the letter ""J"" on it, the software will compare the image to the model and detect the letter ""J"". +How would I create the model?","It seems you want to do OCR (Optical Character Recognition). +If this is only part of a larger project, try OpenCV. Even if you are making a commercial product, it has a permissive BSD license. +If you have set out to make a library of your own, read some of the papers available through any good search engine. There are many tutorials for machine learning and neural nets, which could produce the image models you want.",0.2655860252697744,False,3,2299 2013-01-03 12:54:47.767,Cross-platform deployment and easy installation,"EDIT One option I contemplated but don't know enough about is to e.g. for windows write a batch script to: @@ -24137,7 +24137,7 @@ Background I am writing technical and scientific apps under Linux but will need some of them to be deployable on Windows/MacOs machines too. In the past I have used Python a lot, but I am finding that for non-technical users who aren't happy installing python packages, creating a simple executable (by using e.g. py2exe) is difficult as I can't get the windows version of Python to install using wine. While java would seem a good choice, if possible I wanted to avoid having to port my existing code from Python, especially as Python also allows writing portable code. -I realize I'm trying to cover a lot of bases here, so any suggestions regarding the most appropriate solutions (even if not perfect) will be appreciated.","py2exe works pretty well, I guess you just have to setup a Windows box (or VM) to be able to build packages with it.",0.2655860252697744,False,2,2300 +I realize I'm trying to cover a lot of bases here, so any suggestions regarding the most appropriate solutions (even if not perfect) will be appreciated.","I would recommend using py2exe for the windows side, and then BuildApplet for the mac side. This will allow you to make a simple app you double click for your less savvy users.",0.0,False,2,2300 2013-01-03 12:54:47.767,Cross-platform deployment and easy installation,"EDIT One option I contemplated but don't know enough about is to e.g. for windows write a batch script to: @@ -24161,21 +24161,21 @@ Background I am writing technical and scientific apps under Linux but will need some of them to be deployable on Windows/MacOs machines too. In the past I have used Python a lot, but I am finding that for non-technical users who aren't happy installing python packages, creating a simple executable (by using e.g. py2exe) is difficult as I can't get the windows version of Python to install using wine. While java would seem a good choice, if possible I wanted to avoid having to port my existing code from Python, especially as Python also allows writing portable code. -I realize I'm trying to cover a lot of bases here, so any suggestions regarding the most appropriate solutions (even if not perfect) will be appreciated.","I would recommend using py2exe for the windows side, and then BuildApplet for the mac side. This will allow you to make a simple app you double click for your less savvy users.",0.0,False,2,2300 +I realize I'm trying to cover a lot of bases here, so any suggestions regarding the most appropriate solutions (even if not perfect) will be appreciated.","py2exe works pretty well, I guess you just have to setup a Windows box (or VM) to be able to build packages with it.",0.2655860252697744,False,2,2300 +2013-01-04 06:55:53.620,can one python script run both with python 2.x and python 3.x,"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? +my question is how the script check.py find the Interpreter no matter the Interpreter is python2.x and python3.x","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.",0.0,False,2,2301 2013-01-04 06:55:53.620,can one python script run both with python 2.x and python 3.x,"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? my question is how the script check.py find the Interpreter no matter the Interpreter is python2.x and python3.x","In the general case, no; many Python 2 scripts will not run on Python 3, and vice versa. They are two different languages. Having 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""). However, 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.",0.0,False,2,2301 -2013-01-04 06:55:53.620,can one python script run both with python 2.x and python 3.x,"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? -my question is how the script check.py find the Interpreter no matter the Interpreter is python2.x and python3.x","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.",0.0,False,2,2301 2013-01-04 08:57:55.073,How can I see emails sent with Python's smtplib in my Outlook Sent Items folder?,"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?","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",0.6730655149877884,False,1,2302 2013-01-04 17:45:26.820,PyRun_InteractiveLoop globals/locals,"I am trying to set local/globals variables in PyRun_InteractiveLoop call. Cant figure out how to do it, since, unlike exec counterparts, loop doesn't accept global/local args. What am I missing?","If what you want is a C API version of exec, maybe try PyRun_File and its ilk? Not sure exactly what you're trying to accomplish though.",0.0,False,1,2303 -2013-01-05 23:11:16.263,Get publicly accessible contents of S3 bucket without AWS credentials,"Given a bucket with publicly accessible contents, how can I get a listing of all those publicly accessible contents? I know boto can do this, but boto requires AWS credentials. Also, boto doesn't work in Python3, which is what I'm working with.","If the bucket's permissions allow Everyone to list it, you can just do a simple HTTP GET request to http://s3.amazonaws.com/bucketname with no credentials. The response will be XML with everything in it, whether those objects are accessible by Everyone or not. I don't know if boto has an option to make this request without credentials. If not, you'll have to use lower-level HTTP and XML libraries. -If the bucket itself does not allow Everyone to list it, there is no way to get a list of its contents, even if some of the objects in it are publicly accessible.",0.6730655149877884,False,2,2304 2013-01-05 23:11:16.263,Get publicly accessible contents of S3 bucket without AWS credentials,"Given a bucket with publicly accessible contents, how can I get a listing of all those publicly accessible contents? I know boto can do this, but boto requires AWS credentials. Also, boto doesn't work in Python3, which is what I'm working with.","Using AWS CLI, aws s3 ls s3://*bucketname* --region *bucket-region* --no-sign-request",0.0,False,2,2304 +2013-01-05 23:11:16.263,Get publicly accessible contents of S3 bucket without AWS credentials,"Given a bucket with publicly accessible contents, how can I get a listing of all those publicly accessible contents? I know boto can do this, but boto requires AWS credentials. Also, boto doesn't work in Python3, which is what I'm working with.","If the bucket's permissions allow Everyone to list it, you can just do a simple HTTP GET request to http://s3.amazonaws.com/bucketname with no credentials. The response will be XML with everything in it, whether those objects are accessible by Everyone or not. I don't know if boto has an option to make this request without credentials. If not, you'll have to use lower-level HTTP and XML libraries. +If the bucket itself does not allow Everyone to list it, there is no way to get a list of its contents, even if some of the objects in it are publicly accessible.",0.6730655149877884,False,2,2304 2013-01-07 06:34:29.080,python project setting for production and developement,"I'm building project with Django, I can make two setting files for Django: production_setting.py and development_setting.py, however, I need some configure file for my project and I'm using ConfigParser to parse that files. e.g. [Section] @@ -24202,17 +24202,6 @@ If anyone has an idea of how to do and possible some example code it would be mu ColourDialog, ColourSelect, PyColourChooser or CubeColourDialog They all let you choose colors in different ways and they have a slider to help adjust the colours too. You can see each of them in action in the wxPython demo (downloadable from the wxPython web page)",1.2,True,1,2309 -2013-01-10 09:08:22.983,Mixing categorial and continuous data in Naive Bayes classifier using scikit-learn,"I'm using scikit-learn in Python to develop a classification algorithm to predict the gender of certain customers. Amongst others, I want to use the Naive Bayes classifier but my problem is that I have a mix of categorical data (ex: ""Registered online"", ""Accepts email notifications"" etc) and continuous data (ex: ""Age"", ""Length of membership"" etc). I haven't used scikit much before but I suppose that that Gaussian Naive Bayes is suitable for continuous data and that Bernoulli Naive Bayes can be used for categorical data. However, since I want to have both categorical and continuous data in my model, I don't really know how to handle this. Any ideas would be much appreciated!","You have at least two options: - -Transform all your data into a categorical representation by computing percentiles for each continuous variables and then binning the continuous variables using the percentiles as bin boundaries. For instance for the height of a person create the following bins: ""very small"", ""small"", ""regular"", ""big"", ""very big"" ensuring that each bin contains approximately 20% of the population of your training set. We don't have any utility to perform this automatically in scikit-learn but it should not be too complicated to do it yourself. Then fit a unique multinomial NB on those categorical representation of your data. -Independently fit a gaussian NB model on the continuous part of the data and a multinomial NB model on the categorical part. Then transform all the dataset by taking the class assignment probabilities (with predict_proba method) as new features: np.hstack((multinomial_probas, gaussian_probas)) and then refit a new model (e.g. a new gaussian NB) on the new features.",1.2,True,3,2310 -2013-01-10 09:08:22.983,Mixing categorial and continuous data in Naive Bayes classifier using scikit-learn,"I'm using scikit-learn in Python to develop a classification algorithm to predict the gender of certain customers. Amongst others, I want to use the Naive Bayes classifier but my problem is that I have a mix of categorical data (ex: ""Registered online"", ""Accepts email notifications"" etc) and continuous data (ex: ""Age"", ""Length of membership"" etc). I haven't used scikit much before but I suppose that that Gaussian Naive Bayes is suitable for continuous data and that Bernoulli Naive Bayes can be used for categorical data. However, since I want to have both categorical and continuous data in my model, I don't really know how to handle this. Any ideas would be much appreciated!","The simple answer: multiply result!! it's the same. -Naive Bayes based on applying Bayes’ theorem with the “naive” assumption of independence between every pair of features - meaning you calculate the Bayes probability dependent on a specific feature without holding the others - which means that the algorithm multiply each probability from one feature with the probability from the second feature (and we totally ignore the denominator - since it is just a normalizer). -so the right answer is: - -calculate the probability from the categorical variables. -calculate the probability from the continuous variables. -multiply 1. and 2.",0.9866142981514304,False,3,2310 2013-01-10 09:08:22.983,Mixing categorial and continuous data in Naive Bayes classifier using scikit-learn,"I'm using scikit-learn in Python to develop a classification algorithm to predict the gender of certain customers. Amongst others, I want to use the Naive Bayes classifier but my problem is that I have a mix of categorical data (ex: ""Registered online"", ""Accepts email notifications"" etc) and continuous data (ex: ""Age"", ""Length of membership"" etc). I haven't used scikit much before but I suppose that that Gaussian Naive Bayes is suitable for continuous data and that Bernoulli Naive Bayes can be used for categorical data. However, since I want to have both categorical and continuous data in my model, I don't really know how to handle this. Any ideas would be much appreciated!","You will need the following steps: Calculate the probability from the categorical variables (using predict_proba method from BernoulliNB) @@ -24222,6 +24211,17 @@ Divide by the prior (either from BernoulliNB or from GaussianNB since they are t Divide 4. by the sum (over the classes) of 4. This is the normalisation step. It should be easy enough to see how you can add your own prior instead of using those learned from the data.",0.0,False,3,2310 +2013-01-10 09:08:22.983,Mixing categorial and continuous data in Naive Bayes classifier using scikit-learn,"I'm using scikit-learn in Python to develop a classification algorithm to predict the gender of certain customers. Amongst others, I want to use the Naive Bayes classifier but my problem is that I have a mix of categorical data (ex: ""Registered online"", ""Accepts email notifications"" etc) and continuous data (ex: ""Age"", ""Length of membership"" etc). I haven't used scikit much before but I suppose that that Gaussian Naive Bayes is suitable for continuous data and that Bernoulli Naive Bayes can be used for categorical data. However, since I want to have both categorical and continuous data in my model, I don't really know how to handle this. Any ideas would be much appreciated!","The simple answer: multiply result!! it's the same. +Naive Bayes based on applying Bayes’ theorem with the “naive” assumption of independence between every pair of features - meaning you calculate the Bayes probability dependent on a specific feature without holding the others - which means that the algorithm multiply each probability from one feature with the probability from the second feature (and we totally ignore the denominator - since it is just a normalizer). +so the right answer is: + +calculate the probability from the categorical variables. +calculate the probability from the continuous variables. +multiply 1. and 2.",0.9866142981514304,False,3,2310 +2013-01-10 09:08:22.983,Mixing categorial and continuous data in Naive Bayes classifier using scikit-learn,"I'm using scikit-learn in Python to develop a classification algorithm to predict the gender of certain customers. Amongst others, I want to use the Naive Bayes classifier but my problem is that I have a mix of categorical data (ex: ""Registered online"", ""Accepts email notifications"" etc) and continuous data (ex: ""Age"", ""Length of membership"" etc). I haven't used scikit much before but I suppose that that Gaussian Naive Bayes is suitable for continuous data and that Bernoulli Naive Bayes can be used for categorical data. However, since I want to have both categorical and continuous data in my model, I don't really know how to handle this. Any ideas would be much appreciated!","You have at least two options: + +Transform all your data into a categorical representation by computing percentiles for each continuous variables and then binning the continuous variables using the percentiles as bin boundaries. For instance for the height of a person create the following bins: ""very small"", ""small"", ""regular"", ""big"", ""very big"" ensuring that each bin contains approximately 20% of the population of your training set. We don't have any utility to perform this automatically in scikit-learn but it should not be too complicated to do it yourself. Then fit a unique multinomial NB on those categorical representation of your data. +Independently fit a gaussian NB model on the continuous part of the data and a multinomial NB model on the categorical part. Then transform all the dataset by taking the class assignment probabilities (with predict_proba method) as new features: np.hstack((multinomial_probas, gaussian_probas)) and then refit a new model (e.g. a new gaussian NB) on the new features.",1.2,True,3,2310 2013-01-10 10:08:08.487,Twisted: ReconnectingClientFactory connection to different servers,"I have a twisted ReconnectingClientFactory and i can successfully connect to given ip and port couple with this factory. And it works well. reactor.connectTCP(ip, port, myHandsomeReconnectingClientFactory) @@ -24308,6 +24308,19 @@ Since the view for uploading the images is different from the view for displayin You could add an upload_id, which is set automatically after uploading, send it to the next view, and query for that in the db.",0.0,False,1,2319 2013-01-17 02:11:28.927,Pytest and Python 3,"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. The 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 +/usr/bin/python3: No module named pytest","Install it with pip3: +pip3 install -U pytest",0.3275988531455109,False,3,2320 +2013-01-17 02:11:28.927,Pytest and Python 3,"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. +The 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 +/usr/bin/python3: No module named pytest","I found a workaround: + +Installed python3-pip using aptitude, which created /usr/bin/pip-3.2. +Next pip-3.2 install pytest which re-installed pytest, but under a python3.2 path. +Then I was able to use python3 -m pytest somedir/sometest.py. + +Not as convenient as running py.test directly, but workable.",1.2,True,3,2320 +2013-01-17 02:11:28.927,Pytest and Python 3,"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. +The 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 /usr/bin/python3: No module named pytest","python3 doesn't have the module py.test installed. If you can, install the python3-pytest package. If you can't do that try this: @@ -24325,19 +24338,6 @@ Install py.test pip install py.test Now using this virtualenv try to run your tests",0.9997532108480276,False,3,2320 -2013-01-17 02:11:28.927,Pytest and Python 3,"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. -The 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 -/usr/bin/python3: No module named pytest","I found a workaround: - -Installed python3-pip using aptitude, which created /usr/bin/pip-3.2. -Next pip-3.2 install pytest which re-installed pytest, but under a python3.2 path. -Then I was able to use python3 -m pytest somedir/sometest.py. - -Not as convenient as running py.test directly, but workable.",1.2,True,3,2320 -2013-01-17 02:11:28.927,Pytest and Python 3,"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. -The 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 -/usr/bin/python3: No module named pytest","Install it with pip3: -pip3 install -U pytest",0.3275988531455109,False,3,2320 2013-01-17 09:02:53.413,Compile Python 2.7.3 on Linux for Embedding into a C++ app,"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. My 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. So my questions are: @@ -24533,8 +24533,9 @@ This method is easy but it will cause a sync if ANY file in the drive changes. 3) Start at the specific folder, and move down the folder tree looking for changes. This method will be fast if there are only a few directories in the specific tree, but it will still lead to numerous API requests. Are there any better ways to find whether a specific folder and its contents have changed? -Are there any optimisations I could apply to method 1,2 or 3.","As you have correctly stated, you will need to keep (or work out) the file hierarchy for a changed file to know whether a file has changed within a folder tree. -There is no way of knowing directly from the changes feed whether a deeply nested file within a folder has been changed. Sorry.",1.2,True,2,2347 +Are there any optimisations I could apply to method 1,2 or 3.","There are a couple of tricks that might help. +Firstly, if your app is using drive.file scope, then it will only see its own files. Depending on your specific situation, this may equate to your folder hierarchy. +Secondly, files can have multiple parents. So when creating a file in folder-top/folder-1/folder-1a/folder-1ai. you could declare both folder-1ai and folder-top as parents. Then you simply need to check for folder-top.",0.0,False,2,2347 2013-01-24 22:06:32.997,How can I find if the contents in a Google Drive folder have changed,"I am currently working on an app that syncs one specific folder in a users Google Drive. I need to find when any of the files/folders in that specific folder have changed. The actual syncing process is easy, but I don't want to do a full sync every few seconds. I am condisering one of these methods: 1) Moniter the changes feed and look for any file changes @@ -24543,9 +24544,8 @@ This method is easy but it will cause a sync if ANY file in the drive changes. 3) Start at the specific folder, and move down the folder tree looking for changes. This method will be fast if there are only a few directories in the specific tree, but it will still lead to numerous API requests. Are there any better ways to find whether a specific folder and its contents have changed? -Are there any optimisations I could apply to method 1,2 or 3.","There are a couple of tricks that might help. -Firstly, if your app is using drive.file scope, then it will only see its own files. Depending on your specific situation, this may equate to your folder hierarchy. -Secondly, files can have multiple parents. So when creating a file in folder-top/folder-1/folder-1a/folder-1ai. you could declare both folder-1ai and folder-top as parents. Then you simply need to check for folder-top.",0.0,False,2,2347 +Are there any optimisations I could apply to method 1,2 or 3.","As you have correctly stated, you will need to keep (or work out) the file hierarchy for a changed file to know whether a file has changed within a folder tree. +There is no way of knowing directly from the changes feed whether a deeply nested file within a folder has been changed. Sorry.",1.2,True,2,2347 2013-01-24 22:30:48.483,how to access and edit python library config file,"I am trying to set my AWS id and secret in boto.cfg for the AWS python library ""boto"". I've installed it on my mac with pip install and I don't see it in /etc How do I locate and access it or do I have to create it? And if so how?",The installer does not create a config file for you. You have to manually create one. You can create a system-wide config file in /etc/boto.cfg or a personal config file in ~/.boto. Or you can create one somewhere else and point the BOTO_CONFIG environment variable at it.,1.2,True,1,2348 2013-01-25 06:45:51.467,Django : Call a method only once when the django starts up,"I want to initialize some variables (from the database) when Django starts. @@ -24744,13 +24744,12 @@ Number of 'repeated' is more than 100 No.2 increases the size of entity, but we can save the datastore operations. (We need to use projection query to reduce CPU time for the deserialization though). Therefore, I use this way as much as I can. -I really appreciate your opinion.","One thing that most GAE users will come to realize (sooner or later) is that the datastore does not encourage design according to the formal normalization principles that would be considered a good idea in relational databases. Instead it often seems to encourage design that is unintuitive and anathema to established norms. Although relational database design principles have their place, they just don't work here. -I think the basis for the datastore design instead falls into two questions: - -How am I going to read this data and how do I read it with the minimum number of read operations? -Is storing it that way going to lead to an explosion in the number of write and indexing operations? - -If you answer these two questions with as much foresight and actual tests as you can, I think you're doing pretty well. You could formalize other rules and specific cases, but these questions will work most of the time.",0.9950547536867304,False,2,2372 +I really appreciate your opinion.","A key thing you are missing: How are you reading the data? +If you are displaying all the tasks for a given person on a request, 2 makes sense: you can query the person and show all his tasks. +However, if you need to query say a list of all tasks say due at a certain time, querying for repeated structured properties is terrible. You will want individual entities for your Tasks. +There's a fourth option, which is to use a KeyProperty in your Task that points to your Person. When you need a list of Tasks for a person you can issue a query. +If you need to search for individual Tasks, then you probably want to go with #4. You can use it in combination with #3 as well. +Also, the number of repeated properties has nothing to do with 100. It has everything to do with the size of your Person and Task entities, and how much will fit into 1MB. This is potentially dangerous, because if your Task entity can potentially be large, you might run out of space in your Person entity faster than you expect.",0.9981778976111988,False,2,2372 2013-02-06 21:22:24.413,Effective implementation of one-to-many relationship with Python NDB,"I would like to hear your opinion about the effective implementation of one-to-many relationship with Python NDB. (e.g. Person(one)-to-Tasks(many)) In my understanding, there are three ways to implement it. @@ -24781,12 +24780,13 @@ Number of 'repeated' is more than 100 No.2 increases the size of entity, but we can save the datastore operations. (We need to use projection query to reduce CPU time for the deserialization though). Therefore, I use this way as much as I can. -I really appreciate your opinion.","A key thing you are missing: How are you reading the data? -If you are displaying all the tasks for a given person on a request, 2 makes sense: you can query the person and show all his tasks. -However, if you need to query say a list of all tasks say due at a certain time, querying for repeated structured properties is terrible. You will want individual entities for your Tasks. -There's a fourth option, which is to use a KeyProperty in your Task that points to your Person. When you need a list of Tasks for a person you can issue a query. -If you need to search for individual Tasks, then you probably want to go with #4. You can use it in combination with #3 as well. -Also, the number of repeated properties has nothing to do with 100. It has everything to do with the size of your Person and Task entities, and how much will fit into 1MB. This is potentially dangerous, because if your Task entity can potentially be large, you might run out of space in your Person entity faster than you expect.",0.9981778976111988,False,2,2372 +I really appreciate your opinion.","One thing that most GAE users will come to realize (sooner or later) is that the datastore does not encourage design according to the formal normalization principles that would be considered a good idea in relational databases. Instead it often seems to encourage design that is unintuitive and anathema to established norms. Although relational database design principles have their place, they just don't work here. +I think the basis for the datastore design instead falls into two questions: + +How am I going to read this data and how do I read it with the minimum number of read operations? +Is storing it that way going to lead to an explosion in the number of write and indexing operations? + +If you answer these two questions with as much foresight and actual tests as you can, I think you're doing pretty well. You could formalize other rules and specific cases, but these questions will work most of the time.",0.9950547536867304,False,2,2372 2013-02-07 03:13:31.030,Interpolation Function,"This is probably a very easy question, but all the sources I have found on interpolation in Matlab are trying to correlate two values, all I wanted to benefit from is if I have data which is collected over an 8 hour period, but the time between data points is varying, how do I adjust it such that the time periods are equal and the data remains consistent? Or to rephrase from the approach I have been trying: I have GPS lat,lon and Unix time for these points; what I want to do is take the lat and lon at time 1 and time 3 and for the case where I don't know time 2, simply fill it with data from time 1 - is there a functional way to do this? (I know in something like Python Pandas you can use fill) but I'm unsure of how to do this in Matlab.","What you can do is use interp1 function. This function will fit in deifferent way the numbers for a new X series. For example if you have @@ -24805,42 +24805,42 @@ keys, etc.. values into settings files has problem: Secrets often should be just that: secret! Keeping them in version control means that everyone with repository access has access to them. -My question is how to keep all keys as secret?","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. -local_settings.py can be checked in with development configuration just for convenience, so that each developer need to change it. -Does that solve your problem?",0.283556384140347,False,4,2375 +My question is how to keep all keys as secret?","Here's one way to do it that is compatible with deployment on Heroku: + +Create a gitignored file named .env containing: +export DJANGO_SECRET_KEY = 'replace-this-with-the-secret-key' +Then edit settings.py to remove the actual SECRET_KEY and add this instead: +SECRET_KEY = os.environ['DJANGO_SECRET_KEY'] +Then when you want to run the development server locally, use: +source .env +python manage.py runserver +When you finally deploy to Heroku, go to your app Settings tab and add DJANGO_SECRET_KEY to the Config Vars.",0.1160922760327606,False,4,2375 2013-02-09 07:49:04.497,Keep Secret Keys Out,"One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS keys, etc.. values into settings files has problem: Secrets often should be just that: secret! Keeping them in version control means that everyone with repository access has access to them. -My question is how to keep all keys as secret?","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). -There'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. -That's just an outline, you'll have to build it yourself. -This way the secret data remains solely in the process memory space, and not in a file or in environment variables.",0.336246259354525,False,4,2375 +My question is how to keep all keys as secret?","You may need to use os.environ.get(""SOME_SECRET_KEY"")",0.0,False,4,2375 2013-02-09 07:49:04.497,Keep Secret Keys Out,"One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS keys, etc.. values into settings files has problem: Secrets often should be just that: secret! Keeping them in version control means that everyone with repository access has access to them. -My question is how to keep all keys as secret?","You may need to use os.environ.get(""SOME_SECRET_KEY"")",0.0,False,4,2375 +My question is how to keep all keys as secret?","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). +There'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. +That's just an outline, you'll have to build it yourself. +This way the secret data remains solely in the process memory space, and not in a file or in environment variables.",0.336246259354525,False,4,2375 2013-02-09 07:49:04.497,Keep Secret Keys Out,"One of the causes of the local_settings.py anti-pattern is that putting SECRET_KEY, AWS keys, etc.. values into settings files has problem: Secrets often should be just that: secret! Keeping them in version control means that everyone with repository access has access to them. -My question is how to keep all keys as secret?","Here's one way to do it that is compatible with deployment on Heroku: - -Create a gitignored file named .env containing: -export DJANGO_SECRET_KEY = 'replace-this-with-the-secret-key' -Then edit settings.py to remove the actual SECRET_KEY and add this instead: -SECRET_KEY = os.environ['DJANGO_SECRET_KEY'] -Then when you want to run the development server locally, use: -source .env -python manage.py runserver -When you finally deploy to Heroku, go to your app Settings tab and add DJANGO_SECRET_KEY to the Config Vars.",0.1160922760327606,False,4,2375 +My question is how to keep all keys as secret?","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. +local_settings.py can be checked in with development configuration just for convenience, so that each developer need to change it. +Does that solve your problem?",0.283556384140347,False,4,2375 2013-02-11 00:27:19.747,How to match arbitrary data using hash codes?,"I have some points in space where each point has an id. I also have a subset of these points in another group that have different id values. How can I create a new type of id for both groups of points so that the points that have the same coordinates end up using the same id values? I assume I need to generate hash codes using their coordinates which should give me the same id value for points that have the same coordinates, right? @@ -24855,15 +24855,15 @@ In C\C++ we use semaphore\mutex\rwlocks etc? Do we have anything similar in pyth We 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. Please let me know. Thanks! -Santhosh","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.",0.0,False,2,2378 +Santhosh","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. +The 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.",0.0,False,2,2378 2013-02-11 17:17:45.260,multiple users doing form submission with python CGI,"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. Now, when multiple users submit at the same time, how do we go about it? In 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. We 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. Please let me know. Thanks! -Santhosh","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. -The 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.",0.0,False,2,2378 +Santhosh","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.",0.0,False,2,2378 2013-02-12 02:33:49.900,"Is possible to create a shell like bash in python, ie: Bash replacement?","I wonder if is possible to create a bash replacement but in python. I have done REPLs before, know about subprocess and that kind of stuff, but wonder how use my python-like-bash replacement in the OSX terminal as if were a native shell environment (with limitations). Or simply run ipython as is... P.D. The majority of the google answer are related to create shell scripts. I'm interested in create a shell..","Yes, of course. You can simply make an executable Python script, call it /usr/bin/pysh, add this filename to /etc/shells and then set it as your user's default login shell with chsh.",0.0,False,1,2379 @@ -25034,8 +25034,9 @@ Specify it in the docstring above the class (might be overlooked) Use a leading underscore in the class name (not sure if this is universally understood) Create a def __init__(self): method on the abstract class that raises an error (not sure if this negatively impacts inheritance, like if you want to call a base constructor) -Is one of these a good option or is there a better one? I just want to make sure that other developers know that it is abstract and so if they try to instantiate it they should accept responsibility for any strange behavior.","Create your 'abstract' class and raise NotImplementedError() in the abstract methods. -It won't stop people using the class and, in true duck-typing fashion, it will let you know if you neglect to implement the abstract method.",0.2012947653214861,False,3,2398 +Is one of these a good option or is there a better one? I just want to make sure that other developers know that it is abstract and so if they try to instantiate it they should accept responsibility for any strange behavior.","I just name my abstract classes with the prefix 'Abstract'. E.g. AbstractDevice, AbstractPacket, etc. +It's about as easy and to the point as it comes. If others choose to go ahead and instantiate and/or use a class that starts with the word 'Abstract', then they either know what they're doing or there was no hope for them anyway. +Naming it thus, also serves as a reminder to myself not to go nuts with deep abstraction hierarchies, because putting 'Abstract' on the front of a whole lot of classes feels stupid too.",0.2012947653214861,False,3,2398 2013-02-20 05:03:30.643,Python abstract classes - how to discourage instantiation?,"I come from a C# background where the language has some built in ""protect the developer"" features. I understand that Python takes the ""we're all adults here"" approach and puts responsibility on the developer to code thoughtfully and carefully. That said, Python suggests conventions like a leading underscore for private instance variables. My question is, is there a particular convention for marking a class as abstract other than just specifying it in the docstrings? I haven't seen anything in particular in the python style guide that mentions naming conventions for abstract classes. I can think of 3 options so far but I'm not sure if they're good ideas: @@ -25044,9 +25045,8 @@ Specify it in the docstring above the class (might be overlooked) Use a leading underscore in the class name (not sure if this is universally understood) Create a def __init__(self): method on the abstract class that raises an error (not sure if this negatively impacts inheritance, like if you want to call a base constructor) -Is one of these a good option or is there a better one? I just want to make sure that other developers know that it is abstract and so if they try to instantiate it they should accept responsibility for any strange behavior.","I just name my abstract classes with the prefix 'Abstract'. E.g. AbstractDevice, AbstractPacket, etc. -It's about as easy and to the point as it comes. If others choose to go ahead and instantiate and/or use a class that starts with the word 'Abstract', then they either know what they're doing or there was no hope for them anyway. -Naming it thus, also serves as a reminder to myself not to go nuts with deep abstraction hierarchies, because putting 'Abstract' on the front of a whole lot of classes feels stupid too.",0.2012947653214861,False,3,2398 +Is one of these a good option or is there a better one? I just want to make sure that other developers know that it is abstract and so if they try to instantiate it they should accept responsibility for any strange behavior.","To enforce things is possible, but rather unpythonic. When I came to Python after many years of C++ programming I also tried to do the same, I suppose, most of people try doing so if they have an experience in more classical languages. Metaclasses would do the job, but anyway Python checks very few things at compilation time. Your check will still be performed at runtime. So, is the inability to create a certain class really that useful if discovered only at runtime? In C++ (and in C# as well) you can not even compile you code creating an abstract class, and that is the whole point -- to discover the problem as early as possible. If you have abstract methods, raising a NotImplementedError exception seems to be quite enough. NB: raising, not returning an error code! In Python errors usually should not be silent unless thay are silented explicitly. Documenting. Naming a class in a way that says it's abstract. That's all. +Quality of Python code is ensured mostly with methods that are quite different from those used in languages with advanced compile-time type checking. Personally I consider that the most serious difference between dynamically typed lngauges and the others. Unit tests, coverage analysis etc. As a result, the design of code is quite different: everything is done not to enforce things, but to make testing them as easy as possible.",0.0,False,3,2398 2013-02-20 05:03:30.643,Python abstract classes - how to discourage instantiation?,"I come from a C# background where the language has some built in ""protect the developer"" features. I understand that Python takes the ""we're all adults here"" approach and puts responsibility on the developer to code thoughtfully and carefully. That said, Python suggests conventions like a leading underscore for private instance variables. My question is, is there a particular convention for marking a class as abstract other than just specifying it in the docstrings? I haven't seen anything in particular in the python style guide that mentions naming conventions for abstract classes. I can think of 3 options so far but I'm not sure if they're good ideas: @@ -25055,8 +25055,8 @@ Specify it in the docstring above the class (might be overlooked) Use a leading underscore in the class name (not sure if this is universally understood) Create a def __init__(self): method on the abstract class that raises an error (not sure if this negatively impacts inheritance, like if you want to call a base constructor) -Is one of these a good option or is there a better one? I just want to make sure that other developers know that it is abstract and so if they try to instantiate it they should accept responsibility for any strange behavior.","To enforce things is possible, but rather unpythonic. When I came to Python after many years of C++ programming I also tried to do the same, I suppose, most of people try doing so if they have an experience in more classical languages. Metaclasses would do the job, but anyway Python checks very few things at compilation time. Your check will still be performed at runtime. So, is the inability to create a certain class really that useful if discovered only at runtime? In C++ (and in C# as well) you can not even compile you code creating an abstract class, and that is the whole point -- to discover the problem as early as possible. If you have abstract methods, raising a NotImplementedError exception seems to be quite enough. NB: raising, not returning an error code! In Python errors usually should not be silent unless thay are silented explicitly. Documenting. Naming a class in a way that says it's abstract. That's all. -Quality of Python code is ensured mostly with methods that are quite different from those used in languages with advanced compile-time type checking. Personally I consider that the most serious difference between dynamically typed lngauges and the others. Unit tests, coverage analysis etc. As a result, the design of code is quite different: everything is done not to enforce things, but to make testing them as easy as possible.",0.0,False,3,2398 +Is one of these a good option or is there a better one? I just want to make sure that other developers know that it is abstract and so if they try to instantiate it they should accept responsibility for any strange behavior.","Create your 'abstract' class and raise NotImplementedError() in the abstract methods. +It won't stop people using the class and, in true duck-typing fashion, it will let you know if you neglect to implement the abstract method.",0.2012947653214861,False,3,2398 2013-02-21 05:08:06.700,Wrapping in Notepad++,"I know the Python coding standard has a limit of 78 characters per line. I am working in Notepad++ and how do I set it so it wraps after 78 characters?","To apply the WordWrap, just goo to view in the Menu bar and check the WordWrap option.",0.0,False,1,2399 2013-02-21 21:37:34.480,opening a usb device in python -- what is the path in winXP?,"I'm trying to access a usb device through python but I'm unsure how to find the path to it. @@ -25065,16 +25065,16 @@ pipe = open('/dev/input/js0','r') In which case this is either a mac or linux path. I don't know how to find the path for windows. Could someone steer me in the proper direction? I've sifted through the forums but couldn't quite find my answer. Thanks, --- Mark","The default USB path on windows is D:\. So, if we have a text document named mydoc.txt, which is in the folder myData the appropriate path is D:\myData\mydoc.txt",0.0,False,2,2400 +-- Mark","""Everything is a file"" is one of the core ideas of Unix. Windows does not share this philosophy and, as far as I know, doesn't provide an equivalent interface. You're going to have to find a different way. +The first way would to be to continue handling everything at a low level & have your code use a different code path under Windows. The only real reason to do this is if your goal is to learn about USB programming at a low level. +The other way is to find a library that's already abstracted out the differences between platforms. PySDL immediately comes to mind (followed by PyGame, which is a higher level wrapper around that) but, as that's a gaming/multimedia library, it might be overkill for what you're doing. Google tells me that PyUSB exists and appears to just focus on handing USB devices. PySDL/PyGame have been around a while & are probably more mature so, unless you've got a particular aversion to them, I'd probably stick with them.",0.0,False,2,2400 2013-02-21 21:37:34.480,opening a usb device in python -- what is the path in winXP?,"I'm trying to access a usb device through python but I'm unsure how to find the path to it. The example I'm going from is: pipe = open('/dev/input/js0','r') In which case this is either a mac or linux path. I don't know how to find the path for windows. Could someone steer me in the proper direction? I've sifted through the forums but couldn't quite find my answer. Thanks, --- Mark","""Everything is a file"" is one of the core ideas of Unix. Windows does not share this philosophy and, as far as I know, doesn't provide an equivalent interface. You're going to have to find a different way. -The first way would to be to continue handling everything at a low level & have your code use a different code path under Windows. The only real reason to do this is if your goal is to learn about USB programming at a low level. -The other way is to find a library that's already abstracted out the differences between platforms. PySDL immediately comes to mind (followed by PyGame, which is a higher level wrapper around that) but, as that's a gaming/multimedia library, it might be overkill for what you're doing. Google tells me that PyUSB exists and appears to just focus on handing USB devices. PySDL/PyGame have been around a while & are probably more mature so, unless you've got a particular aversion to them, I'd probably stick with them.",0.0,False,2,2400 +-- Mark","The default USB path on windows is D:\. So, if we have a text document named mydoc.txt, which is in the folder myData the appropriate path is D:\myData\mydoc.txt",0.0,False,2,2400 2013-02-22 13:01:40.437,how to get username and domain of windows logged in client using python code?,"when user logs in to his desktop windows os authenticates him against Active Directory Server. so Whenever he accesses a web page he should not be thrown a login page for entering his userid or password.Instead, his userid and domain need to be captured from his desktop and passed to the web server.(let him enter password after that) Is this possible in python to get username and domain of of client? @@ -25136,22 +25136,6 @@ Thanks.","Does it contain some or all of the current execution state of your pro So how do I do this? I spend most of my time developing desktop program and just know some basic web developing knowledges. I have read some framework such as flask and web2py, and know how to use HTML and Javascript to make buttons but no clue to achieve my purpose. Can someone give me a practical way to do this? It'd be better if the user don't have to upload the local data to the server. Maybe just download the python code from server then execute in Chrome. Is this possible? -Thanks.","No, you cannot run Python code in a web browser.[1] You'd have to port the core of your application to JavaScript to do it all locally. -Just do the upload. 20MB isn't all that much data, and if it's stored on the server then they can all look at each others' results, too. - -[1] There are some tools that try to transpile Python to JavaScript: pyjs compiles directly, and Emscripten is an entire LLVM interpreter in JS that can run CPython itself. I wouldn't really recommend relying on these.",0.1352210990936997,False,3,2414 -2013-02-26 23:55:05.617,How to setup a web app which can handle local data without uploading the data? Use python,"I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website and use Chrome as the GUI. -So how do I do this? I spend most of my time developing desktop program and just know some basic web developing knowledges. I have read some framework such as flask and web2py, and know how to use HTML and Javascript to make buttons but no clue to achieve my purpose. -Can someone give me a practical way to do this? -It'd be better if the user don't have to upload the local data to the server. Maybe just download the python code from server then execute in Chrome. Is this possible? -Thanks.","The whole point of a web application is that the GUI is written in HTML, CSS, and JavaScript, not Python. However, it talks to a web service, which can be written in Python. -For a well-written desktop app, the transition should be pretty easy. If you've already got a clean separation between the GUI part and the engine part of your code, the engine part will only need minor changes (and maybe stick it behind, e.g., a WSGI server). You will have to rewrite the GUI part for the web, but in a complex app, that should be the easy part. -However, many desktop GUI apps don't have such a clean separation. For example, if you have button handlers that directly do stuff to your model, there's really no way to make that work without duplicating the model on both sides (the Python web service and the JS client app) and synchronizing the two, which is a lot of work and leads to a bad experience. In that case, you have to decide between rewriting most of your app from scratch, or refactoring it to the point where you can web-service-ify it. -If you do choose to go the refactoring route, I'd consider adding a second local interface (maybe using the cmd module to build a CLI, or tkinter for an alternate GUI), because that's much easier to do. Once the same backend code can support your PyQt GUI and your cmd GUI, adding a web interface is much easier.",1.2,True,3,2414 -2013-02-26 23:55:05.617,How to setup a web app which can handle local data without uploading the data? Use python,"I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website and use Chrome as the GUI. -So how do I do this? I spend most of my time developing desktop program and just know some basic web developing knowledges. I have read some framework such as flask and web2py, and know how to use HTML and Javascript to make buttons but no clue to achieve my purpose. -Can someone give me a practical way to do this? -It'd be better if the user don't have to upload the local data to the server. Maybe just download the python code from server then execute in Chrome. Is this possible? Thanks.","If I get your point correctly, you want Web connection, so your python program updated on server, client get it before using it. @@ -25166,6 +25150,22 @@ Check against current version to see if you need to download latest program Download latest version and use that to run locally. Does this solve your problem?",0.0,False,3,2414 +2013-02-26 23:55:05.617,How to setup a web app which can handle local data without uploading the data? Use python,"I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website and use Chrome as the GUI. +So how do I do this? I spend most of my time developing desktop program and just know some basic web developing knowledges. I have read some framework such as flask and web2py, and know how to use HTML and Javascript to make buttons but no clue to achieve my purpose. +Can someone give me a practical way to do this? +It'd be better if the user don't have to upload the local data to the server. Maybe just download the python code from server then execute in Chrome. Is this possible? +Thanks.","No, you cannot run Python code in a web browser.[1] You'd have to port the core of your application to JavaScript to do it all locally. +Just do the upload. 20MB isn't all that much data, and if it's stored on the server then they can all look at each others' results, too. + +[1] There are some tools that try to transpile Python to JavaScript: pyjs compiles directly, and Emscripten is an entire LLVM interpreter in JS that can run CPython itself. I wouldn't really recommend relying on these.",0.1352210990936997,False,3,2414 +2013-02-26 23:55:05.617,How to setup a web app which can handle local data without uploading the data? Use python,"I have a small python program to help my colleagues to analyse some tsv data. The data is not big, usually below 20MB. I developed the GUI with PyQT. I want to change this desktop program to a web app so my colleagues don't have to upgrade the program every time I change it or fix a bug. They can just go to a website and use Chrome as the GUI. +So how do I do this? I spend most of my time developing desktop program and just know some basic web developing knowledges. I have read some framework such as flask and web2py, and know how to use HTML and Javascript to make buttons but no clue to achieve my purpose. +Can someone give me a practical way to do this? +It'd be better if the user don't have to upload the local data to the server. Maybe just download the python code from server then execute in Chrome. Is this possible? +Thanks.","The whole point of a web application is that the GUI is written in HTML, CSS, and JavaScript, not Python. However, it talks to a web service, which can be written in Python. +For a well-written desktop app, the transition should be pretty easy. If you've already got a clean separation between the GUI part and the engine part of your code, the engine part will only need minor changes (and maybe stick it behind, e.g., a WSGI server). You will have to rewrite the GUI part for the web, but in a complex app, that should be the easy part. +However, many desktop GUI apps don't have such a clean separation. For example, if you have button handlers that directly do stuff to your model, there's really no way to make that work without duplicating the model on both sides (the Python web service and the JS client app) and synchronizing the two, which is a lot of work and leads to a bad experience. In that case, you have to decide between rewriting most of your app from scratch, or refactoring it to the point where you can web-service-ify it. +If you do choose to go the refactoring route, I'd consider adding a second local interface (maybe using the cmd module to build a CLI, or tkinter for an alternate GUI), because that's much easier to do. Once the same backend code can support your PyQt GUI and your cmd GUI, adding a web interface is much easier.",1.2,True,3,2414 2013-02-27 04:13:37.733,Is it a bad idea to use a PNG image's filename to store the info on how to process it?,"I am making a little game app that allows users to load up textures manually. One such example would be a standard deck of 52 cards. Would it be bad to store the processing info as: Card_79x123_53_53.png @@ -25210,10 +25210,10 @@ I'm using Python 2.6 if it makes a difference. Thanks!","If you really need to But 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? Or, 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?",0.3869120172231254,False,1,2417 2013-02-28 11:20:41.370,Compass not working with pyScss 1.1.5,"I am with Python 2.7, pyScss 1.15 and Compass 0.12.2, but Compass dosn't work, could someone give an advise how to make it work?","You don't need compass with pyScss. Just run ""python pyScss -mscss"" to watch your workingdir for changes and compile the .scss (or .sass) to .css.",0.0,False,1,2418 -2013-03-02 06:07:15.727,How to get image position in Pygame,"I am coding for a mouse drag and drop effect on images. Meanwhile, I want to take record of the upper-left point of image each time I dragged and dropped it, are there any ways to get it?","What methods are you using to draw the images? It's hard to answer this question without that. -If you aren't already doing this, you could use a class to hold data about your image, such as position and geometry.",0.2012947653214861,False,2,2419 2013-03-02 06:07:15.727,How to get image position in Pygame,"I am coding for a mouse drag and drop effect on images. Meanwhile, I want to take record of the upper-left point of image each time I dragged and dropped it, are there any ways to get it?","If you derive your classes from pygame.sprite.Sprite , you can get the position by guy.rect. Depending on if you want center, or toplef, or the full rect: guy.rect.topleft or guy.rect.center or guy.rect",0.2012947653214861,False,2,2419 +2013-03-02 06:07:15.727,How to get image position in Pygame,"I am coding for a mouse drag and drop effect on images. Meanwhile, I want to take record of the upper-left point of image each time I dragged and dropped it, are there any ways to get it?","What methods are you using to draw the images? It's hard to answer this question without that. +If you aren't already doing this, you could use a class to hold data about your image, such as position and geometry.",0.2012947653214861,False,2,2419 2013-03-02 09:21:18.977,Heroku Python App - CSS Not Loading On IPhone Only,"First question posted to Stack Overflow but have spent many hours reading answers here :). I'm creating a Heroku Python app and am using responsive design media queries in my css. I deploy my app to Heroku and visit myherokuapp.herokuapp.com. Website looks fine on laptop browser...responsive design elements working as well. Visiting the same url on my iPhone, however, seems to show a page where one of my css files (the media queries) is loading but the other (the main css file) is not. Does Heroku cache css files? I read somewhere that you have to host static files elsewhere if you have a Django app, but not sure if that's applicable to me. I'm also using the Flask function . Does that have anything to do with it? @@ -25247,7 +25247,12 @@ I'm on Win7, and trying to run Python from the Django stack by BitNami.","http:/ Add python to your environment path. You should then be able to use it anywhere.",1.2,True,1,2424 2013-03-05 10:13:15.943,Get instance of an running Python program,"Suppose a python program is running. Say the object of an Class in that program can give you some stats. So if i have to develop a web UI to display the stats, how do i get the instance of that class which is running[as an separate desktop app] and display the stats in web, which I would be using web2py or django.","You can't (easily) ""get an instance of a running program"" from outside. You can certainly instrument your program so that it communicates its statistics somehow, eg via a socket, or as an even lower-tech solution you could get it to store the relevant data periodically in a file on disk or in a database, which your web app could read.",0.3869120172231254,False,1,2425 2013-03-05 10:29:18.290,How do I update/upgrade pip itself from inside my virtual environment?,"I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version. -What's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already tried pip update and pip update pip with no success.","I had installed Python in C:\Python\Python36 so I went to the Windows command prompt and typed ""cd C:\Python\Python36 to get to the right directory. Then entered the ""python -m install --upgrade pip"" all good!",0.0,False,3,2426 +What's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already tried pip update and pip update pip with no success.","While updating pip in virtual env use full path in python command +Envirnments folder struture + +myenv\scripts\python + +h:\folderName\myenv\scripts\python -m pip install --upgrade pip",0.0,False,3,2426 2013-03-05 10:29:18.290,How do I update/upgrade pip itself from inside my virtual environment?,"I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version. What's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already tried pip update and pip update pip with no success.","for windows, @@ -25260,12 +25265,7 @@ pip --version if you want to install any particular version of pip , for example version 18.1 then use this command, python -m pip install pip==18.1",0.1410236379120691,False,3,2426 2013-03-05 10:29:18.290,How do I update/upgrade pip itself from inside my virtual environment?,"I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version. -What's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already tried pip update and pip update pip with no success.","While updating pip in virtual env use full path in python command -Envirnments folder struture - -myenv\scripts\python - -h:\folderName\myenv\scripts\python -m pip install --upgrade pip",0.0,False,3,2426 +What's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already tried pip update and pip update pip with no success.","I had installed Python in C:\Python\Python36 so I went to the Windows command prompt and typed ""cd C:\Python\Python36 to get to the right directory. Then entered the ""python -m install --upgrade pip"" all good!",0.0,False,3,2426 2013-03-06 02:07:38.567,Serve Static Pages from S3 using Django,"I'm planning to build a Django app to generate and later server static pages (probably stored on S3). When users visit a url like mysite.com/static-pages/12345 the static file in my S3 bucket named 12345.html should be served. That static file might be the static html page of a blog page my site has generated for the user, for example. This is different from including static resources like CSS/Javascript files on a page that is rendered as a Django template since I already know how to use Django templates and SQL databases - what's unfamiliar to me is that my ""data"" is now a file on S3 rather than an entry in a database AND that I don't actually need to use a template. How exactly can I retrieve the requested data (i.e. a static page) and return it to the user? I'd like to minimize performance penalties within reason, although of course it would be fastest if users directly requested their static pages from S3 (I don't want them to do this)"". @@ -25285,9 +25285,6 @@ Thanks a lot.","It doesnt support it directly from what I've seen. However there is a mongodb input step. And a lot of work has been done on it recently ( and still ongoing. So given there is a mongodb input step, if you're using an ETL tool already then why would you want to make it execute a python script to do the job??",1.2,True,1,2429 2013-03-07 21:41:13.973,Django Static Setup,"I've looked through countless answers and questions trying to find a single definitive guide or way to do this, but it seems that everyone has a different way. Can someone please just explain to me how to serve static files in templates? -Assuming I've just created a brand new project with Django 1.4, what all do I need to do to be able to render images? Where should I put the media and static folders?","The created project should have a static folder. Put all resources (images, ...) in there. -Then, in your HTML template, you can reference STATIC_ROOT and add the resource path (relative to the static folder)",0.0,False,2,2430 -2013-03-07 21:41:13.973,Django Static Setup,"I've looked through countless answers and questions trying to find a single definitive guide or way to do this, but it seems that everyone has a different way. Can someone please just explain to me how to serve static files in templates? Assuming I've just created a brand new project with Django 1.4, what all do I need to do to be able to render images? Where should I put the media and static folders?","Put your static files into /static or add an absolute path to STATICFILES_DIRS Configure your web server (you should not serve static files with Django) to serve files in STATIC_ROOT Point STATIC_URL to the base URL the web server serves @@ -25297,6 +25294,9 @@ Coffee and pat yourself on the back A little bit more about running a web server in front of Django. Django is practically an application server. It has not been designed to be any good in serving static files. That is why it actively refuses to do that when DEBUG=False. Also, the Django development server should not be used for production. This means that there should be something in front of Django at all times. It may be a WSGI server such as gunicorn or a 'real' web server such as nginx or Apache. If you are running a reverse proxy (such as nginx or Apache) you can bind /static to a path in the filesystem and the rest of the traffic to pass through to Django. That means your STATIC_URL can be a relative path. Otherwise you will need to use an absolute URL.",1.2,True,2,2430 +2013-03-07 21:41:13.973,Django Static Setup,"I've looked through countless answers and questions trying to find a single definitive guide or way to do this, but it seems that everyone has a different way. Can someone please just explain to me how to serve static files in templates? +Assuming I've just created a brand new project with Django 1.4, what all do I need to do to be able to render images? Where should I put the media and static folders?","The created project should have a static folder. Put all resources (images, ...) in there. +Then, in your HTML template, you can reference STATIC_ROOT and add the resource path (relative to the static folder)",0.0,False,2,2430 2013-03-07 21:42:28.883,creating arabic corpus,"I'm doing the sentiment analysis for the Arabic language , I want to creat my own corpus , to do that , I collect 300 status from facebook and I classify them into positive and negative , now I want to do the tokenization of these status , in order to obain a list of words , and hen generate unigrams and bigrams, trigrams and use the cross fold validation , I'm using for the moment the nltk python, is this software able to do this task fr the arabic language or the rapis Minner will be better to work with , what do you think and I'm wondering how to generate the bigrams, trigrams and use the cross fold validation , is there any idea ??","Well, I think that rapidminer is very interesting and can handle this task. It contains several operators dealing with text mining. Also, it allows the creation of new operators with high fluency.",0.0,False,1,2431 2013-03-08 15:21:14.563,Wait until a Jenkins build is complete,"I am using Python 2.7 and Jenkins. I am writing some code in Python that will perform a checkin and wait/poll for Jenkins job to be complete. I would like some thoughts on around how I achieve it. @@ -25309,17 +25309,17 @@ Can I use snippets from the Jenkins Rest API or from Python Jenkins module?","Yo As a matter of fact, in your Jenkins, add /lastBuild/api/ to any Job, and you will see a lot of API information. It even has Python API, but I not familiar with that so can't help you further However, if you were using XML, you can add lastBuild/api/xml?depth=0 and inside the XML, you can see the object with list of revisions/commit messages that triggered the build",1.2,True,1,2432 2013-03-08 23:01:11.130,"In homebrew how do I change the python3 symlink to only ""python""","I want to install python using homebrew and I noticed there are 2 different formulas for it, one for python 2.x and another for 3.x. The first symlinks ""python"" and the other uses ""python3"". so I ran brew install python3. -I really only care about using python 3 so I would like the default command to be ""python"" instead of having to type ""python3"" every time. Is there a way to do this? I tried brew switch python 3.3 but I get a ""python is not found in the Cellar"" error.","You definitely do not want to do this! You may only care about Python 3, but many people write code that expects python to symlink to Python 2. Changing this can seriously mess your system up.",0.573727155831378,False,2,2433 -2013-03-08 23:01:11.130,"In homebrew how do I change the python3 symlink to only ""python""","I want to install python using homebrew and I noticed there are 2 different formulas for it, one for python 2.x and another for 3.x. The first symlinks ""python"" and the other uses ""python3"". so I ran brew install python3. I really only care about using python 3 so I would like the default command to be ""python"" instead of having to type ""python3"" every time. Is there a way to do this? I tried brew switch python 3.3 but I get a ""python is not found in the Cellar"" error.","As mentioned this is not the best idea. However, the simplest thing to do when necessary is run python3 in terminal. If you need to run something for python3 then run python3",0.0814518047658113,False,2,2433 +2013-03-08 23:01:11.130,"In homebrew how do I change the python3 symlink to only ""python""","I want to install python using homebrew and I noticed there are 2 different formulas for it, one for python 2.x and another for 3.x. The first symlinks ""python"" and the other uses ""python3"". so I ran brew install python3. +I really only care about using python 3 so I would like the default command to be ""python"" instead of having to type ""python3"" every time. Is there a way to do this? I tried brew switch python 3.3 but I get a ""python is not found in the Cellar"" error.","You definitely do not want to do this! You may only care about Python 3, but many people write code that expects python to symlink to Python 2. Changing this can seriously mess your system up.",0.573727155831378,False,2,2433 2013-03-08 23:15:02.527,How to get the list of error numbers (Errno) for an Exception type in python?,"For a specific Exception type (let's say for IOError), how can i extract the complete list of Errnos and descriptions like this: Errno 2: No such file or directory Errno 122: Disk quota exceeded -...","I fear those come straight from the standard C library, so you'll have to look it up in your system documentation. (GLibC, Microsoft, UNIX…)",0.4540544406412981,False,2,2434 +...",look for errno.h on your system.,0.3153999413393242,False,2,2434 2013-03-08 23:15:02.527,How to get the list of error numbers (Errno) for an Exception type in python?,"For a specific Exception type (let's say for IOError), how can i extract the complete list of Errnos and descriptions like this: Errno 2: No such file or directory Errno 122: Disk quota exceeded -...",look for errno.h on your system.,0.3153999413393242,False,2,2434 +...","I fear those come straight from the standard C library, so you'll have to look it up in your system documentation. (GLibC, Microsoft, UNIX…)",0.4540544406412981,False,2,2434 2013-03-11 00:01:31.953,How can I efficiently get all divisors of X within a range if I have X's prime factorization?,"So I have algorithms (easily searchable on the net) for prime factorization and divisor acquisition but I don't know how to scale it to finding those divisors within a range. For example all divisors of 100 between 23 and 49 (arbitrary). But also something efficient so I can scale this to big numbers in larger ranges. At first I was thinking of using an array that's the size of the range and then use all the primes <= the upper bound to sieve all the elements in that array to return an eventual list of divisors, but for large ranges this would be too memory intensive. Is there a simple way to just directly generate the divisors?","As Malvolio was (indirectly) going about, I personal wouldn't find a use for prime factorization if you want to find factors in a range, I would start at int t = (int)(sqrt(n)) and then decremnt until1. t is a factor2. Complete util t or t/n range has been REACHED(a flag) and then (both) has left the range Or if your range is relatively small, check versus those values themselves.",0.0,False,1,2435 @@ -25333,8 +25333,7 @@ This is probably a lot of work to do well. I suggest you use an existing VPN to 2013-03-12 03:59:07.337,python 3.3 on sublime text 2 windows 7,I am running windows 7 32 bit and i am using sublime text 2 I want to know how can I change the default python in ST2 to the python 3.3 I down loaded. Any help would be great thanks.,"You need to change the Sublime build system for Python. Copy the Python.sublime-build file from the Packages/Python folder to the Packages/User folder. In the file in the User folder, change the cmd option from python to c:/python33/python (where your Python 3.3 executable is located).",0.0,False,1,2438 2013-03-12 17:11:35.633,Default working directory for Python IDLE?,"Is there a configuration file where I can set its default working directory? It currently defaults to my home directory, but I want to set it to another directory when it starts. I know I can do ""import os"" followed by ""os.chdir("""")"" but that's kind of troublesome. It'd be great if there is a conf file that I can edit and change that setting, but I am unable to find it. In particular, I've looked into my OS (Ubuntu)'s desktop entry '/usr/share/applications/idle-python3.2.desktop', which doesn't contain a conf file, but points to '/usr/lib/python3.2/idlelib/PyShell.py', which points to config-*.def conf files under the same folder, with 'config-main.def' being the most likely candidate. However I am unable to find where the default path is specified or how it can be changed. -It seems that the path is hard-coded in PyShell.py, though I could be wrong with my limited knowledge on Python. I will keep looking, but would appreciate it if somebody knows the answer on top of his or her head. Thanks in advance.","This ought to be the number one answer. I have been playing around this for an hour or more and nothing worked. Paul explains this perfectly. It's just like the PATH statement in Windows. I successfully imported a module by appending my personal ""PythonModules"" path/dir on my Mac (starting at ""/users/etc"") using a simple -import xxxx command in Idle.",-0.0453204071731508,False,3,2439 +It seems that the path is hard-coded in PyShell.py, though I could be wrong with my limited knowledge on Python. I will keep looking, but would appreciate it if somebody knows the answer on top of his or her head. Thanks in advance.","It can change depending on where you installed Python. Open up IDLE, import os, then call os.getcwd() and that should tell you exactly where your IDLE is working on.",0.0,False,3,2439 2013-03-12 17:11:35.633,Default working directory for Python IDLE?,"Is there a configuration file where I can set its default working directory? It currently defaults to my home directory, but I want to set it to another directory when it starts. I know I can do ""import os"" followed by ""os.chdir("""")"" but that's kind of troublesome. It'd be great if there is a conf file that I can edit and change that setting, but I am unable to find it. In particular, I've looked into my OS (Ubuntu)'s desktop entry '/usr/share/applications/idle-python3.2.desktop', which doesn't contain a conf file, but points to '/usr/lib/python3.2/idlelib/PyShell.py', which points to config-*.def conf files under the same folder, with 'config-main.def' being the most likely candidate. However I am unable to find where the default path is specified or how it can be changed. It seems that the path is hard-coded in PyShell.py, though I could be wrong with my limited knowledge on Python. I will keep looking, but would appreciate it if somebody knows the answer on top of his or her head. Thanks in advance.","Here's a way to reset IDLE's default working directory for MacOS if you launch Idle as an application by double-clicking it. You need a different solution if you launch Idle from a command line in Terminal. This solution is a permanent fix. You don't have to rechange the directory everytime you launch IDLE. I wish it were easier. @@ -25353,22 +25352,23 @@ import os os.getcwd()",0.0,False,3,2439 2013-03-12 17:11:35.633,Default working directory for Python IDLE?,"Is there a configuration file where I can set its default working directory? It currently defaults to my home directory, but I want to set it to another directory when it starts. I know I can do ""import os"" followed by ""os.chdir("""")"" but that's kind of troublesome. It'd be great if there is a conf file that I can edit and change that setting, but I am unable to find it. In particular, I've looked into my OS (Ubuntu)'s desktop entry '/usr/share/applications/idle-python3.2.desktop', which doesn't contain a conf file, but points to '/usr/lib/python3.2/idlelib/PyShell.py', which points to config-*.def conf files under the same folder, with 'config-main.def' being the most likely candidate. However I am unable to find where the default path is specified or how it can be changed. -It seems that the path is hard-coded in PyShell.py, though I could be wrong with my limited knowledge on Python. I will keep looking, but would appreciate it if somebody knows the answer on top of his or her head. Thanks in advance.","It can change depending on where you installed Python. Open up IDLE, import os, then call os.getcwd() and that should tell you exactly where your IDLE is working on.",0.0,False,3,2439 +It seems that the path is hard-coded in PyShell.py, though I could be wrong with my limited knowledge on Python. I will keep looking, but would appreciate it if somebody knows the answer on top of his or her head. Thanks in advance.","This ought to be the number one answer. I have been playing around this for an hour or more and nothing worked. Paul explains this perfectly. It's just like the PATH statement in Windows. I successfully imported a module by appending my personal ""PythonModules"" path/dir on my Mac (starting at ""/users/etc"") using a simple +import xxxx command in Idle.",-0.0453204071731508,False,3,2439 2013-03-12 19:07:09.843,python - saving numpy array to a file (smallest size possible),"Right now I have a python program building a fairly large 2D numpy array and saving it as a tab delimited text file using numpy.savetxt. The numpy array contains only floats. I then read the file in one row at a time in a separate C++ program. What I would like to do is find a way to accomplish this same task, changing my code as little as possible such that I can decrease the size of the file I am passing between the two programs. I found that I can use numpy.savetxt to save to a compressed .gz file instead of a text file. This lowers the file size from ~2MB to ~100kB. Is there a better way to do this? Could I, perhaps, write the numpy array in binary to the file to save space? If so, how would I do this so that I can still read it into the C++ program? Thank you for the help. I appreciate any guidance I can get. EDIT: -There are a lot of zeros (probably 70% of the values in the numpy array are 0.0000) I am not sure of how I can somehow exploit this though and generate a tiny file that my c++ program can read in","If you don't mind installing additional packages (for both python and c++), you can use [BSON][1] (Binary JSON).",0.0,False,3,2440 +There are a lot of zeros (probably 70% of the values in the numpy array are 0.0000) I am not sure of how I can somehow exploit this though and generate a tiny file that my c++ program can read in","numpy.ndarray.tofile and numpy.fromfile are useful for direct binary output/input from python. std::ostream::write std::istream::read are useful for binary output/input in c++. +You should be careful about endianess if the data are transferred from one machine to another.",0.0814518047658113,False,3,2440 2013-03-12 19:07:09.843,python - saving numpy array to a file (smallest size possible),"Right now I have a python program building a fairly large 2D numpy array and saving it as a tab delimited text file using numpy.savetxt. The numpy array contains only floats. I then read the file in one row at a time in a separate C++ program. What I would like to do is find a way to accomplish this same task, changing my code as little as possible such that I can decrease the size of the file I am passing between the two programs. I found that I can use numpy.savetxt to save to a compressed .gz file instead of a text file. This lowers the file size from ~2MB to ~100kB. Is there a better way to do this? Could I, perhaps, write the numpy array in binary to the file to save space? If so, how would I do this so that I can still read it into the C++ program? Thank you for the help. I appreciate any guidance I can get. EDIT: -There are a lot of zeros (probably 70% of the values in the numpy array are 0.0000) I am not sure of how I can somehow exploit this though and generate a tiny file that my c++ program can read in","numpy.ndarray.tofile and numpy.fromfile are useful for direct binary output/input from python. std::ostream::write std::istream::read are useful for binary output/input in c++. -You should be careful about endianess if the data are transferred from one machine to another.",0.0814518047658113,False,3,2440 +There are a lot of zeros (probably 70% of the values in the numpy array are 0.0000) I am not sure of how I can somehow exploit this though and generate a tiny file that my c++ program can read in","If you don't mind installing additional packages (for both python and c++), you can use [BSON][1] (Binary JSON).",0.0,False,3,2440 2013-03-12 19:07:09.843,python - saving numpy array to a file (smallest size possible),"Right now I have a python program building a fairly large 2D numpy array and saving it as a tab delimited text file using numpy.savetxt. The numpy array contains only floats. I then read the file in one row at a time in a separate C++ program. What I would like to do is find a way to accomplish this same task, changing my code as little as possible such that I can decrease the size of the file I am passing between the two programs. I found that I can use numpy.savetxt to save to a compressed .gz file instead of a text file. This lowers the file size from ~2MB to ~100kB. @@ -25398,14 +25398,7 @@ Server A runs import.sh Server A completes running ""import.sh"" Server A removes ""Start Import"" from SQS -Is this how SQS should be used or am I missing the point completely?","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: - -it has abysmal performance in low volume messaging (some messages will take 90 seconds to arrive) -message order is not preserved -it is fond of delivering messages more than once -they charge you for polling - -The 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.",0.3869120172231254,False,3,2442 +Is this how SQS should be used or am I missing the point completely?","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.",0.1352210990936997,False,3,2442 2013-03-13 09:15:18.697,How should Amazon SQS be used? Import / Process Scenario,"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. Server A: Main Dedicated Server Server B: Cloud Process Server @@ -25423,7 +25416,14 @@ Server A runs import.sh Server A completes running ""import.sh"" Server A removes ""Start Import"" from SQS -Is this how SQS should be used or am I missing the point completely?","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.",0.1352210990936997,False,3,2442 +Is this how SQS should be used or am I missing the point completely?","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: + +it has abysmal performance in low volume messaging (some messages will take 90 seconds to arrive) +message order is not preserved +it is fond of delivering messages more than once +they charge you for polling + +The 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.",0.3869120172231254,False,3,2442 2013-03-13 09:15:18.697,How should Amazon SQS be used? Import / Process Scenario,"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. Server A: Main Dedicated Server Server B: Cloud Process Server @@ -25476,13 +25476,13 @@ Ultimately, the only way you can know how much gain you get is by trying it both 2013-03-14 11:41:03.660,cannot import name LOOKUP_SEP,"I'm using django and I'm trying to set up django-roa but when i'm trying to start my webserver I have this error cannot import name LOOKUP_SEP If I remove django_roa from my INSTALLEDS_APP it's okay but I want django-roa working and I don't know how resolve this problem. And I don't know what kind of detail I can tell to find a solution. -Thanks",django_roa is not yet compatible with django 1.5. I'm afraid it only works with django 1.3.,1.2,True,2,2447 -2013-03-14 11:41:03.660,cannot import name LOOKUP_SEP,"I'm using django and I'm trying to set up django-roa but when i'm trying to start my webserver I have this error cannot import name LOOKUP_SEP -If I remove django_roa from my INSTALLEDS_APP it's okay but I want django-roa working and I don't know how resolve this problem. -And I don't know what kind of detail I can tell to find a solution. Thanks","I downgraded from 1.5.2 to 1.4.0 and my app started working again. Via pip: pip install django==1.4 Hope that helps.",0.0,False,2,2447 +2013-03-14 11:41:03.660,cannot import name LOOKUP_SEP,"I'm using django and I'm trying to set up django-roa but when i'm trying to start my webserver I have this error cannot import name LOOKUP_SEP +If I remove django_roa from my INSTALLEDS_APP it's okay but I want django-roa working and I don't know how resolve this problem. +And I don't know what kind of detail I can tell to find a solution. +Thanks",django_roa is not yet compatible with django 1.5. I'm afraid it only works with django 1.3.,1.2,True,2,2447 2013-03-15 22:13:21.490,python - simpledb - how to shard/chunk a big string into several <1kb values?,"I've been reading up on SimpleDB and one downfall (for me) is the 1kb max per attribute limit. I do a lot of RSS feed processing and I was hoping to store feed data in SimpleDB (articles) and from what I've read the best way to do this is to shard the article across several attributes. The typical article is < 30kb of plain text. I'm currently storing article data in DynamoDB (gzip compressed) without any issues, but the cost is fairly high. Was hoping to migrate to SimpleDB for cheaper storage with still fast retrievals. I do archive a json copy of all rss articles on S3 as well (many years of mysql headaches make me wary of db's). Does anyone know to shard a string into < 1kb pieces? I'm assuming an identifier would need to be appended to each chunk for order of reassembly. @@ -25559,10 +25559,10 @@ I guess I can't be the first one thinking about it. Someone must have implemente One 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. Another 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.",0.0,False,1,2460 2013-03-25 22:01:07.000,Matching Month and Year In Python with datetime,"I'm working on a blog using Django and I'm trying to use get() to retrieve the post from my database with a certain post_title and post_date. I'm using datetime for the post_date, and although I can use post_date = date(year, month, day) to fetch a post made on that specific day, I don't know how to get it to ignore the day parameter, I can't only pass two arguments to date() and since only integers can be used I don't think there's any kind of wildcard I can use for the day. How would I go about doing this? -To clarify, I'm trying to find a post using the year in which it was posted, the month, and it's title, but not the day. Thanks in advance for any help!",you could use post_date__year and post_date__month,1.2,True,2,2461 -2013-03-25 22:01:07.000,Matching Month and Year In Python with datetime,"I'm working on a blog using Django and I'm trying to use get() to retrieve the post from my database with a certain post_title and post_date. I'm using datetime for the post_date, and although I can use post_date = date(year, month, day) to fetch a post made on that specific day, I don't know how to get it to ignore the day parameter, I can't only pass two arguments to date() and since only integers can be used I don't think there's any kind of wildcard I can use for the day. How would I go about doing this? To clarify, I'm trying to find a post using the year in which it was posted, the month, and it's title, but not the day. Thanks in advance for any help!","What you're looking for is probably coverd by post_date__year=year and post_date__month=month in django. Nevertheless all this seems a little bit werid for get parameters. Do you have any constraint at database level that forbids you from putting there two posts with the same title in the same month of given year?",0.2012947653214861,False,2,2461 +2013-03-25 22:01:07.000,Matching Month and Year In Python with datetime,"I'm working on a blog using Django and I'm trying to use get() to retrieve the post from my database with a certain post_title and post_date. I'm using datetime for the post_date, and although I can use post_date = date(year, month, day) to fetch a post made on that specific day, I don't know how to get it to ignore the day parameter, I can't only pass two arguments to date() and since only integers can be used I don't think there's any kind of wildcard I can use for the day. How would I go about doing this? +To clarify, I'm trying to find a post using the year in which it was posted, the month, and it's title, but not the day. Thanks in advance for any help!",you could use post_date__year and post_date__month,1.2,True,2,2461 2013-03-26 11:27:35.883,GAE: Data is lost after dev server restart,I'm running App Engine with Python 2.7 on OS X. Once I stop the development server all data in the data store is lost. Same thing happens when I try to deploy my app. What might cause this behaviour and how to fix it?,"This is answered, but to explain a little further - the local datastore, by default writes to the temporary file system on your computer. By default, the temporary file is emptied any time you restart the computer, hence your datastore is emptied. If you don't restart your computer, your datastore should remain.",0.3869120172231254,False,1,2462 2013-03-26 19:02:31.150,How is waiting for I/O or waiting for a lock to be released implemented?,"I'm curious. I've been programming in Python for years. When I run a command that blocks on I/O (whether it's a hard-disk read or a network request), or blocks while waiting on a lock to be released, how is that implemented? How does the thread know when to reacquire the GIL and start running again? I wonder whether this is implemented by constantly checking (""Is the output here now? Is it here now? What about now?"") which I imagine is wasteful, or alternatively in a more elegant way.","There is no need to repeatedly check for either I/O completion or for lock release. @@ -25572,17 +25572,17 @@ The high I/O performance of this mechanism, eliminating any polling or checking, Almost everything is working and needs some code cleanup now. It's written in python, the standalone webserver uses cherrypy as a framework. The problem is, that the gnu screen output on the webinterface is done via a logfile, which can cause high I/O when enabled (ok, it depends on what is running). +Is there a way to pipe the output directly to the standalone webserver (it has to be fast)? Maybe something with sockets, but i dont know how to handle them yet.",You can use syslog or even better you can configure it to send all logs to a database!,0.0,False,2,2464 +2013-03-27 08:43:39.130,"A way to ""pipe"" gnu screen output to a running python process?","I'm developing a small piece of software, that is able to control (start, stop, restart and so on - with gnu screen) every possible gameserver (which have a command line) and includes a tiny standalone webserver with a complete webinterface (you can access the gnu screen from there, like if you're attached to it) on linux. +Almost everything is working and needs some code cleanup now. +It's written in python, the standalone webserver uses cherrypy as a framework. +The problem is, that the gnu screen output on the webinterface is done via a logfile, which can cause high I/O when enabled (ok, it depends on what is running). Is there a way to pipe the output directly to the standalone webserver (it has to be fast)? Maybe something with sockets, but i dont know how to handle them yet.","Writing to a pipe would work but it's dangerous since your command (the one writing the pipe) will block when you're not fast enough reading the data from the pipe. A better solution would be create a local ""log server"" which publishes stdin on a socket. Now you can pipe the output of your command to the log server which reads from stdin and sends copy of the input to anyone connected to it's socket. When no one is connected, then the output is just ignored. Writing such a ""log server"" is trivial (about 1h in Python, I'd guess). An additional advantage would be that you could keep part of the log file in memory (say the last 100 lines). When your command crashes, then you could still get the last output from your log server. For this to work, you must not terminate the log server when stdin returns EOF. The drawback is that you need to clean up stale log servers yourself. When you use sockets, you can send it a ""kill"" command from your web app.",0.1352210990936997,False,2,2464 -2013-03-27 08:43:39.130,"A way to ""pipe"" gnu screen output to a running python process?","I'm developing a small piece of software, that is able to control (start, stop, restart and so on - with gnu screen) every possible gameserver (which have a command line) and includes a tiny standalone webserver with a complete webinterface (you can access the gnu screen from there, like if you're attached to it) on linux. -Almost everything is working and needs some code cleanup now. -It's written in python, the standalone webserver uses cherrypy as a framework. -The problem is, that the gnu screen output on the webinterface is done via a logfile, which can cause high I/O when enabled (ok, it depends on what is running). -Is there a way to pipe the output directly to the standalone webserver (it has to be fast)? Maybe something with sockets, but i dont know how to handle them yet.",You can use syslog or even better you can configure it to send all logs to a database!,0.0,False,2,2464 2013-03-28 22:53:18.933,Shell scripts have different behavior when launched by Jenkins,"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. As 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.","To debug this: @@ -25666,22 +25666,22 @@ everything has been working fine (on dvi/vga/hdmi monitors) up to the time when the monitor is detected by wxwidgets to be lower resolution than it actually is, so the bitmap goes off the screen. EDID still detects valid resolution so it is for sure wxwidgets related issue. when i use wx.DisplaySize - it returns lower resolution than is actually set. i also tried to create the bitmap according to the wx.DisplaySize() output but then, as expected, when i try to light up one pixel, its neighbours are changed too. (some sort of scalling occurs). similar issue occurs when i plug a projector. -have any of you had simmilar symptomes? how to deal with it?",Correct EDID values does not necessarily mean that the system is running it in that display mode. Have you checked the system's display properties or screen resolution properties to ensure that the system is driving the display at its full resolution? Your symptoms sound to me like it is running at a lower resolution and the display is stretching it to fill the full screen.,0.2012947653214861,False,2,2478 +have any of you had simmilar symptomes? how to deal with it?","So i found the solution of the problem. + It is because when I was plugging the different monitor - for some reason the DPI was changing. Adjusting the settings in the windows display control panel did the thing.",1.2,True,2,2478 2013-04-04 16:59:03.153,weird scalling on displayport monitors in wx.python,"I have been developing a wx.python application. at some point i need to create a fullscreen, no taskbar, etc. wx.Frame which has exactly the size of the screen and display in it a bimap which has exactly the dimensions of the screen, so one pixel of the bitmap equals exactly one pixel of the screen. everything has been working fine (on dvi/vga/hdmi monitors) up to the time when i pluged in displayport monitor. the monitor is detected by wxwidgets to be lower resolution than it actually is, so the bitmap goes off the screen. EDID still detects valid resolution so it is for sure wxwidgets related issue. when i use wx.DisplaySize - it returns lower resolution than is actually set. i also tried to create the bitmap according to the wx.DisplaySize() output but then, as expected, when i try to light up one pixel, its neighbours are changed too. (some sort of scalling occurs). similar issue occurs when i plug a projector. -have any of you had simmilar symptomes? how to deal with it?","So i found the solution of the problem. - It is because when I was plugging the different monitor - for some reason the DPI was changing. Adjusting the settings in the windows display control panel did the thing.",1.2,True,2,2478 +have any of you had simmilar symptomes? how to deal with it?",Correct EDID values does not necessarily mean that the system is running it in that display mode. Have you checked the system's display properties or screen resolution properties to ensure that the system is driving the display at its full resolution? Your symptoms sound to me like it is running at a lower resolution and the display is stretching it to fill the full screen.,0.2012947653214861,False,2,2478 2013-04-04 18:50:18.277,What other alternative are there to stemming?,"Given a list of words like this ['add', 'adds', 'adding', 'added', 'addition'], I want to stem all of them to the same word 'add'. That means stemming all different verb and noun forms of a word (but not its adjective and adverb forms) into one. I couldn't find any stemmer that does that. The closest one I found is PorterStemmer, but it stems the above list to ['add', 'add', 'ad', 'ad', 'addit'] I'm not very experienced with stemming techniques. So, I want to ask if there's any available stemmer that does what I explains above? If not, do you have any suggestion on how to achieve that? Many thanks,","The idea of stemming is to reduce different forms of the same word to a single ""base"" form. That is not what you are asking for, so probably no existing stemmer is (at least not by purpose) fullfilling your needs. So the obvious solution for your problem is: If you have your own custom rules, you have to implement them. You don't tell much about your requirement. Depending on your needs, you have to start from scratch. If porter stemmter comes close to your needs, but not in some special cases, you could hand code some overrides and use an existing stemmer for the other cases.",0.0,False,1,2479 +2013-04-04 20:30:55.023,What's the working directory when using IDLE?,"So, I'm learning Python and would like to create a simple script to download a file from the internet and then write it to a file. However, I am using IDLE and have no idea what the working directory is in IDLE or how to change it. How can I do file system stuff in IDLE if I don't know the working directory or how to change it?","Old question I know but maybe the OP's question was not answered? If you want Idle's File Open/Save/Save As menu items to interact with a particular folder, you need to set the CWD before starting Idle. So, assuming you have a folder on Windows ""C:\Users\Documents\python\my_project"", then at a cmd prompt type cd C:\Users\\Documents\python\my_project and then start Idle",0.0,False,2,2480 2013-04-04 20:30:55.023,What's the working directory when using IDLE?,"So, I'm learning Python and would like to create a simple script to download a file from the internet and then write it to a file. However, I am using IDLE and have no idea what the working directory is in IDLE or how to change it. How can I do file system stuff in IDLE if I don't know the working directory or how to change it?","This will depend on OS and how IDLE is executed. To change the (default) CWD in Windows, right click on the Short-cut Icon, go to ""Properties"" and change ""Start In"".",0.3869120172231254,False,2,2480 -2013-04-04 20:30:55.023,What's the working directory when using IDLE?,"So, I'm learning Python and would like to create a simple script to download a file from the internet and then write it to a file. However, I am using IDLE and have no idea what the working directory is in IDLE or how to change it. How can I do file system stuff in IDLE if I don't know the working directory or how to change it?","Old question I know but maybe the OP's question was not answered? If you want Idle's File Open/Save/Save As menu items to interact with a particular folder, you need to set the CWD before starting Idle. So, assuming you have a folder on Windows ""C:\Users\Documents\python\my_project"", then at a cmd prompt type cd C:\Users\\Documents\python\my_project and then start Idle",0.0,False,2,2480 2013-04-06 20:06:36.410,Django Oscar. How to add product?,"I'm a beginner in Python and Django. I have installed django-oscar. Then I Configured it and started the server, it works. Now, I don't understand how to add a product? @@ -25693,14 +25693,14 @@ Perhaps you can get the right answer if you elaborate more or showing us some of ImportError: No module named icon_rc -I know that I have to compile it using pyrcc4 but I don't understand how to do this can anybody help please. It would be very helpful to have an answer that fully explains how to compile the resource file so I can import it.","In Pyqt5 this command can be used Pyrcc5 input_file.qrc -o Out_file.py -We need to convert that qrc file into python file and then it can be imported to your code",0.3869120172231254,False,2,2483 +I know that I have to compile it using pyrcc4 but I don't understand how to do this can anybody help please. It would be very helpful to have an answer that fully explains how to compile the resource file so I can import it.","you could try with pyside as well like: +--- pyside-rcc -o input.qrc output.py",0.0,False,2,2483 2013-04-07 16:30:16.057,PYQT4 - How do I compile and import a qrc file into my program?,"I'm having trouble importing a resource file. I'm using pyqt4 with monkey studio and I am trying to import a png image. When I run the program I get an import error like ImportError: No module named icon_rc -I know that I have to compile it using pyrcc4 but I don't understand how to do this can anybody help please. It would be very helpful to have an answer that fully explains how to compile the resource file so I can import it.","you could try with pyside as well like: ---- pyside-rcc -o input.qrc output.py",0.0,False,2,2483 +I know that I have to compile it using pyrcc4 but I don't understand how to do this can anybody help please. It would be very helpful to have an answer that fully explains how to compile the resource file so I can import it.","In Pyqt5 this command can be used Pyrcc5 input_file.qrc -o Out_file.py +We need to convert that qrc file into python file and then it can be imported to your code",0.3869120172231254,False,2,2483 2013-04-08 01:58:24.963,How to queue up scheduled actions,"I am trying to set up some scheduled tasks for a Django app with celery, hosted on heroku. Aside from not know how everything should be configured, what is the best way to approach this? Let's say users can opt to receive a daily email at a time of their choosing. Should I have a scheduled job that run every, say 5 minutes. Looks up every user who wants to be emailed at that time and then fire off the emails? @@ -25729,7 +25729,7 @@ And NO it's not the FireWall blocking it. I've tried totally turning Firewall o Here's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from ""edit with IDLE"" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained. Then I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to ""edit with IDLE"" and spent a day trying everything including editing in Regedit. No luck there either. I reinstalled Python 3.3.1 still no ""edit with IDLE"" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" I am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone. Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't. -Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?",Remove copy.py in your folder if you happen to have one,0.0370887312438237,False,11,2488 +Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","Look for files on your main python folder that you may create in names like ""threading.py"", ""tkinter.py"" and other names that overlapps with your Lib folder and move/delete them",0.1834289726823514,False,11,2488 2013-04-08 20:19:01.520,Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection,"Resolved April 15, 2013. In windows 7 (64bit) windows explorer when I right clicked a Python file and selected ""edit with IDLE"" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" error message. All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. Even the ""Send to"" method worked but it was unacceptably clunky. I've spend four days (so far) researching this and trying various things including reinstalling Python many times. @@ -25737,10 +25737,8 @@ And NO it's not the FireWall blocking it. I've tried totally turning Firewall o Here's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from ""edit with IDLE"" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained. Then I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to ""edit with IDLE"" and spent a day trying everything including editing in Regedit. No luck there either. I reinstalled Python 3.3.1 still no ""edit with IDLE"" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" I am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone. Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't. -Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","I came across this problem too. There are two things you can do - -You may already have a process running call pythonw.exe which prevents IDLE from being starting. End that task and try running IDLE again -Use pythonwin or python command line",0.0,False,11,2488 +Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","I had this same problem today. I found another stack overflow post where someone had a tkinter.py file in the same directory as python, and they fixed it by removing that tkinter.py file. When I looked in my python directory, I realized I had created a script called random.py and put it there. I suspect that it conflicted with the normal random module in python. When I removed this file, python started working again. +So I would suggest you look in your main python directory and see if there are any .py files that you could move to different places.",0.4772989762184673,False,11,2488 2013-04-08 20:19:01.520,Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection,"Resolved April 15, 2013. In windows 7 (64bit) windows explorer when I right clicked a Python file and selected ""edit with IDLE"" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" error message. All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. Even the ""Send to"" method worked but it was unacceptably clunky. I've spend four days (so far) researching this and trying various things including reinstalling Python many times. @@ -25748,7 +25746,8 @@ And NO it's not the FireWall blocking it. I've tried totally turning Firewall o Here's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from ""edit with IDLE"" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained. Then I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to ""edit with IDLE"" and spent a day trying everything including editing in Regedit. No luck there either. I reinstalled Python 3.3.1 still no ""edit with IDLE"" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" I am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone. Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't. -Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?",i have the Same issue on os win7 64Bit and Python 3.1 and find a workaround because i have a Project with many .py files and just one gave this error. - Workaround is to copy a working file and copy the contents from not working file to working file. (i used Another editor as idle. The Problem with that workaround is... of you rename the file it doenst work. attention just rename the not working file doesnt work for me. just that copy paste. – john,0.0,False,11,2488 +Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","I had exactly the same issue :""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" +I found the answer from this stackoverflow site. I created a file named string.py and that classhed with the normal python files. I removed the string.py and everything works now. Thanks folks.",0.0370887312438237,False,11,2488 2013-04-08 20:19:01.520,Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection,"Resolved April 15, 2013. In windows 7 (64bit) windows explorer when I right clicked a Python file and selected ""edit with IDLE"" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" error message. All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. Even the ""Send to"" method worked but it was unacceptably clunky. I've spend four days (so far) researching this and trying various things including reinstalling Python many times. @@ -25756,7 +25755,7 @@ And NO it's not the FireWall blocking it. I've tried totally turning Firewall o Here's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from ""edit with IDLE"" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained. Then I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to ""edit with IDLE"" and spent a day trying everything including editing in Regedit. No luck there either. I reinstalled Python 3.3.1 still no ""edit with IDLE"" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" I am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone. Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't. -Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?",Using Windows 7 64 installation of Python 2.7.10 Shell I solved the above problem by opening the program as an administrator.,0.0370887312438237,False,11,2488 +Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?",Adding to existing answers - it is actually possible to have firewall block IDLE when not running with -n flag. I haven't used IDLE for a few months and decided to try if it works properly with newly installed python3.3 (on Linux Mint 13 x86). In between I made iptables setup much more aggressive and apparently it blocked idle-python3.3 from connecting to the Python RPC server. Sometimes it is just what the message says.,0.1108597247651115,False,11,2488 2013-04-08 20:19:01.520,Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection,"Resolved April 15, 2013. In windows 7 (64bit) windows explorer when I right clicked a Python file and selected ""edit with IDLE"" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" error message. All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. Even the ""Send to"" method worked but it was unacceptably clunky. I've spend four days (so far) researching this and trying various things including reinstalling Python many times. @@ -25764,7 +25763,7 @@ And NO it's not the FireWall blocking it. I've tried totally turning Firewall o Here's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from ""edit with IDLE"" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained. Then I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to ""edit with IDLE"" and spent a day trying everything including editing in Regedit. No luck there either. I reinstalled Python 3.3.1 still no ""edit with IDLE"" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" I am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone. Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't. -Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","I finally got it to work when I disabled ALL firewalls and antivirus, because some antivirus ALSO have firewall control. Ex. avast",0.0370887312438237,False,11,2488 +Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?",I had the same error message. Error not seen after I added all the *.exe filea to be found in the Python install directory to the Windows firewall exception list.,0.0370887312438237,False,11,2488 2013-04-08 20:19:01.520,Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection,"Resolved April 15, 2013. In windows 7 (64bit) windows explorer when I right clicked a Python file and selected ""edit with IDLE"" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" error message. All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. Even the ""Send to"" method worked but it was unacceptably clunky. I've spend four days (so far) researching this and trying various things including reinstalling Python many times. @@ -25772,9 +25771,7 @@ And NO it's not the FireWall blocking it. I've tried totally turning Firewall o Here's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from ""edit with IDLE"" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained. Then I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to ""edit with IDLE"" and spent a day trying everything including editing in Regedit. No luck there either. I reinstalled Python 3.3.1 still no ""edit with IDLE"" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" I am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone. Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't. -Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","I'm running Windows 7 64-bit. I saw the same errors today. I tracked down the cause for me, hopefully it'll help you. I had IDLE open in the background for days. Today I tried to run a script in IDLE, and got the ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" errors. So I closed all IDLE windows, and tried to restart IDLE. That then caused the same errors to pop up, and now IDLE wouldn't open successfully. -The cause was an extra pythonw.exe process running in the background. If I open up an instance of IDLE, then open a second, the second has issues connecting, and closes. But it does not close the instances of pythonw.exe that it opened, one is left running in the background. That extra instance then prevents future attempts to open IDLE. -Opening up Task Manager and killing all pythonw.exe processes fixed IDLE, and now it functions properly on my machine (1 instance open at a time though!).",0.3549163626943612,False,11,2488 +Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","I finally got it to work when I disabled ALL firewalls and antivirus, because some antivirus ALSO have firewall control. Ex. avast",0.0370887312438237,False,11,2488 2013-04-08 20:19:01.520,Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection,"Resolved April 15, 2013. In windows 7 (64bit) windows explorer when I right clicked a Python file and selected ""edit with IDLE"" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" error message. All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. Even the ""Send to"" method worked but it was unacceptably clunky. I've spend four days (so far) researching this and trying various things including reinstalling Python many times. @@ -25782,7 +25779,7 @@ And NO it's not the FireWall blocking it. I've tried totally turning Firewall o Here's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from ""edit with IDLE"" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained. Then I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to ""edit with IDLE"" and spent a day trying everything including editing in Regedit. No luck there either. I reinstalled Python 3.3.1 still no ""edit with IDLE"" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" I am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone. Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't. -Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","Look for files on your main python folder that you may create in names like ""threading.py"", ""tkinter.py"" and other names that overlapps with your Lib folder and move/delete them",0.1834289726823514,False,11,2488 +Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?",Using Windows 7 64 installation of Python 2.7.10 Shell I solved the above problem by opening the program as an administrator.,0.0370887312438237,False,11,2488 2013-04-08 20:19:01.520,Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection,"Resolved April 15, 2013. In windows 7 (64bit) windows explorer when I right clicked a Python file and selected ""edit with IDLE"" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" error message. All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. Even the ""Send to"" method worked but it was unacceptably clunky. I've spend four days (so far) researching this and trying various things including reinstalling Python many times. @@ -25790,7 +25787,10 @@ And NO it's not the FireWall blocking it. I've tried totally turning Firewall o Here's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from ""edit with IDLE"" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained. Then I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to ""edit with IDLE"" and spent a day trying everything including editing in Regedit. No luck there either. I reinstalled Python 3.3.1 still no ""edit with IDLE"" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" I am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone. Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't. -Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?",I had the same error message. Error not seen after I added all the *.exe filea to be found in the Python install directory to the Windows firewall exception list.,0.0370887312438237,False,11,2488 +Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","I came across this problem too. There are two things you can do + +You may already have a process running call pythonw.exe which prevents IDLE from being starting. End that task and try running IDLE again +Use pythonwin or python command line",0.0,False,11,2488 2013-04-08 20:19:01.520,Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection,"Resolved April 15, 2013. In windows 7 (64bit) windows explorer when I right clicked a Python file and selected ""edit with IDLE"" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" error message. All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. Even the ""Send to"" method worked but it was unacceptably clunky. I've spend four days (so far) researching this and trying various things including reinstalling Python many times. @@ -25798,7 +25798,7 @@ And NO it's not the FireWall blocking it. I've tried totally turning Firewall o Here's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from ""edit with IDLE"" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained. Then I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to ""edit with IDLE"" and spent a day trying everything including editing in Regedit. No luck there either. I reinstalled Python 3.3.1 still no ""edit with IDLE"" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" I am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone. Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't. -Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?",Adding to existing answers - it is actually possible to have firewall block IDLE when not running with -n flag. I haven't used IDLE for a few months and decided to try if it works properly with newly installed python3.3 (on Linux Mint 13 x86). In between I made iptables setup much more aggressive and apparently it blocked idle-python3.3 from connecting to the Python RPC server. Sometimes it is just what the message says.,0.1108597247651115,False,11,2488 +Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?",Remove copy.py in your folder if you happen to have one,0.0370887312438237,False,11,2488 2013-04-08 20:19:01.520,Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection,"Resolved April 15, 2013. In windows 7 (64bit) windows explorer when I right clicked a Python file and selected ""edit with IDLE"" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" error message. All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. Even the ""Send to"" method worked but it was unacceptably clunky. I've spend four days (so far) researching this and trying various things including reinstalling Python many times. @@ -25806,8 +25806,9 @@ And NO it's not the FireWall blocking it. I've tried totally turning Firewall o Here's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from ""edit with IDLE"" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained. Then I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to ""edit with IDLE"" and spent a day trying everything including editing in Regedit. No luck there either. I reinstalled Python 3.3.1 still no ""edit with IDLE"" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" I am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone. Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't. -Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","I had exactly the same issue :""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" -I found the answer from this stackoverflow site. I created a file named string.py and that classhed with the normal python files. I removed the string.py and everything works now. Thanks folks.",0.0370887312438237,False,11,2488 +Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","I'm running Windows 7 64-bit. I saw the same errors today. I tracked down the cause for me, hopefully it'll help you. I had IDLE open in the background for days. Today I tried to run a script in IDLE, and got the ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" errors. So I closed all IDLE windows, and tried to restart IDLE. That then caused the same errors to pop up, and now IDLE wouldn't open successfully. +The cause was an extra pythonw.exe process running in the background. If I open up an instance of IDLE, then open a second, the second has issues connecting, and closes. But it does not close the instances of pythonw.exe that it opened, one is left running in the background. That extra instance then prevents future attempts to open IDLE. +Opening up Task Manager and killing all pythonw.exe processes fixed IDLE, and now it functions properly on my machine (1 instance open at a time though!).",0.3549163626943612,False,11,2488 2013-04-08 20:19:01.520,Can't run Python via IDLE from Explorer [2013] - IDLE's subprocess didn't make connection,"Resolved April 15, 2013. In windows 7 (64bit) windows explorer when I right clicked a Python file and selected ""edit with IDLE"" the editor opens properly but when I run (or f5) the Python 3.3.1 program, it fails with the ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" error message. All other methods of starting IDLE for running my python 3.3.1 programs worked perfectly. Even the ""Send to"" method worked but it was unacceptably clunky. I've spend four days (so far) researching this and trying various things including reinstalling Python many times. @@ -25815,17 +25816,16 @@ And NO it's not the FireWall blocking it. I've tried totally turning Firewall o Here's an important clue: In the beginning I installed and configured python 3.3 64 bit and everything worked including running from ""edit with IDLE"" but then recently when I needed a library only available in Python 2 I installed python 2.7.4 and from that point on the stated problem began. At one point I completely removed all traces of both versions and reinstalled Python 3.3.1 64 bit. Problem remained. Then I tried have both 32 bit versions installed but still no luck. Then at some point in my muddling around I lost the option to ""edit with IDLE"" and spent a day trying everything including editing in Regedit. No luck there either. I reinstalled Python 3.3.1 still no ""edit with IDLE"" then Finally I uninstalled all versions of Python and I removed python references to environment variables PATH and PYTHONPATH. Then I Deleted all the Python related keys in the windows registry, deleted the C:\python33 directory that the uninstall didn't bother to delete. Overkill, of course, then I restarted windows and installed Python 3.3.1 64 bit version again and thankfully the option to 'edit with IDLE' was back. I was momentarily happy, I opened windows explorer, right clicked on a python program, selected 'edit with IDLE' selected RUN (eyes closed) and you guessed it, same original error message ""IDLE's subprocess didn't make connection. Either IDLE can't start a subprocess or personal firewall software is blocking the connection."" I am completely stuck on this issue and really need help. Pretty sure that you can see I and not a happy camper. And to top it all off, I guess I don't understand StackOverflow yet, I have had this plea for help up in various versions for 5 days and not one response from anyone. Believe me I've looked at every thing in stackoverflow plus other sites and I can't see the answer. Almost seems like I have to answer my own question and post it, trouble is, so far I can't. -Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?","I had this same problem today. I found another stack overflow post where someone had a tkinter.py file in the same directory as python, and they fixed it by removing that tkinter.py file. When I looked in my python directory, I realized I had created a script called random.py and put it there. I suspect that it conflicted with the normal random module in python. When I removed this file, python started working again. -So I would suggest you look in your main python directory and see if there are any .py files that you could move to different places.",0.4772989762184673,False,11,2488 +Anyway, thanks for listening. Yes I'm pretty new to Python but I've been programming and overcoming problems for many years (too many perhaps). anyone? Not personally having someone that is familiar with Python makes this difficult, how can I get in touch with an expert in Python for a quick phone conversation?",i have the Same issue on os win7 64Bit and Python 3.1 and find a workaround because i have a Project with many .py files and just one gave this error. - Workaround is to copy a working file and copy the contents from not working file to working file. (i used Another editor as idle. The Problem with that workaround is... of you rename the file it doenst work. attention just rename the not working file doesnt work for me. just that copy paste. – john,0.0,False,11,2488 2013-04-09 09:51:49.383,Gtalk Service On Google App Engine Using Python,"I searched a lot for built web service like Google Talk, using Google Application Engine and Python. For 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. There 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. -Now I want to perform Oauth authentication in python for gtalk at domain level can anyone tell me how to do this?",I think you are confused. Python runs ON appengine. Also theres a working java xmpp example provided.,0.0,False,2,2489 +Now I want to perform Oauth authentication in python for gtalk at domain level can anyone tell me how to do this?","You can only send messages from your app. There are two options: your_app_id@appspot.com or anything@your_app_id.appspotchat.com. +If 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.",0.0,False,2,2489 2013-04-09 09:51:49.383,Gtalk Service On Google App Engine Using Python,"I searched a lot for built web service like Google Talk, using Google Application Engine and Python. For 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. There 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. -Now I want to perform Oauth authentication in python for gtalk at domain level can anyone tell me how to do this?","You can only send messages from your app. There are two options: your_app_id@appspot.com or anything@your_app_id.appspotchat.com. -If 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.",0.0,False,2,2489 +Now I want to perform Oauth authentication in python for gtalk at domain level can anyone tell me how to do this?",I think you are confused. Python runs ON appengine. Also theres a working java xmpp example provided.,0.0,False,2,2489 2013-04-09 11:16:33.607,Python site packages: How can I maintain for both 2.x and 3.x version,"I understand that we can install different version of Python on a same box - but there are packages that are not supported common to both. So if I have two version of Python(2.x and 3.x) installed how can I automatically have packages deployed correctly for each version of Python using pip?","At least on Arch Linux, and presumably on other distros, there are two separate packages for pip, which if both installed give you two different commands: pip and pip3. Running pip ... will always install to the Python 2 site-packages, and pip3 ... to the Python 3 site-packages. This works both for system-wide packages (running as root) or for installing them into your home directory.",1.2,True,1,2490 2013-04-09 14:02:08.560,matplotlib bar graph black - how do I remove bar borders,I'm using pyplot.bar but I'm plotting so many points that the color of the bars is always black. This is because the borders of the bars are black and there are so many of them that they are all squished together so that all you see is the borders (black). Is there a way to remove the bar borders so that I can see the intended color?,"Set the edgecolor to ""none"": bar(..., edgecolor = ""none"")",1.2,True,1,2491 @@ -25853,13 +25853,13 @@ However, @Ber gave me a good enough answer to start developing my own solution s I'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? To clarify my question: Say 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? -Should 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.","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. -This should also make tweet processing faster (because you only process each tweet once).",0.0,False,2,2493 +Should 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.","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.",0.0,False,2,2493 2013-04-11 21:14:50.750,How do I make sure a twitter bot doesn't retweet the same tweet multiple times?,"I'm writing a simple Twitter bot in Python and was wondering if anybody could answer and explain the question for me. I'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? To clarify my question: Say 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? -Should 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.","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.",0.0,False,2,2493 +Should 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.","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. +This should also make tweet processing faster (because you only process each tweet once).",0.0,False,2,2493 2013-04-12 10:38:47.273,Python async and CPU-bound tasks?,"I have recently been working on a pet project in python using flask. It is a simple pastebin with server-side syntax highlighting support with pygments. Because this is a costly task, I delegated the syntax highlighting to a celery task queue and in the request handler I'm waiting for it to finish. Needless to say this does no more than alleviate CPU usage to another worker, because waiting for a result still locks the connection to the webserver. Despite my instincts telling me to avoid premature optimization like the plague, I still couldn't help myself from looking into async. Async @@ -25968,16 +25968,16 @@ Note: Unlike processId(), pid() returns an integer on Unix and a pointer on Wind I have a website, my users can upload files and from this files I need to create some kind of reports for users. When user upload file it stored on my server where website hosted. File path stored in Django model field. Worker is on another server and i need to get access to my database and procces that file. I know how to use django ORM itself without URLs and other parts of django. My question: If I need to create workers on another server, which use different django models from my website i need to copy all of the models into every worker? For example, one worker proccess file and it need models ""Report"" and ""User"". Other worker do other actions and need ""User"" and ""Link"" models. Everytime i change model in my main website i need to change same models in my workers, also different workers can have same duplicate models. I think it's not good from architecture point. -Any suggestions on how to organize my website and workers?","Why do you really need the exact same models in your workers? You can design the worker to have a different model to perform it's own actions on your data. Just design API's for your data and access it separately from your main site. -If it really necessary, Django app can be shared across multiple projects. So you can just put some generic code in a separate app (like your shared models) and put them in sourcecontrol. After an update in your main website, you can easily update the workers also.",0.0,False,2,2506 -2013-04-17 08:44:18.023,"File upload and store, then proccessing with remote worker","My question is about web application architecture. -I have a website, my users can upload files and from this files I need to create some kind of reports for users. When user upload file it stored on my server where website hosted. File path stored in Django model field. Worker is on another server and i need to get access to my database and procces that file. I know how to use django ORM itself without URLs and other parts of django. -My question: If I need to create workers on another server, which use different django models from my website i need to copy all of the models into every worker? -For example, one worker proccess file and it need models ""Report"" and ""User"". Other worker do other actions and need ""User"" and ""Link"" models. Everytime i change model in my main website i need to change same models in my workers, also different workers can have same duplicate models. I think it's not good from architecture point. Any suggestions on how to organize my website and workers?","There are few interesting options. As example, you can add additional reupload workers step for deploy process. It'll guarantee consistence between deployed application and workers. Using own (rest) api is great idea, i like it even more than sharing models between different beings",0.0,False,2,2506 +2013-04-17 08:44:18.023,"File upload and store, then proccessing with remote worker","My question is about web application architecture. +I have a website, my users can upload files and from this files I need to create some kind of reports for users. When user upload file it stored on my server where website hosted. File path stored in Django model field. Worker is on another server and i need to get access to my database and procces that file. I know how to use django ORM itself without URLs and other parts of django. +My question: If I need to create workers on another server, which use different django models from my website i need to copy all of the models into every worker? +For example, one worker proccess file and it need models ""Report"" and ""User"". Other worker do other actions and need ""User"" and ""Link"" models. Everytime i change model in my main website i need to change same models in my workers, also different workers can have same duplicate models. I think it's not good from architecture point. +Any suggestions on how to organize my website and workers?","Why do you really need the exact same models in your workers? You can design the worker to have a different model to perform it's own actions on your data. Just design API's for your data and access it separately from your main site. +If it really necessary, Django app can be shared across multiple projects. So you can just put some generic code in a separate app (like your shared models) and put them in sourcecontrol. After an update in your main website, you can easily update the workers also.",0.0,False,2,2506 2013-04-17 12:02:54.653,Why are python libraries not supplied as pyc?,"If I am right in understanding, Python compile files are cross platform. So why are most libraries released requiring a build and install? Is it laziness on the part of the distributer, or am I wrong in saying they could simply distribute the pyc files? If this isn't the case, how do I distribute a python script file that has libraries as prerequist without requiring the user to build and install the libraries?","They are cross platform, but not cross-version and not cross-implementation. In other words, different CPython versions could have trouble with one and the same .pyc file. And if you look at other implementations such as PyPy, IronPython, Jython etc., you won't have any luck with .pyc files at all. @@ -25989,20 +25989,20 @@ Any library that strictly requires a build step before it is installed certainly If it makes a difference, I am working in Python.",You can stop redis and replace dump.rdb in /var/lib/redis (or whatever file is in the dbfilename variable in your redis.conf). Then start redis again.,0.3869120172231254,False,1,2508 2013-04-18 17:04:06.800,Escaping dollar sign in ipython notebook,"I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown. ANy ideas on how to get just the dollar sign? -Thanks","If you use $, MathJax won't process it as a delimiter. You should be able to enter that in Markdown. For example, I've used that here: $ This is not math $.",0.3869120172231254,False,4,2509 -2013-04-18 17:04:06.800,Escaping dollar sign in ipython notebook,"I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown. -ANy ideas on how to get just the dollar sign? Thanks",You can escape $ with math mode by using a backslash. Try $\$$,0.5658516464399139,False,4,2509 2013-04-18 17:04:06.800,Escaping dollar sign in ipython notebook,"I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown. ANy ideas on how to get just the dollar sign? -Thanks","I'm aware that this topic is old, but it's still somehow the first google result and its answers are incomplete. -You can also surround the $ with `backticks`, the same way that you would display code in Jupyter. -So $ becomes `$`, and should display without error",0.1731644579931097,False,4,2509 +Thanks","If you use $, MathJax won't process it as a delimiter. You should be able to enter that in Markdown. For example, I've used that here: $ This is not math $.",0.3869120172231254,False,4,2509 2013-04-18 17:04:06.800,Escaping dollar sign in ipython notebook,"I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown. ANy ideas on how to get just the dollar sign? Thanks","Put two backslashes in front of dollar signs. For example: Some prices: \\$3.10, \\$4.25, \\$8.50. (running Jupyter notebook server 5.7.0)",0.9999999999897818,False,4,2509 +2013-04-18 17:04:06.800,Escaping dollar sign in ipython notebook,"I have a markdown cell in iPython that contains four dollar signs. iPython interprets anything between dollar signs as a MathJax expression, which is not what I want. How do I escape the dollar signs? Escaping them with a backslash prevents MathJax from kicking in, but the backslash shows in the compiled Markdown. +ANy ideas on how to get just the dollar sign? +Thanks","I'm aware that this topic is old, but it's still somehow the first google result and its answers are incomplete. +You can also surround the $ with `backticks`, the same way that you would display code in Jupyter. +So $ becomes `$`, and should display without error",0.1731644579931097,False,4,2509 2013-04-18 20:09:11.477,How does find procedure work in python,"I wish to create a 'find' procedure myself, which is capable of finding a sub-string in a string and it also should be able to read a string backward and give position of match- just like the original find function in python. I am unable to figure out what logic should I use- also I don't know how the original find functions? I just started to use python and am fairly new to programming as well. @@ -26089,13 +26089,13 @@ specs Next time the user logs in, you do the same: add his password to user name and salt, hash that, and compare the hash to what's stored. There's no way, even in principle, for you to know what his password was, so no way for an attacker to find it even if they get your database and know your algorithm and salt.",0.1618299653758019,False,1,2517 2013-04-22 13:51:49.267,Python will not run in windows powershell,"I am trying to get python.exe to run in interactive mode in windows powershell. I have added c:\python27 to my PATH and when I type ""python"" in into the shell a new command prompt window opens running python, rather than running within powershell. This is a problem as when I run things like ""python --version"" it launches the new command prompt window and then closes before I can read it. Does anyone know how to get python to run in powershell? Note: this used to work before I started to install pip, easy_install and virtualenv this morning. +Thanks","I just solved this issue after nearly pulling my hair out. Thought I would share. In windows system > advanced system settings > environment variables there are two places to change the PATH, user variables and system variables. I added "";c:\python27"" as the value for PATH in both. It now works",1.2,True,2,2518 +2013-04-22 13:51:49.267,Python will not run in windows powershell,"I am trying to get python.exe to run in interactive mode in windows powershell. I have added c:\python27 to my PATH and when I type ""python"" in into the shell a new command prompt window opens running python, rather than running within powershell. This is a problem as when I run things like ""python --version"" it launches the new command prompt window and then closes before I can read it. Does anyone know how to get python to run in powershell? +Note: this used to work before I started to install pip, easy_install and virtualenv this morning. Thanks","I'm not expert in PS, but when I need to use python in interactive mode in windows powershell, I use something like this (version of python is 2.7.3, I didn't change env variables): PS C:\Python27> ./python Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32 Type ""help"", ""copyright"", ""credits"" or ""license"" for more information.",0.0,False,2,2518 -2013-04-22 13:51:49.267,Python will not run in windows powershell,"I am trying to get python.exe to run in interactive mode in windows powershell. I have added c:\python27 to my PATH and when I type ""python"" in into the shell a new command prompt window opens running python, rather than running within powershell. This is a problem as when I run things like ""python --version"" it launches the new command prompt window and then closes before I can read it. Does anyone know how to get python to run in powershell? -Note: this used to work before I started to install pip, easy_install and virtualenv this morning. -Thanks","I just solved this issue after nearly pulling my hair out. Thought I would share. In windows system > advanced system settings > environment variables there are two places to change the PATH, user variables and system variables. I added "";c:\python27"" as the value for PATH in both. It now works",1.2,True,2,2518 2013-04-22 16:08:44.813,How to make this bot work?,"I got a bot in Python that I've made to simulate a player playing a flash web game. The thing is, I've used an approach that requires specific screen coordinates to work, and there is a pop-up I need to click to advance to the next state that seems to appear in random positions every time it shows up. Do you know how to ""detect"" where the popup is?. Thanks.","I'd try saving the button you have to click as a pic, then scan your entire screen and use PIL to match the pic you saved to the button you have to press; from there you should be able to retrieve the coordinates.",0.3869120172231254,False,1,2519 @@ -26138,10 +26138,6 @@ My basic idea is to show user an error which has error code, descriptions, detai 2013-04-25 19:18:44.700,DateTime field OpenErp,"I need a field that can contain a number and text on it, like for example ""6 months"", i've used the datetime field, but it only takes a formatted date on it, and if use integer or float it takes a number, and char takes only a character, so how can i have an integer and a char on the same field?","What you want currently not possible in openerp. But you can use one trick, you should use two fields one is integer for giving interval and other in char fields for giving months, days etc. You can get this example on Scheduler , ir.cron object of opener.",1.2,True,1,2527 2013-04-26 07:29:53.907,train nltk classifier for just one label,"I am just starting out with nltk, and I am following the book. Chapter six is about text classification, and i am a bit confused about something. In the examples (the names, and movie reviews) the classifier is trained to select between two well-defined labels (male-female, and pos-neg). But how to train if you have only one label. Say I have a bunch of movie plot outlines, and I am only interested in fishing out movies from the sci-fi genre. Can I train a classifier to only recognize sci-fi plots, en say f.i. if classification confidence is > 80%, then put it in the sci-fi group, otherwise, just ignore it. -Hope somebody can clarify, thank you,","You can simply train a binary classifier to distinguish between sci-fi and not sci-fi -So train on the movie plots that are labeled as sci-fi and also on a selection of all other genres. It might be a good idea to have a representative sample of the same size for the other genres such that not all are of the romantic comedy genre, for instance.",1.2,True,2,2528 -2013-04-26 07:29:53.907,train nltk classifier for just one label,"I am just starting out with nltk, and I am following the book. Chapter six is about text classification, and i am a bit confused about something. In the examples (the names, and movie reviews) the classifier is trained to select between two well-defined labels (male-female, and pos-neg). But how to train if you have only one label. -Say I have a bunch of movie plot outlines, and I am only interested in fishing out movies from the sci-fi genre. Can I train a classifier to only recognize sci-fi plots, en say f.i. if classification confidence is > 80%, then put it in the sci-fi group, otherwise, just ignore it. Hope somebody can clarify, thank you,","I see two questions How to train the system? @@ -26149,6 +26145,10 @@ Can the system consist of ""sci-fi"" and ""others""? The answer to 2 is yes. Having a 80% confidence threshold idea also makes sense, as long as you see with your data, features and algorithm that 80% is a good threshold. (If not, you may want to consider lowering it if not all sci-fi movies are being classified as sci-fi, or lowering it, if too many non-sci-fi movies are being categorized as sci-fi.) The answer to 1 depends on the data you have, the features you can extract, etc. Jared's approach seems reasonable. Like Jared, I'd also to emphasize the importance of enough and representative data.",0.0,False,2,2528 +2013-04-26 07:29:53.907,train nltk classifier for just one label,"I am just starting out with nltk, and I am following the book. Chapter six is about text classification, and i am a bit confused about something. In the examples (the names, and movie reviews) the classifier is trained to select between two well-defined labels (male-female, and pos-neg). But how to train if you have only one label. +Say I have a bunch of movie plot outlines, and I am only interested in fishing out movies from the sci-fi genre. Can I train a classifier to only recognize sci-fi plots, en say f.i. if classification confidence is > 80%, then put it in the sci-fi group, otherwise, just ignore it. +Hope somebody can clarify, thank you,","You can simply train a binary classifier to distinguish between sci-fi and not sci-fi +So train on the movie plots that are labeled as sci-fi and also on a selection of all other genres. It might be a good idea to have a representative sample of the same size for the other genres such that not all are of the romantic comedy genre, for instance.",1.2,True,2,2528 2013-04-26 17:09:14.607,Tkinter PhotoImage: References in Memory?,"I have a program that displays many tkinter PhotoImages at once (relevant: I'm not using PIL). It currently has several screens, and when the play gets to the edge it loads a new tilemap, creating a bunch more photoimages in the currentTiles array after clearing the old contents. I'm fairly certain there are no other references to these photoimages in the rest of the program. The weird thing is that when I print the contents of the last item in the array after the loadLevel function is called, it says things such as ""pyimage3761"", and it increments each time I load a new screen. Is this due to tkinter keeping track of how many have been created so far, or is it because the old tiles are still in memory? I can't for the life of me figure out where there could be another reference, so I'm just wondering if there are any other possibilities before I spend hours looking for errors. Thanks!!","Every created image is assigned a unique name (unless you specify the name of the image when creating). This unique name is generated by using a counter, which increases monotonically.",0.6730655149877884,False,1,2529 @@ -26427,10 +26427,10 @@ However, when I type ipython in the terminal I get: I do not understand why this ONLY happens with IPython and not with python? Also, how do I fix this? What path should I add in .bashrc? And how should I add? Currently, my .bashrc reads: PATH=$PATH:/usr/local/bin/ -Thanks!","I had this issue too, the following worked for me and seems like a clean simple solution: -pip uninstall ipython -pip install ipython -I'm running mavericks and latest pip",1.2,True,4,2566 +Thanks!","For me the only thing that helped was: +python -m pip install --upgrade pip +Upgrading pip did the work and all the installations started working properly! +Give it a try.",0.0,False,4,2566 2013-05-25 02:45:56.920,IPython command not found Terminal OSX. Pip installed,"Using Python 2.7 installed via homebrew. I then used pip to install IPython. So, IPython seems to be installed under: /usr/local/lib/python2.7/site-packages/ I think this is true because there is a IPython directory and ipython egg. @@ -26449,8 +26449,10 @@ However, when I type ipython in the terminal I get: I do not understand why this ONLY happens with IPython and not with python? Also, how do I fix this? What path should I add in .bashrc? And how should I add? Currently, my .bashrc reads: PATH=$PATH:/usr/local/bin/ -Thanks!","After trying to a number of solutions like above with out joy, when I restarted my terminal, Ipython command launched. Don't forgot to restart your terminal after all the fiddling! -P.S. I think the brew install Ipython did it ... but can't be sure.",0.0,False,4,2566 +Thanks!","I had this issue too, the following worked for me and seems like a clean simple solution: +pip uninstall ipython +pip install ipython +I'm running mavericks and latest pip",1.2,True,4,2566 2013-05-25 02:45:56.920,IPython command not found Terminal OSX. Pip installed,"Using Python 2.7 installed via homebrew. I then used pip to install IPython. So, IPython seems to be installed under: /usr/local/lib/python2.7/site-packages/ I think this is true because there is a IPython directory and ipython egg. @@ -26459,10 +26461,8 @@ However, when I type ipython in the terminal I get: I do not understand why this ONLY happens with IPython and not with python? Also, how do I fix this? What path should I add in .bashrc? And how should I add? Currently, my .bashrc reads: PATH=$PATH:/usr/local/bin/ -Thanks!","For me the only thing that helped was: -python -m pip install --upgrade pip -Upgrading pip did the work and all the installations started working properly! -Give it a try.",0.0,False,4,2566 +Thanks!","After trying to a number of solutions like above with out joy, when I restarted my terminal, Ipython command launched. Don't forgot to restart your terminal after all the fiddling! +P.S. I think the brew install Ipython did it ... but can't be sure.",0.0,False,4,2566 2013-05-25 07:06:42.807,"Does Apache really ""fork"" in mod_php/python way for request handling?","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"" Q: When apache is running in the mod_python/mod_php mode, then does a ""fork"" happen for each incoming reuest? @@ -26481,8 +26481,6 @@ Yes. Imagine case when, user1 is viewing/editing a object A (retrieved from DB). Most likely the issues will be related to DB. So you can use transactions to help in some cases. In some other cases, you can define strategy. E.g the case mentioned above, when user1 tries to save the object, and its not there in db you can just create one.",1.2,True,1,2568 2013-05-28 00:04:40.997,How To Add An Icon Of My Own To A Python Program,"I am developing a game in Python and was wondering how to give it its own icon. I am using a windows computer and have no extra things installed with Python. Oh also I am using version 3.3 Is this even possible. -P.S I have found other things on Stack Overflow but they are using different Operating Systems like Ubuntu and Macintosh","You can't. In Windows, custom icons can only be assigned to certain types of files (executables and shortcuts, mostly), and Python scripts are not one of those types.",0.0,False,2,2569 -2013-05-28 00:04:40.997,How To Add An Icon Of My Own To A Python Program,"I am developing a game in Python and was wondering how to give it its own icon. I am using a windows computer and have no extra things installed with Python. Oh also I am using version 3.3 Is this even possible. P.S I have found other things on Stack Overflow but they are using different Operating Systems like Ubuntu and Macintosh","If you are trying to change the icon of the shortcut for your program, then you need to get to the file where ever it is right-click it and go to create a shortcut @@ -26498,6 +26496,8 @@ then go to where your desire .ico image is saved and set that as the icon if you do this and you open your program in the corner will be the .ico you selected and on your desktop, it will show the icon instead of the python image. that is how you change the shortcut icon but there is no way to change the actual window icon in the corner unless you're using something like Tk or Pygame.",0.1160922760327606,False,2,2569 +2013-05-28 00:04:40.997,How To Add An Icon Of My Own To A Python Program,"I am developing a game in Python and was wondering how to give it its own icon. I am using a windows computer and have no extra things installed with Python. Oh also I am using version 3.3 Is this even possible. +P.S I have found other things on Stack Overflow but they are using different Operating Systems like Ubuntu and Macintosh","You can't. In Windows, custom icons can only be assigned to certain types of files (executables and shortcuts, mostly), and Python scripts are not one of those types.",0.0,False,2,2569 2013-05-28 05:09:32.590,Counter in OpenErp - Python,"I need a field which adds a counter to a specific item i add in the product section of a custom module. Like an automatic number generated by the system, for let's say Internal Reference, so every time i save a new product this field will create a number for it in this field, like IN0001, IN0002, IN0003, etc... I've looked into the internet, searching for some example on how to achieve this in OpenErp but no luck. @@ -26527,14 +26527,14 @@ We solved the problem: Apparently, there where a lot of fragments / pieces of th So far I see my only option is as follows... Copy the apps to the server which means I have two apps using the same models and now have to maintain two code bases --- bad! So, how do other handle this? What options do I have? -Can my models be shared somehow?","For this to be meaningful, you likely need to connect to the same database -Why would you need two codebases? You have two copies of a single codebase.",0.296905446847765,False,3,2573 +Can my models be shared somehow?","Why don't you run the api on the same server on a different port? that will save you a lot of problems to start with. Sharing database connections cross servers will likely require you to think about security, a lot. +Also if you are reusing the same apps in different projects you might want to package and version your apps for comfort. Think about the real problem you are trying to solve and always keep that in mind. There are plenty of solutions for every problem, finding the right one makes a difference.",0.1016881243684853,False,3,2573 2013-05-30 21:45:23.060,Does a Django site with a Tastypie interface need two codebases?,"I have a Django project with several apps. My project is now getting to the point it needs an API. I'm planning to have the API on a different server using tastypie. However, the API will use the same models as the website. So far I see my only option is as follows... Copy the apps to the server which means I have two apps using the same models and now have to maintain two code bases --- bad! So, how do other handle this? What options do I have? -Can my models be shared somehow?","Why don't you run the api on the same server on a different port? that will save you a lot of problems to start with. Sharing database connections cross servers will likely require you to think about security, a lot. -Also if you are reusing the same apps in different projects you might want to package and version your apps for comfort. Think about the real problem you are trying to solve and always keep that in mind. There are plenty of solutions for every problem, finding the right one makes a difference.",0.1016881243684853,False,3,2573 +Can my models be shared somehow?","For this to be meaningful, you likely need to connect to the same database +Why would you need two codebases? You have two copies of a single codebase.",0.296905446847765,False,3,2573 2013-05-30 21:45:23.060,Does a Django site with a Tastypie interface need two codebases?,"I have a Django project with several apps. My project is now getting to the point it needs an API. I'm planning to have the API on a different server using tastypie. However, the API will use the same models as the website. So far I see my only option is as follows... Copy the apps to the server which means I have two apps using the same models and now have to maintain two code bases --- bad! @@ -26545,9 +26545,9 @@ Is the server the bottleneck? Split site and api machines (but using the same mo Is the DB the bottleneck? Scale up the DB to a faster machine / cluster and use the same site for to supply web and api. Either way, One codebase, One set of models, One DB!",1.2,True,3,2573 2013-05-30 22:37:46.737,Connect Android to Python,"I have an Android application that captures an image and Python code that extracts some features from images. I want to connect them to each other (receive the image in Python from the Android application). I read some things about building a TCP Server, but I don't know how to do it and how to start as it's my first time to do something like that. -Can anyone help?","Well, you could have the Android Application save the image to a folder and have the Python file import that image.",0.2012947653214861,False,2,2574 -2013-05-30 22:37:46.737,Connect Android to Python,"I have an Android application that captures an image and Python code that extracts some features from images. I want to connect them to each other (receive the image in Python from the Android application). I read some things about building a TCP Server, but I don't know how to do it and how to start as it's my first time to do something like that. Can anyone help?","You can upload a image to server using any of the database, use python code on server side and you will get the result.",-0.2012947653214861,False,2,2574 +2013-05-30 22:37:46.737,Connect Android to Python,"I have an Android application that captures an image and Python code that extracts some features from images. I want to connect them to each other (receive the image in Python from the Android application). I read some things about building a TCP Server, but I don't know how to do it and how to start as it's my first time to do something like that. +Can anyone help?","Well, you could have the Android Application save the image to a folder and have the Python file import that image.",0.2012947653214861,False,2,2574 2013-06-01 00:15:42.017,Tcp/IP socket programming in python,"I am currently involved in a project where we performed some computer vision object recognition and classification using python. It is necessary to use photos taken from an Android phone (photos should be automatically sent from android to python). I actually don't know how should I connect both applications (android and python) together. I thought of using TCP Server, but I am new to socket programming and don't know how and where to start. Any one can help?","poof's answer is a good overview, but here are some notes on the various options: Option 1: Have your Android get the picture and do a HTTP POST to a Python application running a framework such as Django. It should be 1 line of code on Android, and only a few lines of code on Python (around your existing code). @@ -26591,6 +26591,11 @@ If you just want to return an HTML file, you could just open it as a normal file Alternatively, as suggested in the comment, you can serve it as a static file.",0.999329299739067,False,1,2580 2013-06-04 10:09:50.767,checking/verifying python code,"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: +Return 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. +Code 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.","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. +Linked 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.",0.0,False,2,2581 +2013-06-04 10:09:50.767,checking/verifying python code,"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: + Return 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. Code 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.","You are right, that's an issue with dynamically typed interpreted languages. There are to important things that can help: @@ -26599,11 +26604,6 @@ Good documentation Extensive unit-testing. They apply to other languages as well of course, but here they are especially important.",0.0,False,2,2581 -2013-06-04 10:09:50.767,checking/verifying python code,"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: - -Return 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. -Code 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.","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. -Linked 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.",0.0,False,2,2581 2013-06-06 00:09:22.573,GDB 7.2 + python: how to get members of anonymous structure?,GDB 7.2 python doesn't have gdb.Type.iteritems method. Anyway I can access the members of the anonymous structure (which is within another structure of course) from gdb 7.2 ? The assumption is that I dont know know the name of the members of the anonymous structure or else I could have done gdb.parse_and_eval on them.,"I think you can use Type.fields to iterate over the fields. Then, you can look at the field offset and you can compute a pointer to the anonymous field, along the lines of (type *) (((char *) obj) + offset). This isn't ideal. There is a bug open to implement something better.",1.2,True,1,2582 @@ -26672,13 +26672,13 @@ I'm using Psycopg2.","Have you looked in to SQLAlchemy at all? It takes care of How do I proceed with my python module called module.py, so I import only the functions I want, when calling 'import module.function'? (so I don't have to import the entire module) Does I always have to create a class for my functions, even if I would never use more than ONE object of that class? (if not, how to create a function that has all the self variables inside, so them don't mess up with global variables from the entire code?) (but without use def fun(self, var1, var2...) because I don't want to call fun("""", var1, var2...) Is it better to 'install' my module or use it like a external file?","You don't necessarily have to create a class in python, but the use of classes would help you wrap up functions and variables into an object.",0.2012947653214861,False,1,2588 -2013-06-10 10:03:50.610,Pay Per Request in Django,"Is it possible to implement this in django: In a video site, for every video a user want to watch he/she must pay a fee before watching the video. If it's possible, what's the best way to implement this. And after every successful payment, how can the user be redirected back to the particular video he paid for?","You can do everything web with Django just like with any other webframework/weblibrary. -Probably the easiest way would be to have a user-profile, and as soon as the payment has been working out you add this video to the users ""allowed"" list. This makes it quite easy to show the users available videos. -The redirection thing after payment really depends on your provider, paypal and others allow you to embed their payment process into your application, and have powerful APIs to check for ""incoming"" payments.",1.2,True,2,2589 2013-06-10 10:03:50.610,Pay Per Request in Django,"Is it possible to implement this in django: In a video site, for every video a user want to watch he/she must pay a fee before watching the video. If it's possible, what's the best way to implement this. And after every successful payment, how can the user be redirected back to the particular video he paid for?","I believe this is possible. What you can do is have a check on your video page for a certain receipt that you can add as an entry in the UserProfile model that you'll have for your django website. Now this receipt will only be generated when your user goes through the complete payment path which you can handle by scripts. And as for redirection, you can have the payment processing service redirect to your receipt token generating django view that handles the addition of the user to your whitelist for that video.",0.0,False,2,2589 +2013-06-10 10:03:50.610,Pay Per Request in Django,"Is it possible to implement this in django: In a video site, for every video a user want to watch he/she must pay a fee before watching the video. If it's possible, what's the best way to implement this. And after every successful payment, how can the user be redirected back to the particular video he paid for?","You can do everything web with Django just like with any other webframework/weblibrary. +Probably the easiest way would be to have a user-profile, and as soon as the payment has been working out you add this video to the users ""allowed"" list. This makes it quite easy to show the users available videos. +The redirection thing after payment really depends on your provider, paypal and others allow you to embed their payment process into your application, and have powerful APIs to check for ""incoming"" payments.",1.2,True,2,2589 2013-06-10 18:41:12.223,"Ipython - Notebook error: Tornado.application : ""Module"" object has no attribute 'XREQ'","I am using python 2.6, ipython 0.12.1, tornado 3.02, pyzmq 13.1 , I am getting this error when I start ipython notebook. ""Websocket connection cannot be made"" In the ipython console window I get torado.application error , in line 183 in create_shell_stream @@ -26707,9 +26707,7 @@ Some clarifications/replies: Regarding the ""you should not do this in general"" replies: The bottom line is that in practice, before I publish a project, I manually go through the library modules and remove unused code. As we are all programmers, we know that there is no reason to do something manually when you could easily explain to a computer how to do it. So practically, writing such a program is possible and should even not be too difficult (yes, it may not be super general). My question was if someone know whether such a tool exists, before I start thinking about implementing it by myself. Also, any thoughts about implementing this are welcome. I do not want to simply hide all my code. If I would have wanted to do that I would have probably not used Python. In fact, I want to publish the source code, but only the code which is relevant to the project in question. -Regarding the ""you are legally protected"" comments: In my specific case, the legal/license protection does not help me. Also, the problem here is more general than some stealing the code. For example, it could be for the sake of clarity: if someone needs to use/develop the code, you don't want dozens of irrelevant functions to be included.","If your purpose is to not give away code, then just distribute the python-compiled library, rather than the source code for it. No need to manually weed code calls, just distribute the pyc versions of your files. If you're afraid that people will take your code and not give you credit, don't give them code if there is an alternative. -That said, we have licenses for a reason. You put the minimal header and your attribution at the top of every file, and you distribute a LICENSE file with your software that clearly indicates what people are, and are not, allowed to do with your source code. If they violate that, and you catch them, you now have legal recourse. IF you don't trust people to uphold that license: that's the whole reason it's there. If your code is so unique that it needs to be licensed for fear of others passing it off as their own, it will be easy to find infractions. If, however, you treat all your code like this, a small reality check: you are not that good. Almost nothing you write will be original enough that others haven't already also written it, trying to cling to it is not going to benefit you, or anyone else. -Best code protection? Stick it online for everyone to see, so that you can point everyone else to it and go ""see? that's my code. And this jerk is using it in their own product without giving me credit"". Worse code protection, but still protection: don't distribute code, distribute the compiled libraries. (Worst code protect: distributing gimped code because you're afraid of the world for the wrong reasons)",-0.1352210990936997,False,2,2593 +Regarding the ""you are legally protected"" comments: In my specific case, the legal/license protection does not help me. Also, the problem here is more general than some stealing the code. For example, it could be for the sake of clarity: if someone needs to use/develop the code, you don't want dozens of irrelevant functions to be included.","I agree with @zmo - one way to avoid future problems like this is to plan ahead and make your code as modular as possible. I would have suggested putting the classes and functions in much smaller files. This would mean that for every project you make, you would have to hand-select which of these smaller files to include. I'm not sure if that's feasible with the size of your projects right now. But for future projects it's a practice you may consider.",0.1352210990936997,False,2,2593 2013-06-13 13:02:48.457,Is there a tool that removes functions that are not used in Python?,"I have the following situation: I am working on several projects which make use of library modules that I have written. The library modules contain several classes and functions. In each project, some subset of the code of the libraries is used. However, when I publish a project for other users, I only want to give away the code that is used by that project rather than the whole modules. This means I would like, for a given project, to remove unused library functions from the library code (i.e. create a new reduced library). Is there any tool that can do this automatically? EDIT @@ -26717,11 +26715,13 @@ Some clarifications/replies: Regarding the ""you should not do this in general"" replies: The bottom line is that in practice, before I publish a project, I manually go through the library modules and remove unused code. As we are all programmers, we know that there is no reason to do something manually when you could easily explain to a computer how to do it. So practically, writing such a program is possible and should even not be too difficult (yes, it may not be super general). My question was if someone know whether such a tool exists, before I start thinking about implementing it by myself. Also, any thoughts about implementing this are welcome. I do not want to simply hide all my code. If I would have wanted to do that I would have probably not used Python. In fact, I want to publish the source code, but only the code which is relevant to the project in question. -Regarding the ""you are legally protected"" comments: In my specific case, the legal/license protection does not help me. Also, the problem here is more general than some stealing the code. For example, it could be for the sake of clarity: if someone needs to use/develop the code, you don't want dozens of irrelevant functions to be included.","I agree with @zmo - one way to avoid future problems like this is to plan ahead and make your code as modular as possible. I would have suggested putting the classes and functions in much smaller files. This would mean that for every project you make, you would have to hand-select which of these smaller files to include. I'm not sure if that's feasible with the size of your projects right now. But for future projects it's a practice you may consider.",0.1352210990936997,False,2,2593 +Regarding the ""you are legally protected"" comments: In my specific case, the legal/license protection does not help me. Also, the problem here is more general than some stealing the code. For example, it could be for the sake of clarity: if someone needs to use/develop the code, you don't want dozens of irrelevant functions to be included.","If your purpose is to not give away code, then just distribute the python-compiled library, rather than the source code for it. No need to manually weed code calls, just distribute the pyc versions of your files. If you're afraid that people will take your code and not give you credit, don't give them code if there is an alternative. +That said, we have licenses for a reason. You put the minimal header and your attribution at the top of every file, and you distribute a LICENSE file with your software that clearly indicates what people are, and are not, allowed to do with your source code. If they violate that, and you catch them, you now have legal recourse. IF you don't trust people to uphold that license: that's the whole reason it's there. If your code is so unique that it needs to be licensed for fear of others passing it off as their own, it will be easy to find infractions. If, however, you treat all your code like this, a small reality check: you are not that good. Almost nothing you write will be original enough that others haven't already also written it, trying to cling to it is not going to benefit you, or anyone else. +Best code protection? Stick it online for everyone to see, so that you can point everyone else to it and go ""see? that's my code. And this jerk is using it in their own product without giving me credit"". Worse code protection, but still protection: don't distribute code, distribute the compiled libraries. (Worst code protect: distributing gimped code because you're afraid of the world for the wrong reasons)",-0.1352210990936997,False,2,2593 2013-06-13 17:27:57.237,Get raw query string in flask,"Is there a way to get the raw query string or a list of query string parameters in Flask? I know how to get query string parameters with request.args.get('key'), but I would like to be able to take in variable query strings and process them myself. Is this possible?",request.query_string also seems to work.,0.9866142981514304,False,1,2594 -2013-06-14 16:55:02.320,How to shut down a minecraft server with python?,"I have multiple minecraft servers running on the machine. servers are started with bat files that have according titles. My question is that, how can i shut down a certain minecraft server with python? Or how to kill a titled cmd.exe process with python?","I would look at the tools in the os module, it would also help if i had more information about what operating system you are using.",0.0,False,2,2595 2013-06-14 16:55:02.320,How to shut down a minecraft server with python?,"I have multiple minecraft servers running on the machine. servers are started with bat files that have according titles. My question is that, how can i shut down a certain minecraft server with python? Or how to kill a titled cmd.exe process with python?",I ended up using autohotkey. launched autohotkey with python and made separate .ahk files for every server.,0.0,False,2,2595 +2013-06-14 16:55:02.320,How to shut down a minecraft server with python?,"I have multiple minecraft servers running on the machine. servers are started with bat files that have according titles. My question is that, how can i shut down a certain minecraft server with python? Or how to kill a titled cmd.exe process with python?","I would look at the tools in the os module, it would also help if i had more information about what operating system you are using.",0.0,False,2,2595 2013-06-14 16:55:55.587,Finding log-likelihood in a restricted boltzmann machine,"I have been researching RBMs for a couple months, using Python along the way, and have read all your papers. I am having a problem, and I thought, what the hey? Why not go to the source? I thought I would at least take the chance you may have time to reply. My question is regarding the Log-Likelihood in a Restricted Boltzmann Machine. I have read that finding the exact log-likelihood in all but very small models is intractable, hence the introduction of contrastive divergence, PCD, pseudo log-likelihood etc. My question is, how do you find the exact log-likelihood in even a small model? I have come across several definitions of this formula, and all seem to be different. In Tielemen’s 2008 paper “Training Restricted Boltzmann Machines using Approximations To the Likelihood Gradient”, he performs a log-likelihood version of the test to compare to the other types of approximations, but does not say the formula he used. The closest thing I can find is the probabilities using the energy function over the partition function, but I have not been able to code this, as I don’t completely understand the syntax. @@ -26737,29 +26737,6 @@ The problem is that this is exponential in v. If v > h, just ""transpose"" your 2013-06-14 20:24:51.877,how to access my 127.0.0.1:8000 from android tablet,"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. I have samsung tab 2 10.1 with android 4.0.4. -appreciate any help, thanks","If both are connected to the same network, all you need to do is provide the IP address of your server (in your network) in your Android app.",0.0453204071731508,False,6,2597 -2013-06-14 20:24:51.877,how to access my 127.0.0.1:8000 from android tablet,"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. -i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. -I have samsung tab 2 10.1 with android 4.0.4. -appreciate any help, thanks","127.0.0.1 is a loopback address that means, roughly, ""this device""; your PC and your android tablet are separate devices, so each of them has its own 127.0.0.1. In other words, if you try to go to 127.0.0.1 on your Android tab, it's trying to connect to a webserver on the Android device, which is not what you want. -However, you should be able to connect over the wifi. On your windows box, open a command prompt and execute ipconfig. Somewhere in the output should be your windows box's address, probably 192.168.1.100 or something similar. You tablet should be able to see the Django server at that address.",0.2655860252697744,False,6,2597 -2013-06-14 20:24:51.877,how to access my 127.0.0.1:8000 from android tablet,"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. -i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. -I have samsung tab 2 10.1 with android 4.0.4. -appreciate any help, thanks","You can find out what the ip address of your PC is with the ipconfig command in a Windows command prompt. Since you mentioned them being connected over WiFi look for the IP address of the wireless adapter. -Since the tablet is also in this same WiFi network, you can just type that address into your tablet's browser, with the :8000 appended to it and it should pull up the page.",1.2,True,6,2597 -2013-06-14 20:24:51.877,how to access my 127.0.0.1:8000 from android tablet,"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. -i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. -I have samsung tab 2 10.1 with android 4.0.4. -appreciate any help, thanks","need to know the ip address of your machine .. -Make sure both of your machines (tablet and computer) connected to same network -192.168.0.22 - say your machine address -do this : -192.168.0.22:8000 -- from your tablet -this is it !!!",0.0453204071731508,False,6,2597 -2013-06-14 20:24:51.877,how to access my 127.0.0.1:8000 from android tablet,"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. -i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. -I have samsung tab 2 10.1 with android 4.0.4. appreciate any help, thanks","Though this thread was active quite a long time ago. This is what worked for me on windows 10. Posting it in details. Might be helpful for the newbies like me. Add ALLOWED_HOSTS = ['*'] in django settings.py file @@ -26795,6 +26772,29 @@ python manage.py runserver then connect both tablet and system to same wifi and browse in the address eg: python manage.py runserver 192.168.0.100:8000 In tablet type that url in adress bar",0.0,False,6,2597 +2013-06-14 20:24:51.877,how to access my 127.0.0.1:8000 from android tablet,"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. +i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. +I have samsung tab 2 10.1 with android 4.0.4. +appreciate any help, thanks","need to know the ip address of your machine .. +Make sure both of your machines (tablet and computer) connected to same network +192.168.0.22 - say your machine address +do this : +192.168.0.22:8000 -- from your tablet +this is it !!!",0.0453204071731508,False,6,2597 +2013-06-14 20:24:51.877,how to access my 127.0.0.1:8000 from android tablet,"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. +i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. +I have samsung tab 2 10.1 with android 4.0.4. +appreciate any help, thanks","You can find out what the ip address of your PC is with the ipconfig command in a Windows command prompt. Since you mentioned them being connected over WiFi look for the IP address of the wireless adapter. +Since the tablet is also in this same WiFi network, you can just type that address into your tablet's browser, with the :8000 appended to it and it should pull up the page.",1.2,True,6,2597 +2013-06-14 20:24:51.877,how to access my 127.0.0.1:8000 from android tablet,"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. +i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. +I have samsung tab 2 10.1 with android 4.0.4. +appreciate any help, thanks","127.0.0.1 is a loopback address that means, roughly, ""this device""; your PC and your android tablet are separate devices, so each of them has its own 127.0.0.1. In other words, if you try to go to 127.0.0.1 on your Android tab, it's trying to connect to a webserver on the Android device, which is not what you want. +However, you should be able to connect over the wifi. On your windows box, open a command prompt and execute ipconfig. Somewhere in the output should be your windows box's address, probably 192.168.1.100 or something similar. You tablet should be able to see the Django server at that address.",0.2655860252697744,False,6,2597 +2013-06-14 20:24:51.877,how to access my 127.0.0.1:8000 from android tablet,"I am developing a webpage in django (on my pc with windows 7) and now i need to test some pages in tablet pcs. suddenly the thought came if i can have an access to my localhost in windows from android tablet. is that possible? I am in the same wifi connection in both devices at home. +i read a lot questions and answers regarding this issue in stackoverflow and other places, but none of them gave me some concrete solutions. +I have samsung tab 2 10.1 with android 4.0.4. +appreciate any help, thanks","If both are connected to the same network, all you need to do is provide the IP address of your server (in your network) in your Android app.",0.0453204071731508,False,6,2597 2013-06-15 09:46:38.787,(python) How to create static text in curses,"I am creating a text adventure. How could I to add static text to this. What i mean is some text that always stays on the left side of the window. Even if all the other text is scrolling down. Also how could i make this text red.","You create static text by putting it in a separate window. Create a window large enough for all the text, and then create a smaller window for the dynamic text. Text is colored by passing the various COLOR_* constants as the text attribute.",0.0,False,1,2598 2013-06-15 10:10:51.120,how to find out exactly from where print is being executed,"This application I am working on (GUI based), has well over a dozen modules. On running the application and using it, there is this particular action(clicking a label) upon which I get tons of empty prints in the stdout and because of which I suspect the application's performance is suffering. Now the problem is I am unable to find out exactly which print statement is causing this to happen. @@ -26846,11 +26846,11 @@ And, of course, Google.",0.1016881243684853,False,2,2601 The code I used is: :csv2.to_excel(""C:\\Users\\shruthi.sundaresan\\Desktop\\csat1.xls"",sheet_name='SAC_STORE_DATA',index=False). csv2 is the dataframe. Why does this kind of error happens and how to avoid this is in the future?",The problem you are facing is that your excel has a character that cannot be decoded to unicode. It was probably working before but maybe you edited this xls file somehow in Excel/Libre. You just need to find this character and either get rid of it or replace it with the one that is acceptable.,0.0,False,1,2602 +2013-06-17 07:00:53.610,Round a floating-point number down to the nearest integer?,"I want to take a floating-point number and round it down to the nearest integer. However, if it's not a whole, I always want to round down the variable, regardless of how close it is to the next integer up. Is there a way to do this?",Just make round(x-0.5) this will always return the next rounded down Integer value of your Float. You can also easily round up by do round(x+0.5),0.1016881243684853,False,3,2603 2013-06-17 07:00:53.610,Round a floating-point number down to the nearest integer?,"I want to take a floating-point number and round it down to the nearest integer. However, if it's not a whole, I always want to round down the variable, regardless of how close it is to the next integer up. Is there a way to do this?","Don't know if you solved this, but I just stumble upon this question. If you want to get rid of decimal points, you could use int(x) and it will eliminate all decimal digits. Theres no need to use round(x).",0.0340004944420038,False,3,2603 2013-06-17 07:00:53.610,Round a floating-point number down to the nearest integer?,"I want to take a floating-point number and round it down to the nearest integer. However, if it's not a whole, I always want to round down the variable, regardless of how close it is to the next integer up. Is there a way to do this?","I used this code where you subtract 0.5 from the number and when you round it, it is the original number rounded down. round(a-0.5)",-0.2012947653214861,False,3,2603 -2013-06-17 07:00:53.610,Round a floating-point number down to the nearest integer?,"I want to take a floating-point number and round it down to the nearest integer. However, if it's not a whole, I always want to round down the variable, regardless of how close it is to the next integer up. Is there a way to do this?",Just make round(x-0.5) this will always return the next rounded down Integer value of your Float. You can also easily round up by do round(x+0.5),0.1016881243684853,False,3,2603 2013-06-18 02:12:44.600,Is there any simple way to store the user location while registering in database,"I have the user registration form made in django. I want to know the city from which the user is registering. Is there any way that i get the IP address of the user and then somehow get the city for that IP. using some API or something","Not in any reliable way, or at least not in Django. The problem is that user IPs are usually dynamic, hence the address is changing every couple of days. Also some ISPs soon will start to use a single IP for big blocks of users (forgot what this is called) since they are running out of IPv4 IP addresses... In other words, all users from that ISP within a whole state or even country will have a single IP address. @@ -26869,13 +26869,13 @@ So, the IE didn't provide the API for developer to access the Product ID, and I If the program doesnt provide an api then its not possible to interact with the program unless you get the output from a browser or you may use programs like Sikuli and obtain the info for example by image processing",0.0,False,1,2606 2013-06-19 06:25:14.113,how to remove task from celery with redis broker?,"I Have add some wrong task to a celery with redis broker but now I want to remove the incorrect task and I can't find any way to do this +Is there some commands or some api to do this ?",try to remove the .state file and if you are using a beat worker (celery worker -B) then remove the schedule file as well,0.0,False,2,2607 +2013-06-19 06:25:14.113,how to remove task from celery with redis broker?,"I Have add some wrong task to a celery with redis broker +but now I want to remove the incorrect task and I can't find any way to do this Is there some commands or some api to do this ?","The simplest way is to use the celery control revoke [id1 [id2 [... [idN]]]] (do not forget to pass the -A project.application flag too). Where id1 to idN are task IDs. However, it is not guaranteed to succeed every time you run it, for valid reasons... Sure Celery has API for it. Here is an example how to do it from a script: res = app.control.revoke(task_id, terminate=True) In the example above app is an instance of the Celery application. In some rare ocasions the control command above will not work, in which case you have to instruct Celery worker to kill the worker process: res = app.control.revoke(task_id, terminate=True, signal='SIGKILL')",0.2401167094949473,False,2,2607 -2013-06-19 06:25:14.113,how to remove task from celery with redis broker?,"I Have add some wrong task to a celery with redis broker -but now I want to remove the incorrect task and I can't find any way to do this -Is there some commands or some api to do this ?",try to remove the .state file and if you are using a beat worker (celery worker -B) then remove the schedule file as well,0.0,False,2,2607 2013-06-20 09:13:40.570,to measure Contact Angle between 2 edges in an image,i need to find out contact angle between 2 edges in an image using open cv and python so can anybody suggest me how to find it? if not code please let me know algorithm for the same.,"Simplify edge A and B into a line equation (using only the few last pixels) Get the line equations of the two lines (form y = mx + b) Get the angle orientations of the two lines θ=atan|1/m| @@ -27072,12 +27072,12 @@ The connection can time out, of course, but it won't be closed or cleaned up wit 2013-07-03 11:26:54.530,How to create field through func in openerp?,Hi I have created a button oin my custom openerp module. I wanted to add func to this button to create a field. I have added the function but how to add functionality for creating fields . please help,"You can create field on function, you have to create field in object 'ir.model.fields' if you are create simple field like float. char, boolean then you have to give value Field Name, Label, Model, for which object you want to create field , if many2one or many2many field then you have to give Object Relation field to. Hope this help",0.0,False,1,2631 +2013-07-03 15:18:14.487,"When using magic %paste in ipython, how can i get it to just paste the copied code, rather than paste and execute, so that it can be edited","When using magic %paste in ipython, it executes pasted code, rather than just pasting. How can i get it to just paste the copied code so that it can be edited?","There is a solution for this issue in ipython, if you are not concerned with indentation, +Just run %autoindent to Automatic indentation OFF.",0.3869120172231254,False,2,2632 2013-07-03 15:18:14.487,"When using magic %paste in ipython, how can i get it to just paste the copied code, rather than paste and execute, so that it can be edited","When using magic %paste in ipython, it executes pasted code, rather than just pasting. How can i get it to just paste the copied code so that it can be edited?","You have two options: To edit it by hand, run %cpaste. Then you can paste it in with standard terminal options (try Ctrl-Shift-V), and edit it. Enter -- on a line to finish. To change it as text in your code, run %paste foo. It will store the clipboard contents in foo.",0.6730655149877884,False,2,2632 -2013-07-03 15:18:14.487,"When using magic %paste in ipython, how can i get it to just paste the copied code, rather than paste and execute, so that it can be edited","When using magic %paste in ipython, it executes pasted code, rather than just pasting. How can i get it to just paste the copied code so that it can be edited?","There is a solution for this issue in ipython, if you are not concerned with indentation, -Just run %autoindent to Automatic indentation OFF.",0.3869120172231254,False,2,2632 2013-07-03 19:09:23.743,Python Matching License Plates,"I am working on a traffic study and I have the following problem: I have a CSV file that contains time-stamps and license plate numbers of cars for a location and another CSV file that contains the same thing. I am trying to find matching license plates between the two files and then find the time difference between the two. I know how to match strings but is there a way I can find matches that are close maybe to detect user input error of the license plate number? Essentially the data looks like the following: @@ -27220,9 +27220,9 @@ Even better if you call SetInsertionPointEnd() on your text control before the t 2013-07-08 21:36:35.510,How can i reduce memory usage of Scikit-Learn Vectorizers?,"TFIDFVectorizer takes so much memory ,vectorizing 470 MB of 100k documents takes over 6 GB , if we go 21 million documents it will not fit 60 GB of RAM we have. So we go for HashingVectorizer but still need to know how to distribute the hashing vectorizer.Fit and partial fit does nothing so how to work with Huge Corpus?",One way to overcome the inability of HashingVectorizer to account for IDF is to index your data into elasticsearch or lucene and retrieve termvectors from there using which you can calculate Tf-IDF.,0.2012947653214861,False,1,2647 2013-07-09 03:31:21.223,How to insert a table inside a frame?,"I have a frame with buttons and plotting options and wanted to include a table as well in that frame. Is there any example or suggestion on how to do it? -Thanks.","You would use a wx.grid.Grid in most cases. You could use a wx.ListCtrl or an ObjectListView widget too. The idea is to put the widgets inside of sizers. So you could have a top level BoxSizer in vertical orientation that contains another sizer or sizers. In this case, I would create a sizer to hold the buttons and nest that sizer in the top level sizer. Then add the table (i.e. grid) to the top level sizer and you're done.",0.0,False,2,2648 -2013-07-09 03:31:21.223,How to insert a table inside a frame?,"I have a frame with buttons and plotting options and wanted to include a table as well in that frame. Is there any example or suggestion on how to do it? Thanks.",The wxpython demo is full of examples of all differant controls.,0.0,False,2,2648 +2013-07-09 03:31:21.223,How to insert a table inside a frame?,"I have a frame with buttons and plotting options and wanted to include a table as well in that frame. Is there any example or suggestion on how to do it? +Thanks.","You would use a wx.grid.Grid in most cases. You could use a wx.ListCtrl or an ObjectListView widget too. The idea is to put the widgets inside of sizers. So you could have a top level BoxSizer in vertical orientation that contains another sizer or sizers. In this case, I would create a sizer to hold the buttons and nest that sizer in the top level sizer. Then add the table (i.e. grid) to the top level sizer and you're done.",0.0,False,2,2648 2013-07-09 11:05:17.210,"How to build python 3.3.2 with _bz2, _sqlite and _ssl from source","I want to build Python 3.3.2 from scratch on my SLE 11 (OpenSUSE). During the compilation of Python I got the message that the modules _bz2, _sqlite and _ssl have not been compiled. I looked for solutions with various search engines. It is often said that you have to install the -dev packages with your package management system, but I have no root access. @@ -27365,16 +27365,16 @@ Any help is appreciated, thanks.","You need a server in order to be able to rece 2013-07-15 04:31:37.233,the idea behind chat website,"I've been learning about Python socket, http request/reponse handling these days, I'm still very novice to server programming, I have a question regarding to the fundamental idea behind chatting website. In chatting website, like Omegle or Facebook's chat, how do 2 guys talk to each other? Do sockets on their own computers directly connect to each other, OR... guy A send a message to the web server, and server send this message to guy B, and vice versa? Because in the first scenario, both users can retrieve each other's IP, and in the second scenario, since you are connecting to a server, you can not.. right? +Thanks a lot to clear this confusion for me, I'm very new and I really appreciate any help from you guys!","Most chats will use a push notification system. It will keep track of people within a chat, and as it receives a new message to the chat, it will push it to all the people currently in it. This protects the users from seeing each other.",0.0,False,2,2665 +2013-07-15 04:31:37.233,the idea behind chat website,"I've been learning about Python socket, http request/reponse handling these days, I'm still very novice to server programming, I have a question regarding to the fundamental idea behind chatting website. +In chatting website, like Omegle or Facebook's chat, how do 2 guys talk to each other? Do sockets on their own computers directly connect to each other, OR... guy A send a message to the web server, and server send this message to guy B, and vice versa? +Because in the first scenario, both users can retrieve each other's IP, and in the second scenario, since you are connecting to a server, you can not.. right? Thanks a lot to clear this confusion for me, I'm very new and I really appreciate any help from you guys!","Usually they both connect to the server. There are a few reasons to do it this way. For example, imagine you want your users to see the last 10 messages of a conversation. Who's going to store this info? One client? Both? What happens if they use more than one PC/device? What happens if one of them is offline? Well, you will have to send the messages to the server, this way the server will have the conversation history stored, always available. Another reason, imagine that one user is offline. If the user is offline you can't do anything to contact him. You can't connect. So you will have to send messages to the server, and the server will notify the user once online. So you are probably going to need a connection to the server (storing common info, providing offline messages, keeping track of active users...). There is also another reason, if you want two users to connect directly, you need one of them to start a server listening on a (public IP):port, and let the other connect against that ip:port. Well, this is a problem. If you use the clients->server model you don't have to worry about that, because you can open a port in the server easily, for all, without routers and NAT in between.",1.2,True,2,2665 -2013-07-15 04:31:37.233,the idea behind chat website,"I've been learning about Python socket, http request/reponse handling these days, I'm still very novice to server programming, I have a question regarding to the fundamental idea behind chatting website. -In chatting website, like Omegle or Facebook's chat, how do 2 guys talk to each other? Do sockets on their own computers directly connect to each other, OR... guy A send a message to the web server, and server send this message to guy B, and vice versa? -Because in the first scenario, both users can retrieve each other's IP, and in the second scenario, since you are connecting to a server, you can not.. right? -Thanks a lot to clear this confusion for me, I'm very new and I really appreciate any help from you guys!","Most chats will use a push notification system. It will keep track of people within a chat, and as it receives a new message to the chat, it will push it to all the people currently in it. This protects the users from seeing each other.",0.0,False,2,2665 2013-07-15 19:54:33.090,Gathering information from few forms in django,"I am creating simple search engine, so I have one input text field on the top of the page and buttom ""search"" next to it. That is all in one form, and ""produce"" for instance/q=search%20query. In sidebar I have panel with another form with filters, lets say from, to. I want to have a possibility of creating link like /q=search%20query&from=20&to=50. I wonder how button from first form should gather information from second form. I read somewhere that there is something like formsets, however I didn't find information that they can be used to something like that.","I just come up with an idea, that I can create in first form additional hidden fields, which can be synchronized with fields from second form by JavaScript. This will create small redundancy, however seems to be very easy to implement. @@ -27443,6 +27443,7 @@ Added Comments to the answer to preserve them: So at 741 lines, I'll take that as a yes to OOP:) So specifically on the data class. Is it correct to create a new instance of the data class 20x per second as data strings come in, or is it more appropriate to append to some data list of an existing instance of the class? Or is there no clear preference either way? – TimoB I would append/extend your existing instance. – seth I think I see the light now. I can instantiate the data class when the ""start data"" button is pressed, and append to that instance in the subsequent thread that does the serial reading. THANKS! – TimoB",0.6730655149877884,False,1,2673 +2013-07-17 20:37:46.960,how make a datetime object in year 0 with python,Exactly what the title says. If I try to it gives me a ValueError for the year value but I'd like to have a datetime with year 0. Is there any way to do this?,I don't think there is any way to do this. datetime.datetime.min says 1 is the min value for year.,0.0,False,2,2674 2013-07-17 20:37:46.960,how make a datetime object in year 0 with python,Exactly what the title says. If I try to it gives me a ValueError for the year value but I'd like to have a datetime with year 0. Is there any way to do this?,"from the docs The datetime module exports the following constants: @@ -27450,7 +27451,6 @@ datetime.MINYEAR The smallest year number allowed in a date or datetime object. MINYEAR is 1. datetime.MAXYEAR The largest year number allowed in a date or datetime object. MAXYEAR is 9999.",0.6730655149877884,False,2,2674 -2013-07-17 20:37:46.960,how make a datetime object in year 0 with python,Exactly what the title says. If I try to it gives me a ValueError for the year value but I'd like to have a datetime with year 0. Is there any way to do this?,I don't think there is any way to do this. datetime.datetime.min says 1 is the min value for year.,0.0,False,2,2674 2013-07-17 21:53:40.627,Concurrent Remote Procedure Calls to C++ Object,"I would like to have a class written in C++ that acts as a remote procedure call server. I have a large (over a gigabyte) file that I parse, reading in parameters to instantiate objects which I then store in a std::map. I would like the RPC server to listen for calls from a client, take the parameters passed from the client, look up an appropriate value in the map, do a calculation, and return the calculated value back to the client, and I want it to serve concurrent requests -- so I'd like to have multiple threads listening. BTW, after the map is populated, it does not change. The requests will only read from it. I'd like to write the client in Python. Could the server just be an HTTP server that listens for POST requests, and the client can use urllib to send them? @@ -27653,13 +27653,13 @@ However, I found myself in situations where it is not clear for me to build a re So I have to get the '190' from the whole HTML document. I could write a regex for that, although regex for parsing HTML is not exactly the best, or that is what I always understood. On the other hand, using DOM seems overwhelming for me as it is just a simple element. String manipulation seems to be the best way, but I am not really sure if I should proceed like that in such a similar case. Can you tell me how would you parse these kind of single elements from a HTML document using Python (or any other language)?","People shy away from doing regexes to search HTML because it isn't the right tool for the job when parsing tags. But everything should be considered on a case-by-case basis. You aren't searching for tags, you are searching for a well-defined string in a document. It seems to me the simplest solution is just a regex or some sort of XPath expression -- simple parsing requires simple tools.",0.3869120172231254,False,1,2705 +2013-08-05 04:50:35.980,how to set name of a field dynamically in openerp?,"Hi I am working on an openerp module . I want to make a field dynamically . I want to take a name of a field from user and then create a field to it . How this can be done ? Can I do it with fields.function to return name, char type ? Plz help","You can create Fields Dynamically by the help of class self.pool.get('ir.model.fields') +Use Create Function.",0.0,False,2,2706 2013-08-05 04:50:35.980,how to set name of a field dynamically in openerp?,"Hi I am working on an openerp module . I want to make a field dynamically . I want to take a name of a field from user and then create a field to it . How this can be done ? Can I do it with fields.function to return name, char type ? Plz help","Do you mean you want a dynamic field on the form/tree view or in the model? If it is in the view then you override fields_view_get, call super and then process the returned XML for the form type you want adding in the field or manipulating the XML. ElementTree is your friend here. If you are talking about having a dynamic database field, I don't think you can and OpenERP creates a registry for each database when that database is first accessed and this process performs database refactoring at that time. The registry contains the singleton model instances you get with self.pool.get... To achieve this you will need to create some kind of generic field like field1 and then in fields_view_get change the string attribute to give it a dynamic label. Actually, a plan C occurs to me. You could create a properties type of table, use a functional field to read the value for the current user and override fields_view_get to do the form.",0.3869120172231254,False,2,2706 -2013-08-05 04:50:35.980,how to set name of a field dynamically in openerp?,"Hi I am working on an openerp module . I want to make a field dynamically . I want to take a name of a field from user and then create a field to it . How this can be done ? Can I do it with fields.function to return name, char type ? Plz help","You can create Fields Dynamically by the help of class self.pool.get('ir.model.fields') -Use Create Function.",0.0,False,2,2706 2013-08-05 18:34:41.497,How could i totally secure a connection between two nodes?,"I'm building an authentication server in python and was wondering about how I could secure a connection totally between two peers totally? I cannot see how in any way a malicious user wouldn't be able to copy packets and simply analyze them if he understands what comes in which order. Admitting a client server schema. Client asks for an Account. Even though SRP, packets can be copied and sent later on to allow login. Then now, if I add public - private key encryption, how do I send the public key to each other without passing them in an un-encrypted channel? @@ -27699,7 +27699,7 @@ Update: Based on your comment that you are using Twisted, I will ask you a quest 2013-08-06 11:48:43.437,How to either sort a wxsizer or remove items without destroying them?,"I have a wxpython grid sizer that is sizing sublists of bitmap buttons. The master list I would like to create just once because creating these buttons takes a considerable amount of time, and thus I do not want to destroy them. My idea is to somehow remove all of the buttons from the sizer, make a new list of the buttons that I want the sizer to contain, and then use the sizer's AddMany method. If I can't remove the buttons from the sizer without destroying them, then is there a way to use the sizer's Show method to hide some of the times, but then have the sizer adjust to fill in the gaps? When I hide them, all I can get them to do right now is just to have them disappear and leave a gap. I need the next item to be adjusted to the gap's place. Also is there a way to sort the grid sizer's item list? -Thanks for any help you can offer.","You should be able to call the Layout method on the parent of the sizer, this will make it recalculate the shown items.",0.0,False,3,2711 +Thanks for any help you can offer.","So I found out that the detach method is what I'm looking for! I would still be interested to know of a way to sort a sizer's item list though, without detaching all of the items and then re attaching a sublist.",0.0,False,3,2711 2013-08-06 11:48:43.437,How to either sort a wxsizer or remove items without destroying them?,"I have a wxpython grid sizer that is sizing sublists of bitmap buttons. The master list I would like to create just once because creating these buttons takes a considerable amount of time, and thus I do not want to destroy them. My idea is to somehow remove all of the buttons from the sizer, make a new list of the buttons that I want the sizer to contain, and then use the sizer's AddMany method. If I can't remove the buttons from the sizer without destroying them, then is there a way to use the sizer's Show method to hide some of the times, but then have the sizer adjust to fill in the gaps? When I hide them, all I can get them to do right now is just to have them disappear and leave a gap. I need the next item to be adjusted to the gap's place. Also is there a way to sort the grid sizer's item list? @@ -27707,7 +27707,7 @@ Thanks for any help you can offer.","You can't sort the sizer items in place. It 2013-08-06 11:48:43.437,How to either sort a wxsizer or remove items without destroying them?,"I have a wxpython grid sizer that is sizing sublists of bitmap buttons. The master list I would like to create just once because creating these buttons takes a considerable amount of time, and thus I do not want to destroy them. My idea is to somehow remove all of the buttons from the sizer, make a new list of the buttons that I want the sizer to contain, and then use the sizer's AddMany method. If I can't remove the buttons from the sizer without destroying them, then is there a way to use the sizer's Show method to hide some of the times, but then have the sizer adjust to fill in the gaps? When I hide them, all I can get them to do right now is just to have them disappear and leave a gap. I need the next item to be adjusted to the gap's place. Also is there a way to sort the grid sizer's item list? -Thanks for any help you can offer.","So I found out that the detach method is what I'm looking for! I would still be interested to know of a way to sort a sizer's item list though, without detaching all of the items and then re attaching a sublist.",0.0,False,3,2711 +Thanks for any help you can offer.","You should be able to call the Layout method on the parent of the sizer, this will make it recalculate the shown items.",0.0,False,3,2711 2013-08-06 20:14:57.490,Is there a way to store python objects directly in mongoDB without serializing them,"I have read somewhere that you can store python objects (more specifically dictionaries) as binaries in MongoDB by using BSON. However right now I cannot find any any documentation related to this. Would anyone know how exactly this can be done?","Assuming you are not specifically interested in mongoDB, you are probably not looking for BSON. BSON is just a different serialization format compared to JSON, designed for more speed and space efficiency. On the other hand, pickle does more of a direct encoding of python objects. However, do your speed tests before you adopt pickle to ensure it is better for your use case.",0.5916962662253621,False,1,2712 @@ -27727,14 +27727,14 @@ pip install mechanize then just open a python interpreter and import mechanize to confirm. That should be it, you can start using mechanize in your Django project.",0.0,False,1,2714 2013-08-07 17:16:24.917,Why doesn't the index/list of an array begin with 1?,"Is there any special reason? I know that that's how the language has been written, but can't we change it? -And what are the challenges we'd face if the index start with 1?","One thing is that, you can reference and navigate the arrays using pointers. Infact the the array operations decay to pointer arithmetic at the back end. -Suppose you want to reach a nth element of an array then you can simply do (a + n) where a is the base address of an array(1-dimension), but if the subscript starts at 1 then to reach the nth element you would have to do (a + n -1) all the time. -This is because just by taking the name of an array you the the address of the starting element of it, which is the simplest way!",0.0814518047658113,False,3,2715 +And what are the challenges we'd face if the index start with 1?","The basic reason behind it is that the computer remembers the address at wich the first part of any variable/object is stored. So the index represents the ""distance"" in between that and what you're looking for, so the first one is 0 away, the second 1...",0.2401167094949473,False,3,2715 2013-08-07 17:16:24.917,Why doesn't the index/list of an array begin with 1?,"Is there any special reason? I know that that's how the language has been written, but can't we change it? And what are the challenges we'd face if the index start with 1?","In C and C++, array indexing is syntactic sugar for dereferencing an offset pointer. That is, array[i] is equivalent to *(array + i). It makes sense for pointers to point to the beginning of their block of memory, and this implies that the first element of the array needs to be *array, which is just array[0].",0.2401167094949473,False,3,2715 2013-08-07 17:16:24.917,Why doesn't the index/list of an array begin with 1?,"Is there any special reason? I know that that's how the language has been written, but can't we change it? -And what are the challenges we'd face if the index start with 1?","The basic reason behind it is that the computer remembers the address at wich the first part of any variable/object is stored. So the index represents the ""distance"" in between that and what you're looking for, so the first one is 0 away, the second 1...",0.2401167094949473,False,3,2715 +And what are the challenges we'd face if the index start with 1?","One thing is that, you can reference and navigate the arrays using pointers. Infact the the array operations decay to pointer arithmetic at the back end. +Suppose you want to reach a nth element of an array then you can simply do (a + n) where a is the base address of an array(1-dimension), but if the subscript starts at 1 then to reach the nth element you would have to do (a + n -1) all the time. +This is because just by taking the name of an array you the the address of the starting element of it, which is the simplest way!",0.0814518047658113,False,3,2715 2013-08-07 20:42:28.817,Boto randomly connecting to different regions for S3 transfers,"I have several S3 buckets containing a total of 40 TB of data across 761 million objects. I undertook a project to copy these objects to EBS storage. To my knowledge, all buckets were created in us-east-1. I know for certain that all of the EC2 instances used for the export to EBS were within us-east-1. The problem is that the AWS bill for last month included a pretty hefty charge for inter-regional data transfer. I'd like to know how this is possible? The transfer used a pretty simple Python script with Boto to connect to S3 and download the contents of each object. I suspect that the fact that the bucket names were composed of uppercase letters might have been a contributing factor (I had to specify OrdinaryCallingFormat()), but I don't know this for sure.",The problem ended up being an internal billing error at AWS and was not related to either S3 or Boto.,0.0,False,1,2716 @@ -27785,7 +27785,9 @@ ln -s /tmp/mysql.sock /var/lib/mysqld/mysqld.sock I met an another problem today. I can't login to mysql. I'm newbie to mysql. So I guess mysql server and client use the same socket to communicate. -I add socket = /var/mysqld/mysqld.sock to [mysqld] [client] block in my.cnf and it wokrs.",You need to change your HOST from 'localhost' to '127.0.0.1' and check your django app :),0.0,False,3,2721 +I add socket = /var/mysqld/mysqld.sock to [mysqld] [client] block in my.cnf and it wokrs.","I faced this problem when connecting MySQL with Django when using Docker. +Try 'PORT':'0.0.0.0'. +Do not use 'PORT': 'db'. This will not work if you tried to run your app outside Docker.",0.0,False,3,2721 2013-08-09 15:55:32.050,"OperationalError: (2002, ""Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)"")","when connecting to mysql database in Django ,I get the error. I'm sure mysql server is running. @@ -27824,9 +27826,7 @@ ln -s /tmp/mysql.sock /var/lib/mysqld/mysqld.sock I met an another problem today. I can't login to mysql. I'm newbie to mysql. So I guess mysql server and client use the same socket to communicate. -I add socket = /var/mysqld/mysqld.sock to [mysqld] [client] block in my.cnf and it wokrs.","I faced this problem when connecting MySQL with Django when using Docker. -Try 'PORT':'0.0.0.0'. -Do not use 'PORT': 'db'. This will not work if you tried to run your app outside Docker.",0.0,False,3,2721 +I add socket = /var/mysqld/mysqld.sock to [mysqld] [client] block in my.cnf and it wokrs.",You need to change your HOST from 'localhost' to '127.0.0.1' and check your django app :),0.0,False,3,2721 2013-08-11 03:02:04.637,Multiprocessing in python on Mac OS,"Any basic information would be greatly appreciated. I am almost completed with my project, all I have to do now is run my code to get my data. However, it takes a very long time, and it has been suggested that I make my code (python) available to multiprocess. However, I am clueless on how to do this and have had a lot of trouble running how. I use a Mac OS X 10.8.2. I know that I need a semaphore. I have looked up the multiprocessing module and the Thread module, although I could not understand most of this. Do the Process() or Manager() functions have anything to do with this? @@ -28218,11 +28218,11 @@ I know that I downloaded Python 2.7 (as the download path is C:/Python27/), so t 2013-09-12 02:08:16.763,Upgrading to Python 2.7 Google App Engine 500 server error,"I just started using Google App Engine and I am very new to Python. I may have made a stupid mistake or a fatal error, I don't know, but I realized that the basic ""template"" I downloaded from a website was old and used Python 2.5. So, I decided to update to Python 2.7 (after recieving a warning in the site's dashboard). I have no idea how to do this, but I blindly followed some instructions on how to update but I'm not sure what I did wrong. -I know that I downloaded Python 2.7 (as the download path is C:/Python27/), so there shouldn't be a problem there. Can anybody tell what I'm doing wrong?","I'm not sure if this is your formatting when you loaded your code here, but where you define app in main.py should not be part of the contacts class. If it is, your reference to main.app in your app.yaml won't work and your page won't load.",0.2655860252697744,False,3,2771 +I know that I downloaded Python 2.7 (as the download path is C:/Python27/), so there shouldn't be a problem there. Can anybody tell what I'm doing wrong?","Thank you everyone for your respective answers and comments, but I recently stumbled upon GAE boilerplate and decided to use that and everything's fine. I kept having very odd problems with GAE beforehand, but the boilerplate is simple and seems to be working fine so far. Anyways, thanks again. (Note: I would delete the question but two people have already answered and received rep from +1s, and they are in fact helpful answers, so I'll leave it be).",1.2,True,3,2771 2013-09-12 02:08:16.763,Upgrading to Python 2.7 Google App Engine 500 server error,"I just started using Google App Engine and I am very new to Python. I may have made a stupid mistake or a fatal error, I don't know, but I realized that the basic ""template"" I downloaded from a website was old and used Python 2.5. So, I decided to update to Python 2.7 (after recieving a warning in the site's dashboard). I have no idea how to do this, but I blindly followed some instructions on how to update but I'm not sure what I did wrong. -I know that I downloaded Python 2.7 (as the download path is C:/Python27/), so there shouldn't be a problem there. Can anybody tell what I'm doing wrong?","Thank you everyone for your respective answers and comments, but I recently stumbled upon GAE boilerplate and decided to use that and everything's fine. I kept having very odd problems with GAE beforehand, but the boilerplate is simple and seems to be working fine so far. Anyways, thanks again. (Note: I would delete the question but two people have already answered and received rep from +1s, and they are in fact helpful answers, so I'll leave it be).",1.2,True,3,2771 +I know that I downloaded Python 2.7 (as the download path is C:/Python27/), so there shouldn't be a problem there. Can anybody tell what I'm doing wrong?","I'm not sure if this is your formatting when you loaded your code here, but where you define app in main.py should not be part of the contacts class. If it is, your reference to main.app in your app.yaml won't work and your page won't load.",0.2655860252697744,False,3,2771 2013-09-12 03:49:54.783,Django Clear All Admin List Filters,"I have a Django admin control panel and in each list of objects there are lots and lots of list filters. I want to be able to clear all the filters with a click of a button, but can't find where this ability is, if it already exists in Django. Routes I'm considering (but cannot figure out): @@ -28278,9 +28278,9 @@ So finally the question - which is: is there any better solution? Or maybe I'm w Here's another simple idea to consider: link all the keys in a linked list in order of arrival. Each time you retrieve a key, iterate from the beginning of the list and remove all expired items, from both the list and the dictionary.",0.1352210990936997,False,2,2777 2013-09-13 09:56:42.507,python pip specify a library directory and an include directory,"I am using pip and trying to install a python module called pyodbc which has some dependencies on non-python libraries like unixodbc-dev, unixodbc-bin, unixodbc. I cannot install these dependencies system wide at the moment, as I am only playing, so I have installed them in a non-standard location. How do I tell pip where to look for these dependencies ? More exactly, how do I pass information through pip of include dirs (gcc -I) and library dirs (gcc -L -l) to be used when building the pyodbc extension ?","Just in case it's of help to somebody, I still could not find a way to do it through pip, so ended up simply downloading the package and doing through its 'setup.py'. Also switched to what seems an easier to install API called 'pymssql'.",-0.1731644579931097,False,1,2778 2013-09-13 15:43:00.843,How to avoid repeated pre-calculation in django view,"I am writing an API which returns json according to queries. For example: localhost/api/query?a=1&b=2. To return the json, I need to do some pre-calculations to calculate a value, say, x. The pre-calculation takes long time (several hundred milliseconds). For example, The json file returns the value of x+a+b. -When the user query localhost/api/query?a=3&b=4, x will be calculate again and this is a waste of time since x won't change for any query. The question is how can I do this pre-calculation of x for all queries (In the real app, x is not a value but a complex object returned by wrapped C++ code).","If you are using some sort of cache (memcached, redis) you can store it there. You can try to serialize the object with pickle, msgpack etc. That you can retrieve and deserialze it.",0.3869120172231254,False,2,2779 -2013-09-13 15:43:00.843,How to avoid repeated pre-calculation in django view,"I am writing an API which returns json according to queries. For example: localhost/api/query?a=1&b=2. To return the json, I need to do some pre-calculations to calculate a value, say, x. The pre-calculation takes long time (several hundred milliseconds). For example, The json file returns the value of x+a+b. When the user query localhost/api/query?a=3&b=4, x will be calculate again and this is a waste of time since x won't change for any query. The question is how can I do this pre-calculation of x for all queries (In the real app, x is not a value but a complex object returned by wrapped C++ code).","You could add a model (with a db table) that stores values for a, b and x. Then for each query, you could look for an instance with a and b and return the associated x.",0.2012947653214861,False,2,2779 +2013-09-13 15:43:00.843,How to avoid repeated pre-calculation in django view,"I am writing an API which returns json according to queries. For example: localhost/api/query?a=1&b=2. To return the json, I need to do some pre-calculations to calculate a value, say, x. The pre-calculation takes long time (several hundred milliseconds). For example, The json file returns the value of x+a+b. +When the user query localhost/api/query?a=3&b=4, x will be calculate again and this is a waste of time since x won't change for any query. The question is how can I do this pre-calculation of x for all queries (In the real app, x is not a value but a complex object returned by wrapped C++ code).","If you are using some sort of cache (memcached, redis) you can store it there. You can try to serialize the object with pickle, msgpack etc. That you can retrieve and deserialze it.",0.3869120172231254,False,2,2779 2013-09-14 06:29:53.133,How to perform flash object testing in selenium webdriver with python?,"After trying to find some help on the internet related to flash testing through selenium, all I find is FlexUISelenium package available for Selenium RC. I DO NOT find any such package available for Selenium Webdriver. I am working with python and selenium webdriver and I do not see any packages available to automate flash applications. Is there any such package available at all for webdriver? If not, how do I start automating a flash application in webdriver?",Use flashselenium or sikuli for flash object testing.,0.0,False,1,2780 2013-09-14 08:11:29.187,How to if few letters are part of the string entered?,"Can somebody pls help me on how to write the code to check if few given letters are part of the string entered. the output must be true if the letters are present or false. @@ -28458,10 +28458,10 @@ Usually you can leave the operating system to do what it knows best, so calling The Python Shell within Wing101, is version 2.7.2, how do I configure it to open python 3.3.2. I have downloaded Python 3.3.2 and I need the custom Python Executable. I previously tried ""/usr/bin/python"" as my custom python executable, but it doesn't work. I am on a Mac 10.8.3","The location of the python.exe for Python 3.3 can vary depending on how you installed it. Probably the best bet is to search w/ Spotlight for python.exe, press ""Show All"" in the drop down menu, change to ""File Name"" instead of ""Contents"" search and then click on results to see the full path at the bottom of the search results window. You'll get at least 2-3 results and the full path should make clear which is the correct one. Then enter that into Python Executable in the Configure Python dialog, accessed from the Source menu in Wing 101. You'll need to restart the Python Shell in Wing 101 from its Options menu before it switches to the new Python version.",1.2,True,1,2807 -2013-10-02 00:31:14.027,What is the android activity for opening sudoku and how do I find how to?,I am using appium and using Sudoku app for Android on a Windows 7 machine using Python. If someone can help me find out what the app activity is to opening this and how they were able to figure that out,A simple VM emulate an Android device. Not dificult.,0.0,False,2,2808 2013-10-02 00:31:14.027,What is the android activity for opening sudoku and how do I find how to?,I am using appium and using Sudoku app for Android on a Windows 7 machine using Python. If someone can help me find out what the app activity is to opening this and how they were able to figure that out,"You just need to run adb shell command in command prompt. After that , Open the Suduko app in your device(make sure your device is connected to your laptop/pc) and go back to the command prompt and run the below command : dumpsys window windows | grep -E 'mCurrentFocus' The Above command will give you the package name & activity name of the currently focused app.",1.2,True,2,2808 +2013-10-02 00:31:14.027,What is the android activity for opening sudoku and how do I find how to?,I am using appium and using Sudoku app for Android on a Windows 7 machine using Python. If someone can help me find out what the app activity is to opening this and how they were able to figure that out,A simple VM emulate an Android device. Not dificult.,0.0,False,2,2808 2013-10-02 05:40:24.123,Truncate Django CMS Placeholder,"I'm creating my own Django CMS blog plugin. I'm using a placeholder to hold the full content of the blog entry and I'm trying to figure out how to automatically create an excerpt from this placeholder. If it were simply a text field I know I could use ""|truncatechars:15"" in the template, but I don't know how to do this for a placeholder. Is there something I can use in the template or in the 'views.py' in order to truncate the placeholder? @@ -28474,7 +28474,7 @@ E.g. INPUT to OUTPUT Santa Claus to Claus, S. Michael J. Fox to Fox, M. J. Madonna to Madonna -William Henry Richard Charles Windsor to Windsor, W. H. R. C.","You will need an algorithm, which separates your input string by whitespaces. Then you would take the last of those separated strings and add it to your output string. You will have to add a comma, if more names are following. After that, take the other strings, starting with the first one, and check if they are already in the form ""[A-Z]."". If not, transform them to that form. Otherwise just add them to your output. Thats it. I could be more precise, but you asked not to be :)",0.0,False,2,2810 +William Henry Richard Charles Windsor to Windsor, W. H. R. C.","Ok, then use String.Split() To change String into List , then use len() to count the elements. Use loop for and create new string .",0.0,False,2,2810 2013-10-04 22:04:32.450,I need help on creating a name changing program,"This question is for a school project so don't give my exact answer XD But please tell me how I would start it. I have been trying it for a couple of hours but I just can't get it. Here is the question: Create a function in python that accepts names in standard form and prints them in the form: @@ -28482,7 +28482,7 @@ E.g. INPUT to OUTPUT Santa Claus to Claus, S. Michael J. Fox to Fox, M. J. Madonna to Madonna -William Henry Richard Charles Windsor to Windsor, W. H. R. C.","Ok, then use String.Split() To change String into List , then use len() to count the elements. Use loop for and create new string .",0.0,False,2,2810 +William Henry Richard Charles Windsor to Windsor, W. H. R. C.","You will need an algorithm, which separates your input string by whitespaces. Then you would take the last of those separated strings and add it to your output string. You will have to add a comma, if more names are following. After that, take the other strings, starting with the first one, and check if they are already in the form ""[A-Z]."". If not, transform them to that form. Otherwise just add them to your output. Thats it. I could be more precise, but you asked not to be :)",0.0,False,2,2810 2013-10-05 22:29:24.267,Python social auth account association only,"I'm currently trying to add an 'associate google account' button to my django 1.4.8 project. I've never worked with python-social-auth before, and I'm a bit confused about only associating accounts --as opposed to authenticating against--, and how to use credentials for accessing Google Drive services. Thanks! A.",If your user is already logged in with a username a password you simply need to allow them to follow the same steps they would when signing up with a social account and that social account will be automatically associated with their django account,1.2,True,1,2811 @@ -28499,15 +28499,8 @@ prompt after the script runs once through? PyCharm Community Edition 3.0 Windows 7 -Python 2.7","UPDATE -Starting with version 4.0 there's an option Show command line afterwards (renamed in later versions to Run with Python console) when editing run/debug configuration in Run|Edit Configurations.... - -From output of python --help: - --i : inspect interactively after running script; forces a prompt even - if stdin does not appear to be a terminal; also PYTHONINSPECT=x - -To set interpreter option in PyCharm go to Run|Edit Configuration",1.2,True,3,2812 +Python 2.7","Click Run -> Edit Configurations..., +Then check the box Run with Python console.",0.9903904942256808,False,3,2812 2013-10-06 08:44:30.647,Interacting with program after execution,"In PyCharm, after I run a script it automatically kills it: C:\Users\Sean.virtualenvs\Stanley\Scripts\python.exe C:/Users/Sean/PycharmProjects/Stanley/Stanley.py @@ -28535,8 +28528,15 @@ prompt after the script runs once through? PyCharm Community Edition 3.0 Windows 7 -Python 2.7","Click Run -> Edit Configurations..., -Then check the box Run with Python console.",0.9903904942256808,False,3,2812 +Python 2.7","UPDATE +Starting with version 4.0 there's an option Show command line afterwards (renamed in later versions to Run with Python console) when editing run/debug configuration in Run|Edit Configurations.... + +From output of python --help: + +-i : inspect interactively after running script; forces a prompt even + if stdin does not appear to be a terminal; also PYTHONINSPECT=x + +To set interpreter option in PyCharm go to Run|Edit Configuration",1.2,True,3,2812 2013-10-07 09:03:37.463,pythonocc loading .3md format,"In the pythonOCC examples CADViewerMDI.py the CAD format step, stp, iges, igs, and brep are suported. Do pythonOCC support the format "".3dm"" and if, how do I load it. Supoptimal sulution: @@ -28557,27 +28557,27 @@ Now if i set base as 'example.com/blog/new/i.html' wont the first one break","Ke 2013-10-07 19:37:25.363,How to tell uWSGI to prefer processes to threads for load balancing,"I've installed Nginx + uWSGI + Django on a VDS with 3 CPU cores. uWSGI is configured for 6 processes and 5 threads per process. Now I want to tell uWSGI to use processes for load balancing until all processes are busy, and then to use threads if needed. It seems uWSGI prefer threads, and I have not found any config option to change this behaviour. First process takes over 100% CPU time, second one takes about 20%, and another processes are mostly not used. Our site receives 40 r/s. Actually even having 3 processes without threads is anough to handle all requests usually. But request processing hangs from time to time for various reasons like locked shared resources, etc. In such cases we have -1 process. Users don't like to wait and click the link again and again. As a result all processes hangs and all users have to wait. I'd add even more threads to make the server more robust. But the problem is probably python GIL. Threads wan't use all CPU cores. So multiple processes work much better for load balancing. But threads may help a lot in case of locked shared resources and i/o wait delays. A process may do much work while one of it's thread is locked. -I don't want to decrease time limits until there is no another solution. It is possible to solve this problem with threads in theory, and I don't want to show error messages to user or to make him waiting on every request until there is no another choice.","Every process is effectively a thread, as threads are execution contexts of the same process. -For such a reason there is nothing like ""a process executes it instead of a thread"". Even without threads your process has 1 execution context (a thread). What i would investigate is why you get (perceived) poor performances when using multiple threads per process. Are you sure you are using a stable (with solid threading support) uWSGI release ? (1.4.x or 1.9.x) -Have you thought about dynamically spawning more processes when the server is overloaded ? Check the uWSGI cheaper modes, there are various algorithm available. Maybe one will fit your situation. -The GIL is not a problem for you, as from what you describe the problem is the lack of threads for managing new requests (even if from your numbers it looks you may have a too much heavy lock contention on something else)",0.9997532108480276,False,2,2816 -2013-10-07 19:37:25.363,How to tell uWSGI to prefer processes to threads for load balancing,"I've installed Nginx + uWSGI + Django on a VDS with 3 CPU cores. uWSGI is configured for 6 processes and 5 threads per process. Now I want to tell uWSGI to use processes for load balancing until all processes are busy, and then to use threads if needed. It seems uWSGI prefer threads, and I have not found any config option to change this behaviour. First process takes over 100% CPU time, second one takes about 20%, and another processes are mostly not used. -Our site receives 40 r/s. Actually even having 3 processes without threads is anough to handle all requests usually. But request processing hangs from time to time for various reasons like locked shared resources, etc. In such cases we have -1 process. Users don't like to wait and click the link again and again. As a result all processes hangs and all users have to wait. -I'd add even more threads to make the server more robust. But the problem is probably python GIL. Threads wan't use all CPU cores. So multiple processes work much better for load balancing. But threads may help a lot in case of locked shared resources and i/o wait delays. A process may do much work while one of it's thread is locked. I don't want to decrease time limits until there is no another solution. It is possible to solve this problem with threads in theory, and I don't want to show error messages to user or to make him waiting on every request until there is no another choice.","So, the solution is: Upgrade uWSGI to recent stable version (as roberto suggested). Use --thunder-lock option. Now I'm running with 50 threads per process and all requests are distributed between processes equally.",1.2,True,2,2816 -2013-10-07 21:17:22.697,Linked Matrix Implementation in Python?,"I know in a linked list there are a head node and a tail node. Well, for my data structures assignment, we are suppose to create a linked matrix with references to a north, south, east, and west node. I am at a loss of how to implement this. A persistent problem that bothers me is the head node and tail node. The user inputs the number of rows and the number of columns. Should I have multiple head nodes then at the beginning of each row and multiple tail nodes at the end of each row? If so, should I store the multiple head/tail nodes in a list? -Thank you.","It really depends on what options you want/need to efficiently support. -For instance, a singly linked list with only a head pointer can be a stack (insert and remove at the head). If you add a tail pointer you can insert at either end, but only remove at the head (stack or queue). A doubly linked list can support insertion or deletion at either end (deque). If you try to implement an operation that your data structure is not designed for you incur an O(N) penalty. -So I would start with a single pointer to the (0,0) element and then start working on the operations your instructor asks for. You may find you need additional pointers, you may not. My guess would be that you will be fine with a single head pointer.",0.0,False,2,2817 +2013-10-07 19:37:25.363,How to tell uWSGI to prefer processes to threads for load balancing,"I've installed Nginx + uWSGI + Django on a VDS with 3 CPU cores. uWSGI is configured for 6 processes and 5 threads per process. Now I want to tell uWSGI to use processes for load balancing until all processes are busy, and then to use threads if needed. It seems uWSGI prefer threads, and I have not found any config option to change this behaviour. First process takes over 100% CPU time, second one takes about 20%, and another processes are mostly not used. +Our site receives 40 r/s. Actually even having 3 processes without threads is anough to handle all requests usually. But request processing hangs from time to time for various reasons like locked shared resources, etc. In such cases we have -1 process. Users don't like to wait and click the link again and again. As a result all processes hangs and all users have to wait. +I'd add even more threads to make the server more robust. But the problem is probably python GIL. Threads wan't use all CPU cores. So multiple processes work much better for load balancing. But threads may help a lot in case of locked shared resources and i/o wait delays. A process may do much work while one of it's thread is locked. +I don't want to decrease time limits until there is no another solution. It is possible to solve this problem with threads in theory, and I don't want to show error messages to user or to make him waiting on every request until there is no another choice.","Every process is effectively a thread, as threads are execution contexts of the same process. +For such a reason there is nothing like ""a process executes it instead of a thread"". Even without threads your process has 1 execution context (a thread). What i would investigate is why you get (perceived) poor performances when using multiple threads per process. Are you sure you are using a stable (with solid threading support) uWSGI release ? (1.4.x or 1.9.x) +Have you thought about dynamically spawning more processes when the server is overloaded ? Check the uWSGI cheaper modes, there are various algorithm available. Maybe one will fit your situation. +The GIL is not a problem for you, as from what you describe the problem is the lack of threads for managing new requests (even if from your numbers it looks you may have a too much heavy lock contention on something else)",0.9997532108480276,False,2,2816 2013-10-07 21:17:22.697,Linked Matrix Implementation in Python?,"I know in a linked list there are a head node and a tail node. Well, for my data structures assignment, we are suppose to create a linked matrix with references to a north, south, east, and west node. I am at a loss of how to implement this. A persistent problem that bothers me is the head node and tail node. The user inputs the number of rows and the number of columns. Should I have multiple head nodes then at the beginning of each row and multiple tail nodes at the end of each row? If so, should I store the multiple head/tail nodes in a list? Thank you.","There's more than one way to interpret this, but one option is: Have a single ""head"" node at the top-left corner and a ""tail"" node at the bottom-right. There will then be row-head, row-tail, column-head, and column-tail nodes, but these are all accessible from the overall head and tail, so you don't need to keep track of them, and they're already part of the linked matrix, so they don't need to be part of a separate linked list. (Of course a function that builds up an RxC matrix of zeroes will probably have local variables representing the current row's head/tail, but that's not a problem.)",0.0,False,2,2817 +2013-10-07 21:17:22.697,Linked Matrix Implementation in Python?,"I know in a linked list there are a head node and a tail node. Well, for my data structures assignment, we are suppose to create a linked matrix with references to a north, south, east, and west node. I am at a loss of how to implement this. A persistent problem that bothers me is the head node and tail node. The user inputs the number of rows and the number of columns. Should I have multiple head nodes then at the beginning of each row and multiple tail nodes at the end of each row? If so, should I store the multiple head/tail nodes in a list? +Thank you.","It really depends on what options you want/need to efficiently support. +For instance, a singly linked list with only a head pointer can be a stack (insert and remove at the head). If you add a tail pointer you can insert at either end, but only remove at the head (stack or queue). A doubly linked list can support insertion or deletion at either end (deque). If you try to implement an operation that your data structure is not designed for you incur an O(N) penalty. +So I would start with a single pointer to the (0,0) element and then start working on the operations your instructor asks for. You may find you need additional pointers, you may not. My guess would be that you will be fine with a single head pointer.",0.0,False,2,2817 2013-10-08 02:53:15.040,Access iOS Apps List in iTunes via Win32 COM?,"I've been using Python to script Win32 iTunes, and it's been rocky but doable. However, I wanted to move beyond just media (songs, etc.) to analyze what apps were on my devices. Can anyone recommend how to use the iTunes Win32 COM interface to, say, get a list of apps that are currently on the phone? I thought the app list might be exposed as a playlist, with each app as an IITFileOrCDTrack, but that doesn't seem to be the case. When I look at my phone as a source, it just lists media playlists (books, movies, etc.) Or, if you can suggest a different way to do this from Python, open to suggestions. I assumed I'd have to use iTunes as my phone is not jailbroken and I don't know any other way to see what's on the phone, but if there is another way, cool. I don't need to add or remove, just want to see what's there. @@ -28589,7 +28589,6 @@ i want my output to be like this: By the way its supposed to be (month,year), how can i achieve that?","after a lot of trying i changed my approach and instead of tuples, i used datetime objects and then applied the: months_sorted = sorted(months.iteritems(), key=operator.itemgetter(0))",1.2,True,1,2819 -2013-10-08 19:46:52.183,Python - how to normalize time-series data,"I have a dataset of time-series examples. I want to calculate the similarity between various time-series examples, however I do not want to take into account differences due to scaling (i.e. I want to look at similarities in the shape of the time-series, not their absolute value). So, to this end, I need a way of normalizing the data. That is, making all of the time-series examples fall between a certain region e.g [0,100]. Can anyone tell me how this can be done in python","I'm not going to give the Python code, but the definition of normalizing, is that for every value (datapoint) you calculate ""(value-mean)/stdev"". Your values will not fall between 0 and 1 (or 0 and 100) but I don't think that's what you want. You want to compare the variation. Which is what you are left with if you do this.",0.0,False,2,2820 2013-10-08 19:46:52.183,Python - how to normalize time-series data,"I have a dataset of time-series examples. I want to calculate the similarity between various time-series examples, however I do not want to take into account differences due to scaling (i.e. I want to look at similarities in the shape of the time-series, not their absolute value). So, to this end, I need a way of normalizing the data. That is, making all of the time-series examples fall between a certain region e.g [0,100]. Can anyone tell me how this can be done in python","The solutions given are good for a series that aren’t incremental nor decremental(stationary). In financial time series( or any other series with a a bias) the formula given is not right. It should, first be detrended or perform a scaling based in the latest 100-200 samples. And if the time series doesn't come from a normal distribution ( as is the case in finance) there is advisable to apply a non linear function ( a standard CDF funtion for example) to compress the outliers. Aronson and Masters book (Statistically sound Machine Learning for algorithmic trading) uses the following formula ( on 200 day chunks ): @@ -28600,6 +28599,7 @@ F50 : mean of the latest 200 points F75 : percentile 75 F25 : Percentile 25 N : normal CDF",0.7153027079198643,False,2,2820 +2013-10-08 19:46:52.183,Python - how to normalize time-series data,"I have a dataset of time-series examples. I want to calculate the similarity between various time-series examples, however I do not want to take into account differences due to scaling (i.e. I want to look at similarities in the shape of the time-series, not their absolute value). So, to this end, I need a way of normalizing the data. That is, making all of the time-series examples fall between a certain region e.g [0,100]. Can anyone tell me how this can be done in python","I'm not going to give the Python code, but the definition of normalizing, is that for every value (datapoint) you calculate ""(value-mean)/stdev"". Your values will not fall between 0 and 1 (or 0 and 100) but I don't think that's what you want. You want to compare the variation. Which is what you are left with if you do this.",0.0,False,2,2820 2013-10-10 12:59:09.063,Java Application Interacting with Flash on Web Application,"Is there anyway I can make a Java application communicate with a Flash Player (application) that is on a website? The flash application is quite dynamic, meaning the data changes as i refresh and visit different pages. In fact the page itself is fully flash. Where should i be looking at to get this working? I'm thinking how can i even retrieve the text / objects from this flash and then send a action(click, text ) . @@ -28622,21 +28622,21 @@ I am using linus mint 15 as an OS. I am unsure how to get my modules in netbeans to ""see"" methors e.g. json.dumps. I am new to netbeans and would appreciate your assistance. Thanks and regards, -Chris","I found the issue ... -netbeans defaults to jython. I had to save my project files to another directory, delete my project (changing to python 2.7. for current project had no effect) and create a new project with netbeans with python 2.7 as the default. -Thanks for helping me get simplejson into my python 2.7 Nipun! Chris",0.0,False,2,2823 -2013-10-13 01:12:12.410,How do I install simplejson 3.3.1 for a Python project in Netbeans IDE 7.3.1,"I am trying to install simplejson-3.3.1.tar.gz so it can be accessed by my Python project in netbeans IDE 7.3.1. -I installed json.py in my src as a quick fix, but need more functionality. -I am using linus mint 15 as an OS. -I am unsure how to get my modules in netbeans to ""see"" methors e.g. json.dumps. -I am new to netbeans and would appreciate your assistance. -Thanks and regards, Chris","Install Python setuptools sudo apt-get install python-setuptools Now using pip install simplejson sudo pip install simplejson In general most Python packages can be installed this way.",0.0,False,2,2823 +2013-10-13 01:12:12.410,How do I install simplejson 3.3.1 for a Python project in Netbeans IDE 7.3.1,"I am trying to install simplejson-3.3.1.tar.gz so it can be accessed by my Python project in netbeans IDE 7.3.1. +I installed json.py in my src as a quick fix, but need more functionality. +I am using linus mint 15 as an OS. +I am unsure how to get my modules in netbeans to ""see"" methors e.g. json.dumps. +I am new to netbeans and would appreciate your assistance. +Thanks and regards, +Chris","I found the issue ... +netbeans defaults to jython. I had to save my project files to another directory, delete my project (changing to python 2.7. for current project had no effect) and create a new project with netbeans with python 2.7 as the default. +Thanks for helping me get simplejson into my python 2.7 Nipun! Chris",0.0,False,2,2823 2013-10-14 13:46:33.090,How to find orphan process's pid,"How can I find child process pid after the parent process died. I have program that creates child process that continues running after it (the parent) terminates. i.e., @@ -28675,8 +28675,8 @@ your graph will span across the 2nd and 4th quadrants",0.0,False,1,2829 I'd like to know which one of the regexes gave a match in re.search(r""reg1|reg2|..."", text), and I cannot figure how to do it since `re.search(r""reg1|reg2|..."", text).re.pattern gives the whole regex. For example, if my regex is r""foo[0-9]|bar"", my pattern ""foo1"", I'd like to get as an answer ""foo[0-9]. Is there any way to do this ?","Wrap each sub-regexp in (). After the match, you can go through all the groups in the matcher (match.group(index)). The non-empty group will be the one that matched.",1.2,True,1,2830 -2013-10-18 11:26:18.377,IntelliJ IDEA - unix python virtualenv on WIndows,I have Python application and virtualenv for it. I run it on Debian virtual machine. Is it possible to configure IntelliJ to start application and use IntelliJ debug tools? The problem is how to use virtualenv for debian in Windows 7 system.,Just install an appropriate python and virtualenv for that python directly on the windows 7 machine.,0.0,False,2,2831 2013-10-18 11:26:18.377,IntelliJ IDEA - unix python virtualenv on WIndows,I have Python application and virtualenv for it. I run it on Debian virtual machine. Is it possible to configure IntelliJ to start application and use IntelliJ debug tools? The problem is how to use virtualenv for debian in Windows 7 system.,I solved it. If connect with my virtual machine by remote debug tool. I add one line with IntellJ/PyCharm generate to entry point of paster script. Before debug i run script (using IntelliJ remote tool) with run application on virtual machine.,0.0,False,2,2831 +2013-10-18 11:26:18.377,IntelliJ IDEA - unix python virtualenv on WIndows,I have Python application and virtualenv for it. I run it on Debian virtual machine. Is it possible to configure IntelliJ to start application and use IntelliJ debug tools? The problem is how to use virtualenv for debian in Windows 7 system.,Just install an appropriate python and virtualenv for that python directly on the windows 7 machine.,0.0,False,2,2831 2013-10-18 20:17:07.087,Bigquery: how to preserve nested data in derived tables?,"I have a few large hourly upload tables with RECORD fieldtypes. I want to pull select records out of those tables and put them in daily per-customer tables. The trouble I'm running into is that using QUERY to do this seems to flatten the data out. Is there some way to preserve the nested RECORDs, or do I need to rethink my approach? If it helps, I'm using the Python API.","Unfortunately, there isn't a way to do this right now, since, as you realized, all results are flattened.",1.2,True,1,2832 @@ -28692,6 +28692,12 @@ However the best solution for you, the original authors and future users is prob 2013-10-22 05:47:42.950,how to make python script executable when click on the file,"I am trying to make my python script executable without going through the terminal typing like python test.py I want to make it able to run when i click on the file. +How i going to do this in my fedora machine.","Add #!/usr/bin/env python at the very beginning of file. +Make chmod u+x filename.py +Change your extension from .py to .sh, so your linux distro's UI will recognize it as shell script and try to execute.",0.1160922760327606,False,6,2835 +2013-10-22 05:47:42.950,how to make python script executable when click on the file,"I am trying to make my python script executable without going through the terminal typing like +python test.py +I want to make it able to run when i click on the file. How i going to do this in my fedora machine.","Add #!/bin/python as the very first line of your file. Or, if you don't know where your python executable is, type which python in a terminal; then copy the result of that and put it after the #!. Change the permissions of the file so that its executable chmod u+x test.py @@ -28714,12 +28720,6 @@ How i going to do this in my fedora machine.",If you don't have any specific ver 2013-10-22 05:47:42.950,how to make python script executable when click on the file,"I am trying to make my python script executable without going through the terminal typing like python test.py I want to make it able to run when i click on the file. -How i going to do this in my fedora machine.","Add #!/usr/bin/env python at the very beginning of file. -Make chmod u+x filename.py -Change your extension from .py to .sh, so your linux distro's UI will recognize it as shell script and try to execute.",0.1160922760327606,False,6,2835 -2013-10-22 05:47:42.950,how to make python script executable when click on the file,"I am trying to make my python script executable without going through the terminal typing like -python test.py -I want to make it able to run when i click on the file. How i going to do this in my fedora machine.","It's Nautilus's fault. Open Nautilus (the file manager), go to Menu > Preferences. Select the ""Behaviour"" section. On the field titled ""Executable text files"", select the option ""Execute executable text files when opened"".",0.0582430451621389,False,6,2835 @@ -28737,19 +28737,19 @@ I have a somewhat messy notebook which I want to filter by tagging cells as slid In an optimal world there would be a fire-and-forget 'give me a pdf' button somewhere. So I did already view the slides locally via ipython nbconvert ... --to slides -- post serve But how do I distribute that to others? Can I get a pdf from such a slideshow easily (I do not care about transition animations etc.) -I hope this is developed further, great features so far!","$ ipython nbconvert ... --to slides (no serve option necessary) create a standalone html file you should be able to mail, or whatever. -The skip/- logic can be applied to pdf generation too, you just have to write your own extended template (which is not that hard, wild guess ~20 lines)",0.1016881243684853,False,2,2836 +I hope this is developed further, great features so far!","You can print it as a pdf file from Chrome. + +Add ""?print-pdf"" at the end of your URL.e.g: 127.0.0.1:8000/index.html?print-pdf +Select print menu from Chrome. +Select Save As pdf, then print it out.",0.1016881243684853,False,2,2836 2013-10-22 09:11:40.180,Distribute a slideshow from IPython notebook,"so I am adoring the new IPython notebook slideshow feature, however I could not figure out how to distribute such a slideshow in a userfriendly (I am no HTML/JS guy) way. My usecase is: I have a somewhat messy notebook which I want to filter by tagging cells as slides/skip/- etc. In an optimal world there would be a fire-and-forget 'give me a pdf' button somewhere. So I did already view the slides locally via ipython nbconvert ... --to slides -- post serve But how do I distribute that to others? Can I get a pdf from such a slideshow easily (I do not care about transition animations etc.) -I hope this is developed further, great features so far!","You can print it as a pdf file from Chrome. - -Add ""?print-pdf"" at the end of your URL.e.g: 127.0.0.1:8000/index.html?print-pdf -Select print menu from Chrome. -Select Save As pdf, then print it out.",0.1016881243684853,False,2,2836 +I hope this is developed further, great features so far!","$ ipython nbconvert ... --to slides (no serve option necessary) create a standalone html file you should be able to mail, or whatever. +The skip/- logic can be applied to pdf generation too, you just have to write your own extended template (which is not that hard, wild guess ~20 lines)",0.1016881243684853,False,2,2836 2013-10-22 19:54:48.560,Does print statement will make performance issue for a website,"We are using the python/Django for web development. While development phase wile coding i tends to put print statement a lot places to check the control flow of the code. And same code with print statement is uploaded for server, I know logging is a place to be more suitable but i find myself more comfortable with print. @@ -28796,17 +28796,14 @@ I have found some examples that detail how to make a call from within an Android Google designs their services (such as GAE and endpoints) to be language agnostic, e.g. using JSON to serialize objects. There are a few advantages to using Java on both, such as being able to share code between client and service projects, but Google does not promote such dependencies at all - you will have no problem using Python instead.",1.2,True,1,2842 2013-10-27 19:34:59.097,Binary to decimal conversion - formula explanation,"can anyone explain me how to see why the number in binary form: 111 is 2^3 - 1 ? -I know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..","It is a unique property of number 2 that the sum of it's previous powers is equal to the next power level subtracted by 1. -In other words: - -2^n=2^0+2^1+2^2+...+2^(n-1)+1 for n in (1,2,3...) +I know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..","The general formula for base B is as follows: +(B^N + ... + B^1 + B^0)*(B-1) = +(B^(N+1) + ... + B^2 + B^1) - (B^N + ... + B^1 + B^0) = +B^(N+1) - B^0 = B^(N+1)-1 +Examples: -If you need proof, use mathematical induction. -Base: n=1; 2^1=2=2^0+1=1+1 -Suppose that for n=k the property 2^n=2^0+2^1+...+2^(n-1)+1 is satisfied -For n=k+1 you have 2^n=(2^k)*(2^1) then apply the hypothesis and you have -2^n=(2^0+2^1+...+2^(n-2)+1)*2 which yields -2^n=(2^1+2^2+...+2^(n-1)+2)=1+2^0+2^1+...+2^(n-1) which concludes our proof.",1.2,True,4,2843 +B=2 and N=3 gives 2^4 - 1 = 1111 binary +B=10 and N=3 gives 10^3 - 1 = 999 decimal",0.0,False,4,2843 2013-10-27 19:34:59.097,Binary to decimal conversion - formula explanation,"can anyone explain me how to see why the number in binary form: 111 is 2^3 - 1 ? I know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..","Add 1 to 111: the result is 1000. It follows, therefore, that: @@ -28819,16 +28816,19 @@ Now, 1000 is 23, hence: Of course, you can say something similar about binary numbers with any number of 1s",0.0814518047658113,False,4,2843 2013-10-27 19:34:59.097,Binary to decimal conversion - formula explanation,"can anyone explain me how to see why the number in binary form: 111 is 2^3 - 1 ? -I know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..","Think of it like this, 111 is 1 less than 1000 (8 in binary).",0.0814518047658113,False,4,2843 -2013-10-27 19:34:59.097,Binary to decimal conversion - formula explanation,"can anyone explain me how to see why the number in binary form: 111 is 2^3 - 1 ? -I know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..","The general formula for base B is as follows: -(B^N + ... + B^1 + B^0)*(B-1) = -(B^(N+1) + ... + B^2 + B^1) - (B^N + ... + B^1 + B^0) = -B^(N+1) - B^0 = B^(N+1)-1 -Examples: +I know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..","It is a unique property of number 2 that the sum of it's previous powers is equal to the next power level subtracted by 1. +In other words: -B=2 and N=3 gives 2^4 - 1 = 1111 binary -B=10 and N=3 gives 10^3 - 1 = 999 decimal",0.0,False,4,2843 +2^n=2^0+2^1+2^2+...+2^(n-1)+1 for n in (1,2,3...) + +If you need proof, use mathematical induction. +Base: n=1; 2^1=2=2^0+1=1+1 +Suppose that for n=k the property 2^n=2^0+2^1+...+2^(n-1)+1 is satisfied +For n=k+1 you have 2^n=(2^k)*(2^1) then apply the hypothesis and you have +2^n=(2^0+2^1+...+2^(n-2)+1)*2 which yields +2^n=(2^1+2^2+...+2^(n-1)+2)=1+2^0+2^1+...+2^(n-1) which concludes our proof.",1.2,True,4,2843 +2013-10-27 19:34:59.097,Binary to decimal conversion - formula explanation,"can anyone explain me how to see why the number in binary form: 111 is 2^3 - 1 ? +I know that the number is calculated by 1*2^0 + 1*2^1 + 1*2^2 but I can't see how to get from here to 2^3-1 ... can't see any power rule or something..","Think of it like this, 111 is 1 less than 1000 (8 in binary).",0.0814518047658113,False,4,2843 2013-10-27 23:30:41.163,Closing a python program window leaves program still running in the background,"I made a program, which uses tkinter to create a window where stuff happens. It contains images and loops to constantly shift and move the images. Now, when I close the window, the scripts are still running and it creates error messages that it has nowhere to place the images with new coordinates. I think that the loops are still running. So my question is, how do I close the program all together after clicking the x on the window. Is there a way to bind the x(close window) to terminate the program, or cat n ibe done inside a code, to see when the tkinter window is closed(to me this way seems to be bad, because it would keep checking for if the window is still existing or not). @@ -29089,6 +29089,12 @@ Add a registry entry key "".py"" in HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\10.0_Config\Projects{E24C65DC-7377-472b-9ABA-BC803B73C61A}\RelatedFiles.aspx",1.2,True,1,2875 2013-11-13 19:31:03.547,"Flask RESTful cross-domain issue with Angular: PUT, OPTIONS methods","I've developed a small write-only REST api with Flask Restful that accepts PUT request from a handful of clients that can potentially have changing IP addresses. My clients are embedded Chromium clients running an AngularJS front-end; they authenticate with my API with a simple magic key -- it's sufficient for my very limited scale. I'm testing deploying my API now and I notice that the Angular clients are attempting to send an OPTIONS http methods to my Flask service. My API meanwhile is replying with a 404 (since I didn't write an OPTIONS handler yet, only a PUT handler). It seems that when sending cross-domain requests that are not POST or GET, Angular will send a pre-flight OPTIONS method at the server to make sure the cross-domain request is accepted before it sends the actual request. Is that right? +Anyway, how do I allow all cross-domain PUT requests to Flask Restful API? I've used cross-domaion decorators with a (non-restful) Flask instance before, but do I need to write an OPTIONS handler as well into my API?","Just an update to this comment. Flask CORS is the way to go, but the flask.ext.cors is deprecated. +use: + +from flask_cors import CORS",0.2229491379952452,False,2,2876 +2013-11-13 19:31:03.547,"Flask RESTful cross-domain issue with Angular: PUT, OPTIONS methods","I've developed a small write-only REST api with Flask Restful that accepts PUT request from a handful of clients that can potentially have changing IP addresses. My clients are embedded Chromium clients running an AngularJS front-end; they authenticate with my API with a simple magic key -- it's sufficient for my very limited scale. +I'm testing deploying my API now and I notice that the Angular clients are attempting to send an OPTIONS http methods to my Flask service. My API meanwhile is replying with a 404 (since I didn't write an OPTIONS handler yet, only a PUT handler). It seems that when sending cross-domain requests that are not POST or GET, Angular will send a pre-flight OPTIONS method at the server to make sure the cross-domain request is accepted before it sends the actual request. Is that right? Anyway, how do I allow all cross-domain PUT requests to Flask Restful API? I've used cross-domaion decorators with a (non-restful) Flask instance before, but do I need to write an OPTIONS handler as well into my API?","You can use the after_request hook: @app.after_request @@ -29097,12 +29103,6 @@ def after_request(response): response.headers.add('Access-Control-Allow-Headers', 'Content-Type,Authorization') response.headers.add('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE') return response",0.999329299739067,False,2,2876 -2013-11-13 19:31:03.547,"Flask RESTful cross-domain issue with Angular: PUT, OPTIONS methods","I've developed a small write-only REST api with Flask Restful that accepts PUT request from a handful of clients that can potentially have changing IP addresses. My clients are embedded Chromium clients running an AngularJS front-end; they authenticate with my API with a simple magic key -- it's sufficient for my very limited scale. -I'm testing deploying my API now and I notice that the Angular clients are attempting to send an OPTIONS http methods to my Flask service. My API meanwhile is replying with a 404 (since I didn't write an OPTIONS handler yet, only a PUT handler). It seems that when sending cross-domain requests that are not POST or GET, Angular will send a pre-flight OPTIONS method at the server to make sure the cross-domain request is accepted before it sends the actual request. Is that right? -Anyway, how do I allow all cross-domain PUT requests to Flask Restful API? I've used cross-domaion decorators with a (non-restful) Flask instance before, but do I need to write an OPTIONS handler as well into my API?","Just an update to this comment. Flask CORS is the way to go, but the flask.ext.cors is deprecated. -use: - -from flask_cors import CORS",0.2229491379952452,False,2,2876 2013-11-13 22:00:05.687,Performance: Class Based Views VS Function Based Views,"I'm curious about this, from a performance point of view only, how do their differ considering the proper use?",They don't differ in performance at all.,0.3869120172231254,False,1,2877 2013-11-14 10:28:33.510,how to find python-mosquitto version,"How do I see what is the version of the python-mosquitto package used by my program? How do I find an old version of python-mosquitto (version 0.15) and remove it? I'm running on Raspberry Pi, raspian","If you are using pip, use pip freeze | grep 'python-mosquitto' to get the package version, and pip remove python-mosquitto to remove it.",0.2012947653214861,False,1,2878 @@ -29216,14 +29216,10 @@ untar pyserial.tgz cd pyserial python3 setup.py install -But I'd like to do like the cool kids do, and just do something like pip3 install pyserial. But it's not clear how I get to that point. And just that point. Not interested (unless I have to be) in virtualenv yet.","brew install python3 -create alias in your shell profile - -eg. alias pip3=""python3 -m pip"" in my .zshrc - +But I'd like to do like the cool kids do, and just do something like pip3 install pyserial. But it's not clear how I get to that point. And just that point. Not interested (unless I have to be) in virtualenv yet.","pip is installed automatically with python2 using brew: -➜ ~ pip3 --version -pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)",0.296905446847765,False,3,2887 +brew install python3 +pip3 --version",0.1016881243684853,False,3,2887 2013-11-19 21:57:24.747,How to install pip for Python 3 on Mac OS X?,"OS X (Mavericks) has Python 2.7 stock installed. But I do all my own personal Python stuff with 3.3. I just flushed my 3.3.2 install and installed the new 3.3.3. So I need to install pyserial again. I can do it the way I've done it before, which is: Download pyserial from pypi @@ -29231,10 +29227,14 @@ untar pyserial.tgz cd pyserial python3 setup.py install -But I'd like to do like the cool kids do, and just do something like pip3 install pyserial. But it's not clear how I get to that point. And just that point. Not interested (unless I have to be) in virtualenv yet.","pip is installed automatically with python2 using brew: +But I'd like to do like the cool kids do, and just do something like pip3 install pyserial. But it's not clear how I get to that point. And just that point. Not interested (unless I have to be) in virtualenv yet.","brew install python3 +create alias in your shell profile -brew install python3 -pip3 --version",0.1016881243684853,False,3,2887 +eg. alias pip3=""python3 -m pip"" in my .zshrc + + +➜ ~ pip3 --version +pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)",0.296905446847765,False,3,2887 2013-11-19 21:57:24.747,How to install pip for Python 3 on Mac OS X?,"OS X (Mavericks) has Python 2.7 stock installed. But I do all my own personal Python stuff with 3.3. I just flushed my 3.3.2 install and installed the new 3.3.3. So I need to install pyserial again. I can do it the way I've done it before, which is: Download pyserial from pypi @@ -29316,6 +29316,13 @@ The tricky part is loading the code from a file in such a way that breakpoints a There are also some gotchas there - e.g. the REPL window will become unresponsive whenever you are paused on a breakpoint.",1.2,True,1,2894 2013-11-25 18:18:16.677,Removing first bit,"Is there an efficient way to remove the first bit of a number in C++ / Python, assuming you don't know how large the number is or its datatype? I know in Python I can do it by getting the bin(n), truncating the string by 1, and then recasting it to an int, but I am curious if there is a more ""mathematical"" way to do this. +e.g. say the number is 6, which is 110 in binary. Chop the first bit and it becomes 10, or 2.","looking at 110 (6 decimal) +The Most Significant bit is 100 (4 decimal) // -- Note that this is always a power of 2 +Create a mask: one less than the MSB is 011 (3 decimal) +Mask off the highest bit using bitwise-and: 110 & 011 = 10 (2 decimal) +Calculating the MSB (Most Significant Bit) has been handled here and elsewhere quite often",0.3869120172231254,False,2,2895 +2013-11-25 18:18:16.677,Removing first bit,"Is there an efficient way to remove the first bit of a number in C++ / Python, assuming you don't know how large the number is or its datatype? +I know in Python I can do it by getting the bin(n), truncating the string by 1, and then recasting it to an int, but I am curious if there is a more ""mathematical"" way to do this. e.g. say the number is 6, which is 110 in binary. Chop the first bit and it becomes 10, or 2.","Well, you could create a loop in which you would double some variable (say x) in each iteration and then check whether this variable is greater than your number. If it is, divide it by two and subtract from your number. For example, if your number is 11: -first iteration: x=1<11, so continue -second iteration: x =2<11, so continue @@ -29323,13 +29330,6 @@ e.g. say the number is 6, which is 110 in binary. Chop the first bit and it beco -fourth iteration: x=8<11, so continue -fifth iteration: x=16>11, so divide x by two: x=8. Then subtract 8 from your number and get answer: 11-8=3.",0.1618299653758019,False,2,2895 -2013-11-25 18:18:16.677,Removing first bit,"Is there an efficient way to remove the first bit of a number in C++ / Python, assuming you don't know how large the number is or its datatype? -I know in Python I can do it by getting the bin(n), truncating the string by 1, and then recasting it to an int, but I am curious if there is a more ""mathematical"" way to do this. -e.g. say the number is 6, which is 110 in binary. Chop the first bit and it becomes 10, or 2.","looking at 110 (6 decimal) -The Most Significant bit is 100 (4 decimal) // -- Note that this is always a power of 2 -Create a mask: one less than the MSB is 011 (3 decimal) -Mask off the highest bit using bitwise-and: 110 & 011 = 10 (2 decimal) -Calculating the MSB (Most Significant Bit) has been handled here and elsewhere quite often",0.3869120172231254,False,2,2895 2013-11-26 06:19:52.390,"Installing bigfloat, GMP and MPFR in windows for python","I am trying to install bigfloat in Python 3.2 on a Windows 7 machine. The documentation says that I first need to install GMP and MPFR. I have downloaded both of these to my desktop (as well as the bigfloat package). However as they are C packages I am not sure how to install them in python (I have tried to find a clear explanation for the last several hours and failed). Can any one either tell me what I need to do or point me to a tutorial? Thanks a lot, any help is greatly appreciated.","There are two versions of gmpy - version 1 (aka gmpy) and version 2 (aka gmpy2). gmpy2 includes MPFR. If you install gmpy2 then you probably don't need bigfloat since the functionality of MPFR can be directly accessed from gmpy2. Disclaimer: I maintain gmpy and gmpy2.",0.1352210990936997,False,1,2896 2013-11-26 20:59:02.030,Recommendation engine using collaborative filtering in Python,"I have developed a search engine for restaurants. I have a social network wherein users can add friends and form groups and recommend restaurants to each other. Each restaurant may serve multiple cuisines. All of this in Python. @@ -29438,9 +29438,7 @@ but the problem is one table has it is as an integer(big integer) and other tabl basically i dont want to create another database, i simply want to store two columns from each table into a file so I guess i dont need inner-join. do i? e.g. in table-1 = 9876543210 -in table-2 = ""9876543210""","Not sure if I understand what it is you want to do. You want to match a value from a column from one table to a value from a column from another table? -If you'd have the data in two tables in a database, you could make an inner join. -Depending on how big the file is, you could use a manual comparison tool like WinMerge.",0.0,False,2,2910 +in table-2 = ""9876543210""",You can use Join with alias name.,0.0,False,2,2910 2013-12-03 10:28:52.193,Compare two databases and find common value in a row,"I have two databases (infact two database dump ... db1.sql and db2.sql) both database have only 1 table in each. in each table there are few columns (not equal number nor type) but 1 or 2 columns have same type and same value @@ -29453,7 +29451,9 @@ but the problem is one table has it is as an integer(big integer) and other tabl basically i dont want to create another database, i simply want to store two columns from each table into a file so I guess i dont need inner-join. do i? e.g. in table-1 = 9876543210 -in table-2 = ""9876543210""",You can use Join with alias name.,0.0,False,2,2910 +in table-2 = ""9876543210""","Not sure if I understand what it is you want to do. You want to match a value from a column from one table to a value from a column from another table? +If you'd have the data in two tables in a database, you could make an inner join. +Depending on how big the file is, you could use a manual comparison tool like WinMerge.",0.0,False,2,2910 2013-12-03 16:01:50.257,Python: TypeError in referencing item in JSON feed,"First, here is a sample JSON feed that I want to read in Python 2.7 with either simplejson or the built in JSON decoder. I am loading the .json file in Python and then searching for a key like ""Apple"" or ""Orange"" and when that key is found, I want to bring in the information for it like the types and quantities. Right now there is only 3 items, but I want to be able to search one that may have up to 1000 items. Here is the code: @@ -29624,7 +29624,8 @@ urllib3 if my requirement is only to request a API by GET method, assume it return a JSON string. which lib I should use? do they have some duplicated functions? if the urllib can implement my require, but after if my requirements get more and more complicated, the urllib can not fit my function, I should import another lib at that time, but I really want to import only one lib, because I think import all of them can make me confused, I think the method between them are totally different. -so now I am confused which lib I should use, I prefer urllib3, I think it can fit my requirement all time, how do you think?","As Alexander says in the comments, use requests. That's all you need.",1.2,True,2,2922 +so now I am confused which lib I should use, I prefer urllib3, I think it can fit my requirement all time, how do you think?","Personally I avoid to use third-party library when possible, so I can reduce the dependencies' list and improve portability. +urllib and urllib2 are not mutually exclusive and are often mixed in the same project.",0.1352210990936997,False,2,2922 2013-12-09 09:23:03.190,Which urllib I should choose?,"as we know, python has two built-in url lib: urllib @@ -29637,8 +29638,7 @@ urllib3 if my requirement is only to request a API by GET method, assume it return a JSON string. which lib I should use? do they have some duplicated functions? if the urllib can implement my require, but after if my requirements get more and more complicated, the urllib can not fit my function, I should import another lib at that time, but I really want to import only one lib, because I think import all of them can make me confused, I think the method between them are totally different. -so now I am confused which lib I should use, I prefer urllib3, I think it can fit my requirement all time, how do you think?","Personally I avoid to use third-party library when possible, so I can reduce the dependencies' list and improve portability. -urllib and urllib2 are not mutually exclusive and are often mixed in the same project.",0.1352210990936997,False,2,2922 +so now I am confused which lib I should use, I prefer urllib3, I think it can fit my requirement all time, how do you think?","As Alexander says in the comments, use requests. That's all you need.",1.2,True,2,2922 2013-12-09 17:37:41.567,How to know if a list has an even or odd number of elements,"How can I find out if there is even, or odd, number of elements in an arbitrary list. I tried list.index() to get all of the indices... but I still don't know how I can tell the program what is an even and what is an odd number.","Even numbers are divisible by 2. Odd numbers are not. len(X) will get the length of X @@ -29691,18 +29691,18 @@ To make radiobuttons work, create a single StringVar and associate it with two o 2013-12-11 21:04:04.753,Time complexity of os.walk in Python,"I've to calculate the time-complexity of an algorithm, but in it I'm calling os.walk which I can't consider as a single operation but many. The sources of os.walk left me confused as the filetree may be ordered in many ways (1.000.000 files in a folder or a file per folder and 1.000.000 folders. I'm not an expert on time-complexities, I can't be sure on what I should consider as only an operation or many, so this left me stuck. Don't count the simlink flag, which I assume set to false to ignore them. +PD: I found the sources of os.walk in the Komodo IDE, but I wouldn't know how to find them as the javadocs.","This is too long for a comment: in CPython, a yield passes its result to the immediate caller, not directly to the ultimate consumer of the result. So, if you have recursion going R levels deep, a chain of yields at each level delivering a result back up the call stack to the ultimate consumer takes O(R) time. It also takes O(R) time to resume the R levels of recursive call to get back to the lowest level where the first yield occurred. +So each result yield'ed by walk() takes time proportional to the level in the directory tree at which the result is first yield'ed. +That's the theoretical ;-) truth. In practice, however, this makes approximately no difference unless the recursion is very deep. That's because the chain of yields, and the chain of generator resumptions, occurs ""at C speed"". In other words, it does take O(R) time, but the constant factor is so small most programs never notice this. +This is especially true of recursive generators like walk(), which almost never recurse deeply. Who has a directory tree nested 100 levels? Nope, me neither ;-)",0.5916962662253621,False,2,2931 +2013-12-11 21:04:04.753,Time complexity of os.walk in Python,"I've to calculate the time-complexity of an algorithm, but in it I'm calling os.walk which I can't consider as a single operation but many. +The sources of os.walk left me confused as the filetree may be ordered in many ways (1.000.000 files in a folder or a file per folder and 1.000.000 folders. +I'm not an expert on time-complexities, I can't be sure on what I should consider as only an operation or many, so this left me stuck. Don't count the simlink flag, which I assume set to false to ignore them. PD: I found the sources of os.walk in the Komodo IDE, but I wouldn't know how to find them as the javadocs.","os.walk (unless you prune it, or have symlink issues) guarantees to list each directory in the subtree exactly once. So, if you assume that listing a directory is linear on the number of entries in the directory,* then if there are N total directory entries in your subtree, os.walk will take O(N) time. Or, if you want the time for walk to produce each value (the root, dirnames, filenames tuple): if those N directory entries are split among M subdirectories, then each of the M iterations takes amortized O(N/M) time. * Really, that's up to your OS, C library, and filesystem not Python, and it can be much worse than O(N) for older filesystems… but let's ignore that.",0.2655860252697744,False,2,2931 -2013-12-11 21:04:04.753,Time complexity of os.walk in Python,"I've to calculate the time-complexity of an algorithm, but in it I'm calling os.walk which I can't consider as a single operation but many. -The sources of os.walk left me confused as the filetree may be ordered in many ways (1.000.000 files in a folder or a file per folder and 1.000.000 folders. -I'm not an expert on time-complexities, I can't be sure on what I should consider as only an operation or many, so this left me stuck. Don't count the simlink flag, which I assume set to false to ignore them. -PD: I found the sources of os.walk in the Komodo IDE, but I wouldn't know how to find them as the javadocs.","This is too long for a comment: in CPython, a yield passes its result to the immediate caller, not directly to the ultimate consumer of the result. So, if you have recursion going R levels deep, a chain of yields at each level delivering a result back up the call stack to the ultimate consumer takes O(R) time. It also takes O(R) time to resume the R levels of recursive call to get back to the lowest level where the first yield occurred. -So each result yield'ed by walk() takes time proportional to the level in the directory tree at which the result is first yield'ed. -That's the theoretical ;-) truth. In practice, however, this makes approximately no difference unless the recursion is very deep. That's because the chain of yields, and the chain of generator resumptions, occurs ""at C speed"". In other words, it does take O(R) time, but the constant factor is so small most programs never notice this. -This is especially true of recursive generators like walk(), which almost never recurse deeply. Who has a directory tree nested 100 levels? Nope, me neither ;-)",0.5916962662253621,False,2,2931 2013-12-12 12:34:05.943,How to save a temporary value in a security token?,"Is it possible to save a value in a security token memory by using PyKCS11 and M2Crypto? I need to save an integer to token memory, so that the value can be carried out with the token I know how to create objects, but is it possible to create attributes in a token, so whenever I read that attribute I will know the status of that token.","using PKCS#11, the only way to store 'home made' data, it through the use of a CKO_DATA object type. Like any object, it can be persistent on the token (not lost when the token is powered off) or it can be a memory object (lost when the session to the token is closed). @@ -29859,12 +29859,12 @@ An iCal alert that runs the Automator (and thus the Python script) on a regular All of the above works just fine. But I need to make a change. I need the script to check a web site for a time in the future (that same day) and then come back prior to that time and run itself again. I know how to do the first part (get the time) but I have no clue how to do the second part. How do you get a Python script to (1) run itself at a regular time and then (2) run again at some point in the future? The point in the future will change on a regular basis. Sometimes it would be as early as 10AM, other times it may be 7PM. Any thoughts on this and pseudo-code are welcome. Thanks!","Set a variable to the future time, and check it in a while() loop",0.0,False,1,2953 2013-12-28 17:07:18.940,"In PyCharm, how to navigate to the top of the file?","I'm new to PyCharm and haven't been able to figure out what I'm sure is a very simple thing -- what's the key stroke to go to the top of the current file? +(Bonus question -- is there a way to scroll to the top of the current file without moving the cursor there also, a la the Home key in Sublime Text 2?)","Another way is to navigate to the first line using goto line: Ctrl-G and then 1. But this will move the cursor to the first line. +A small disadvantage is it is a two step process and adds a navigation step. Moving back to your previous location with CtrlAlt-< will have to be done in two steps if you do an edit.",0.2012947653214861,False,2,2954 +2013-12-28 17:07:18.940,"In PyCharm, how to navigate to the top of the file?","I'm new to PyCharm and haven't been able to figure out what I'm sure is a very simple thing -- what's the key stroke to go to the top of the current file? (Bonus question -- is there a way to scroll to the top of the current file without moving the cursor there also, a la the Home key in Sublime Text 2?)","You navigate to the top of the file using Ctrl+Home. It moves cursor too. So does navigating via Page Up and Page Down keys. Ctrl+Up and Ctrl+Down move the view without moving cursor but scrolling the long file takes some time. Additionally You can change the keymap (Settings > Keymap). There is 'Scroll to Top' in 'Editor Actions'. You can use Your own key binding for this action, by default (in PyCharm 4 and later) it is not set.",1.2,True,2,2954 -2013-12-28 17:07:18.940,"In PyCharm, how to navigate to the top of the file?","I'm new to PyCharm and haven't been able to figure out what I'm sure is a very simple thing -- what's the key stroke to go to the top of the current file? -(Bonus question -- is there a way to scroll to the top of the current file without moving the cursor there also, a la the Home key in Sublime Text 2?)","Another way is to navigate to the first line using goto line: Ctrl-G and then 1. But this will move the cursor to the first line. -A small disadvantage is it is a two step process and adds a navigation step. Moving back to your previous location with CtrlAlt-< will have to be done in two steps if you do an edit.",0.2012947653214861,False,2,2954 2013-12-30 03:17:23.633,Display Python Output in Sublime text,"New to Python & Sublime Problem: I type 'print (""Hello world"") @@ -30007,11 +30007,11 @@ Not really tutorials, but pretty self-explanatory basic scripts under the follow you will find about 100 examples in 30 folders ranging from beginner to advanced, covering basic windows, menus, tabs, layouts, network, OpenGL, etc.",0.999999991970842,False,1,2970 2014-01-09 16:57:36.663,Text with multiple colors in PsychoPy,"I am messing around in PsychoPy now, trying to modify the Sternberg demo for a class project. I want the stimulus text—the number set—to display in a variety of colors: say, one digit is red, the next blue, the next brown, etc. A variety within the same stimulus. -I can only find how to change the color of the entire set. I was wondering if I could add another variable to the spreadsheet accompanying the experiment and have the values in the cells be comma separated (red,blue,brown…). Is this possible?","No, that isn't possible right now. There's an experimental new stimulus class called TextBox that will allow it, but you'd have to write code to use that (not available yet from the Builder interface). Or just create some tif images of your stimuli and use those?",1.2,True,2,2971 -2014-01-09 16:57:36.663,Text with multiple colors in PsychoPy,"I am messing around in PsychoPy now, trying to modify the Sternberg demo for a class project. I want the stimulus text—the number set—to display in a variety of colors: say, one digit is red, the next blue, the next brown, etc. A variety within the same stimulus. I can only find how to change the color of the entire set. I was wondering if I could add another variable to the spreadsheet accompanying the experiment and have the values in the cells be comma separated (red,blue,brown…). Is this possible?","The current way to implement this is to have a separate text stimulus for each digit, each with the desired colour. If the text representation of the number is contained in a variable called, say, stimulusText then in the Text field for the first text component put ""$stimulusText[0]"" so that it contains just the first digit. In the next text component , use ""$stimulusText[1]"", and so on. The colour of each text component can be either fixed or vary according to separate column variables specified in a conditions file.",0.3869120172231254,False,2,2971 +2014-01-09 16:57:36.663,Text with multiple colors in PsychoPy,"I am messing around in PsychoPy now, trying to modify the Sternberg demo for a class project. I want the stimulus text—the number set—to display in a variety of colors: say, one digit is red, the next blue, the next brown, etc. A variety within the same stimulus. +I can only find how to change the color of the entire set. I was wondering if I could add another variable to the spreadsheet accompanying the experiment and have the values in the cells be comma separated (red,blue,brown…). Is this possible?","No, that isn't possible right now. There's an experimental new stimulus class called TextBox that will allow it, but you'd have to write code to use that (not available yet from the Builder interface). Or just create some tif images of your stimuli and use those?",1.2,True,2,2971 2014-01-10 00:10:53.093,"how to write a Python program that reads from a text file, and builds a dictionary which maps each word","I am having difficulties with writing a Python program that reads from a text file, and builds a dictionary which maps each word that appears in the file to a list of all the words that immediately follow that word in the file. The list of words can be in any order and should include duplicates. For example,the key ""and"" might have the list [""then"", ""best"", ""after"", ...] listing all the words which came after ""and"" in the text. Any idea would be great help.","A couple of ideas: @@ -30065,11 +30065,6 @@ help me please","Yes, for repeat sample from one population, @MaxLascombe's answ So I have a question about unit testing, not necessarily about Python, but since I'm working with Python at the moment I chose to base my question on it. I get the idea of unit testing, but the only thing I can find on the internet are the very simple unit tests. Like testing if the method sum(a, b) returns the sum of a + b. But how do you apply unit testing when dealing with a more complex program? As an example, I have written a crawler. I don't know what it will return, else I wouldn't need the crawler. So how can I test that the crawler works properly without knowing what the method will return? -Thanks in advance!","Unit testing verifies that your code does what you expect in a given environment. You should make sure all other variables are as you expect them to be and test your single method. To do that for methods which use third party APIs, you should probably mock them using a mocking library. By mocking you provide data you expect and verify that your method works as expected. You can also try to separate your code so that the part which makes API request and the part that parses/uses it are separate and unit test that second part with a certain API example response you provide.",0.0,False,2,2984 -2014-01-18 11:47:17.300,Python - unit testing,"Sorry if this is a really dumb question but I've been searching for ages and just can't figure it out. -So I have a question about unit testing, not necessarily about Python, but since I'm working with Python at the moment I chose to base my question on it. -I get the idea of unit testing, but the only thing I can find on the internet are the very simple unit tests. Like testing if the method sum(a, b) returns the sum of a + b. -But how do you apply unit testing when dealing with a more complex program? As an example, I have written a crawler. I don't know what it will return, else I wouldn't need the crawler. So how can I test that the crawler works properly without knowing what the method will return? Thanks in advance!","The whole crawler would be probably tested functionally (we'll get there). As for unit testing, you have probably written your crawler with several components, like page parser, url recogniser, fetcher, redirect handler, etc. These are your UNITS. You should unit tests each of them, or at least those with at least slightly complicated logic, where you can expect some output for some input. Remember, that sometimes you'll test behaviour, not input/output, and this is where mocks and stubs may come handy. As for functional testing - you'll need to create some test scenarios, like webpage with links to other webpages that you'll create, and set them up on some server. Then you'll need to perform crawling on webpages YOU created, and check whether your crawler is behaving as expected (you should know what to expect, because you;ll be creating those pages). Also, sometimes it is good to perform integration tests between unit and functional testing. If you have some components working together (for example fetcher using redirect handler) it is good to check whether those two work together as expected (for example, you may create resource on your own server, that when fetched will return redirect HTTP code, and check whether it is handled as expected). @@ -30078,6 +30073,11 @@ So, in the end: create unit tests for components creating your app, to see if you haven't made simple mistake create integration tests for co-working components, to see if you glued everything together just fine create functional tests, to be sure that your app will work as expected (because some errors may come from project, not from implementation)",1.2,True,2,2984 +2014-01-18 11:47:17.300,Python - unit testing,"Sorry if this is a really dumb question but I've been searching for ages and just can't figure it out. +So I have a question about unit testing, not necessarily about Python, but since I'm working with Python at the moment I chose to base my question on it. +I get the idea of unit testing, but the only thing I can find on the internet are the very simple unit tests. Like testing if the method sum(a, b) returns the sum of a + b. +But how do you apply unit testing when dealing with a more complex program? As an example, I have written a crawler. I don't know what it will return, else I wouldn't need the crawler. So how can I test that the crawler works properly without knowing what the method will return? +Thanks in advance!","Unit testing verifies that your code does what you expect in a given environment. You should make sure all other variables are as you expect them to be and test your single method. To do that for methods which use third party APIs, you should probably mock them using a mocking library. By mocking you provide data you expect and verify that your method works as expected. You can also try to separate your code so that the part which makes API request and the part that parses/uses it are separate and unit test that second part with a certain API example response you provide.",0.0,False,2,2984 2014-01-18 16:14:24.520,Use template html page with BaseHttpRequestHandler,"I am building a small program with Python, and I would like to have a GUI for some configuration stuff. Now I have started with a BaseHTTPServer, and I am implementing a BaseHTTPRequestHandler to handle GET and POST requests. But I am wondering what would be best practice for the following problem. I have two separate requests that result in very similar responses. That is, the two pages that I return have a lot of html in common. I could create a template html page that I retrieve when either of these requests is done and fill in the missing pieces according to the specific request. But I feel like there should be a way where I could directly retrieve two separate html pages, for the two requests, but still have one template page so that I don't have to copy this. I would like to know how I could best handle this, e.g. something scalable. Thanks!","This has nothing to do with BaseHTTPRequestHandler as its purpose is to serve HTML, how you generate the HTML is another topic. @@ -30266,9 +30266,8 @@ Computer Service Desk Support I would like my algorithm to create something like below: (Service OR Help)->(Desk)->(Analyst OR Support) ...where Service and Help are both root nodes, and both Analyst and Support are children of Desk Basically, I need the following: I would like this matching algorithm to be able to reduce the strings it is presented with to a minimal number of sub-strings which effectively match all of the strings in a given cateogory (preferably using a decision tree). -If I am not being clear enough, just let me know!","This sounds like a clustering, or unsupervised, problem rather than a decision tree one (do you know all the roles in advance, and can you provide labelled data). -If it were me, I'd be tempted to build a bag-of-words style representation of your strings and run a generic clustering algorithm (k-means, say) to see what came out. Deciding on a category to assign a new string to is then a fairly simple matching operation (depending on what you use to do the clustering). -You could also look at topic models, with the simplest being Latent Dirichlet Allocation, as being of potential application here. You'd get an assignment to a topic per-word, not per string, but that could be altered if you tweaked the method.",0.0,False,2,3010 +If I am not being clear enough, just let me know!","There were suggestions about unsupervised learning, but I recommend to use supervised learning, so you'll categorize 100-200 positions manually, and then algo will do the rest. +There are number of resources, libraries, etc. - look please at ""Programming Collective Intelligence"" book - they provided good machine learning topics with python examples.",0.0,False,2,3010 2014-02-01 16:47:45.430,Python - A way to learn and detect text patterns?,"Problem: I am given a long list of various position titles for jobs in the IT industry (support or development); I need to automatically categorize them based on the general type of job they represent. For example, IT-support analyst, help desk analyst... etc. Could all belong to the group IT-Support. Current Approach: @@ -30292,8 +30291,9 @@ Computer Service Desk Support I would like my algorithm to create something like below: (Service OR Help)->(Desk)->(Analyst OR Support) ...where Service and Help are both root nodes, and both Analyst and Support are children of Desk Basically, I need the following: I would like this matching algorithm to be able to reduce the strings it is presented with to a minimal number of sub-strings which effectively match all of the strings in a given cateogory (preferably using a decision tree). -If I am not being clear enough, just let me know!","There were suggestions about unsupervised learning, but I recommend to use supervised learning, so you'll categorize 100-200 positions manually, and then algo will do the rest. -There are number of resources, libraries, etc. - look please at ""Programming Collective Intelligence"" book - they provided good machine learning topics with python examples.",0.0,False,2,3010 +If I am not being clear enough, just let me know!","This sounds like a clustering, or unsupervised, problem rather than a decision tree one (do you know all the roles in advance, and can you provide labelled data). +If it were me, I'd be tempted to build a bag-of-words style representation of your strings and run a generic clustering algorithm (k-means, say) to see what came out. Deciding on a category to assign a new string to is then a fairly simple matching operation (depending on what you use to do the clustering). +You could also look at topic models, with the simplest being Latent Dirichlet Allocation, as being of potential application here. You'd get an assignment to a topic per-word, not per string, but that could be altered if you tweaked the method.",0.0,False,2,3010 2014-02-01 22:40:51.917,How do I tell Aptana Studio to use Python virtualenv?,"I did some searches on this topic and the solutions didn't work for me. I am running both a Linux (Ubuntu) environment and Windows. My system is Windows 8.1 but I have virtualbox with Ubuntu on that. Starting with Windows... I created a venv directory off the root of the e drive. Created a project folder and then ran the activate command, which is in the venv>Scripts directory. So, after activating that (note, I had installed virtualenv already)... so after activating that I then changed into the folder with my module and it ran fine, with the shebang, I didn't even have to type python in front of my filename. However, in Aptana Studio, it cannot find the module I installed with pip. So, it doesn't work. In an earlier post it was recommended that one choose a different interpreter and browse to the env and select that. So, how does one get this installed and working with an IDE like Eclipse and Aptana Studio? @@ -30470,7 +30470,13 @@ I have saved my module as pb3.py and am executing it within the command line lik python -m pb3 The execution does indeed stop at the breakpoint, but within di pdb (ipdb) console, the commands indicated don't display anything - or display a NameError -If more info is needed, i will provide it.",Use the break command. Don't add any line numbers and it will list all instead of adding them.,0.9999665971563038,False,2,3022 +If more info is needed, i will provide it.","info breakpoints + +or just + +info b + +lists all breakpoints.",-0.9051482536448664,False,2,3022 2014-02-05 16:10:28.280,How to find the breakpoint numbers in pdb (ipdb)?,"Trying to find how to execute ipdb (or pdb) commands such as disable. Calling the h command on disable says @@ -30515,13 +30521,7 @@ I have saved my module as pb3.py and am executing it within the command line lik python -m pb3 The execution does indeed stop at the breakpoint, but within di pdb (ipdb) console, the commands indicated don't display anything - or display a NameError -If more info is needed, i will provide it.","info breakpoints - -or just - -info b - -lists all breakpoints.",-0.9051482536448664,False,2,3022 +If more info is needed, i will provide it.",Use the break command. Don't add any line numbers and it will list all instead of adding them.,0.9999665971563038,False,2,3022 2014-02-05 21:03:41.120,Using python2.7 with Emacs 24.3 and python-mode.el,"I'm new to Emacs and I'm trying to set up my python environment. So far I've learned that using ""python-mode.el"" in a python buffer C-c C-c loads the contents of the current buffer into an interactive python shell, apparently using what which python yields. In my case that is python 3.3.3. But since I need to get a python 2.7 shell, I'm trying to get Emacs to spawn such a shell on C-c C-c. Unfortunatly I can't figure out, how to do this. Setting py-shell-name to what which python2.7 yields (i.e. /usr/bin/python2.7) does not work. How can get Emacs to do this, or how can I trace back what Emacs executes when I hit C-c C-c?","I don't use python, but from the source to python-mode, I think you should look into customizing the variable python-python-command - It seems to default to the first path command matching ""python""; perhaps you can supply it with a custom path?",0.0,False,1,3023 2014-02-07 01:25:20.650,Where should I save the Amazon Manifest json file on an app hosted at PythonAnywhere?,"I am trying to have my app on Amazon appstore. In order to do this Amazon needs to park a small json file (web-app-manifest.json). @@ -30606,9 +30606,7 @@ The shelve module does not support concurrent read/write access to Personally, at this point, you may want to look into using a simple key-value store like Redis with some kind of optimistic locking.",1.2,True,1,3034 2014-02-13 13:25:06.517,IPython notebook - unable to export to pdf,"I'm trying to export my IPython notebook to pdf, but somehow I can't figure out how to do that. I searched through stackoverflow and already read about nbconvert, but where do I type that command? In the notebook? In the cmd prompt? If someone can tell me, step by step, what to do? I'm using Python 3.3 and IPython 1.1.0. -Thank you in advance :)","open terminal -navigate to the directory of your notebook -ipython nbconvert mynotebook.ipynb --to latex --post PDF",0.1352210990936997,False,3,3035 +Thank you in advance :)",ipython nbconvert notebook.ipynb --to pdf,0.0679224682270276,False,3,3035 2014-02-13 13:25:06.517,IPython notebook - unable to export to pdf,"I'm trying to export my IPython notebook to pdf, but somehow I can't figure out how to do that. I searched through stackoverflow and already read about nbconvert, but where do I type that command? In the notebook? In the cmd prompt? If someone can tell me, step by step, what to do? I'm using Python 3.3 and IPython 1.1.0. Thank you in advance :)","I was facing the same problem. I tried to use the option select File --> Download as --> Pdf via LaTeX (.pdf) in the notebook but it did not worked for me(It is not working for me). I tried other options too still not working. @@ -30634,7 +30632,9 @@ Now go to print option. From here you can save this file in pdf file format. Note that from print option we also have the flexibility of selecting a portion of a notebook to save in pdf format.",0.0679224682270276,False,3,3035 2014-02-13 13:25:06.517,IPython notebook - unable to export to pdf,"I'm trying to export my IPython notebook to pdf, but somehow I can't figure out how to do that. I searched through stackoverflow and already read about nbconvert, but where do I type that command? In the notebook? In the cmd prompt? If someone can tell me, step by step, what to do? I'm using Python 3.3 and IPython 1.1.0. -Thank you in advance :)",ipython nbconvert notebook.ipynb --to pdf,0.0679224682270276,False,3,3035 +Thank you in advance :)","open terminal +navigate to the directory of your notebook +ipython nbconvert mynotebook.ipynb --to latex --post PDF",0.1352210990936997,False,3,3035 2014-02-14 17:38:23.173,Display a file to the user with Python,"I am trying to find a way to display a txt/csv file to the user of my Python script. Everytime I search how to do it, I keep finding information on how to open/read/write etc ... But I just want to display the file to the user. Thank you in advance for your help.","It really depends what you mean by ""display"" the file. When we display text, we need to take the file, get all of its text, and put it onto the screen. One possible display would be to read every line and print them. There are certainly others. You're going to have to open the file and read the lines in order to display it, though, unless you make a shell command to something like vim file.txt.",0.2012947653214861,False,1,3036 2014-02-14 20:01:14.333,wxpython GUI program to exe using py2exe,"I am new to python programming and development. After much self study through online tutorials I have been able to make a GUI with wxpython. This GUI interacts with a access database in my computer to load list of teams and employees into the comboboxes. @@ -30650,11 +30650,11 @@ I want to filter for rows with a certain maximum delta between expiration and da When doing fr.expiration - fr.date I obtain timedelta values, but don't know how to get a filter criteria such as fr[timedelta(fr.expiration-fr.date)<=60days]","for the 60 days you're looking to compare to, create a timedelta object of that value timedelta(days=60) and use that for the filter. and if you're already getting timedelta objects from the subtraction, recasting it to a timedelta seems unnecessary. and finally, make sure you check the signs of the timedeltas you're comparing.",0.5457054096481145,False,1,3038 -2014-02-14 23:57:26.587,Python development on Mac OS X: pure Mac OS or linux in virtualbox,"I'm new to Mac, and I have OS X 10.9.1. The main question is whether it is better to create a virtual machine with Linux and do port forwarding or set all packages directly to the Mac OS and work with it directly? If I create a virtual machine, I'm not sure how it will affect the health of SSD and ease of development. On the other hand, I also do not know how to affect the stability and performance of Mac OS installation packages directly into it. Surely there are some best practices, but I do not know them.",I do all of my main development on OSX. I deploy on a linux box. Pycharm (CE) is your friend.,0.3869120172231254,False,2,3039 2014-02-14 23:57:26.587,Python development on Mac OS X: pure Mac OS or linux in virtualbox,"I'm new to Mac, and I have OS X 10.9.1. The main question is whether it is better to create a virtual machine with Linux and do port forwarding or set all packages directly to the Mac OS and work with it directly? If I create a virtual machine, I'm not sure how it will affect the health of SSD and ease of development. On the other hand, I also do not know how to affect the stability and performance of Mac OS installation packages directly into it. Surely there are some best practices, but I do not know them.","On my Mac, I use Python and PyCharm and all the usual Unix tools, and I've always done just fine. Regard OS X as a Unix machine with a very nice GUI on top of it, because it basically is -- Mac OS X is POSIX-compliant, with BSD underpinnings. Why would you even consider doing VirtualBox'd Linux? Even if you don't want to relearn the hotkeys, PyCharm provides a non-OS X mapping, and in Terminal, CTRL and ALT work like you expect. If you're used to developing on Windows but interfacing with Unix machines through Cygwin, you'll be happy to use Terminal, which is a normal bash shell and has (or can easily get through Homebrew) all the tools you're used to. Plus the slashes go the right way and line endings don't need conversion. If you're used to developing on a Linux distro, you'll be happy with all the things that ""just work"" and let you move on with your life. So in answer to your question, do straight Mac OS X. Working in a virtualized Linux environment imparts a cost and gains you nothing.",1.2,True,2,3039 +2014-02-14 23:57:26.587,Python development on Mac OS X: pure Mac OS or linux in virtualbox,"I'm new to Mac, and I have OS X 10.9.1. The main question is whether it is better to create a virtual machine with Linux and do port forwarding or set all packages directly to the Mac OS and work with it directly? If I create a virtual machine, I'm not sure how it will affect the health of SSD and ease of development. On the other hand, I also do not know how to affect the stability and performance of Mac OS installation packages directly into it. Surely there are some best practices, but I do not know them.",I do all of my main development on OSX. I deploy on a linux box. Pycharm (CE) is your friend.,0.3869120172231254,False,2,3039 2014-02-15 20:07:20.453,Computing K-means clustering on Location data in Python,"I have a dataset of users and their music plays, with every play having location data. For every user i want to cluster their plays to see if they play music in given locations. I plan on using the sci-kit learn k-means package, but how do I get this to work with location data, as opposed to its default, euclidean distance? An example of it working would really help me!","Is the data already in vector space e.g. gps coordinates? If so you can cluster on it directly, lat and lon are close enough to x and y that it shouldn't matter much. If not, preprocessing will have to be applied to convert it to a vector space format (table lookup of locations to coords for instance). Euclidean distance is a good choice to work with vector space data. @@ -30752,14 +30752,14 @@ To get rid of the self-flow on that one bad node sparsely: repeatedly grab a flo 2014-02-20 20:23:51.020,How to label certain x values,"I want to plot weather data over the span of several days every half hour, but I only want to label the days at the start as a string in the format 'mm/dd/yy'. I want to leave the rest unmarked. I would also want to control where such markings are placed along the x axis, and control the range of the axis. I also want to plot multiple sets of measurements taken over different intervals on the same figure. Therefore being able to set the axis and plot the measurements for a given day would be best. -Any suggestions on how to approach this with matplotlib?","Matplotlib xticks are your friend. Will allow you to set where the ticks appear. -As for date formatting, make sure you're using dateutil objects, and you'll be able to handle the formatting.",0.1352210990936997,False,2,3051 -2014-02-20 20:23:51.020,How to label certain x values,"I want to plot weather data over the span of several days every half hour, but I only want to label the days at the start as a string in the format 'mm/dd/yy'. I want to leave the rest unmarked. -I would also want to control where such markings are placed along the x axis, and control the range of the axis. -I also want to plot multiple sets of measurements taken over different intervals on the same figure. Therefore being able to set the axis and plot the measurements for a given day would be best. Any suggestions on how to approach this with matplotlib?","You can use a DayLocator as in: plt.gca().xaxis.set_major_locator(dt.DayLocator()) And DateFormatter as in: plt.gca().xaxis.set_major_formatter(dt.DateFormatter(""%d/%m/%Y"")) Note: import matplotlib.dates as dt",0.2655860252697744,False,2,3051 +2014-02-20 20:23:51.020,How to label certain x values,"I want to plot weather data over the span of several days every half hour, but I only want to label the days at the start as a string in the format 'mm/dd/yy'. I want to leave the rest unmarked. +I would also want to control where such markings are placed along the x axis, and control the range of the axis. +I also want to plot multiple sets of measurements taken over different intervals on the same figure. Therefore being able to set the axis and plot the measurements for a given day would be best. +Any suggestions on how to approach this with matplotlib?","Matplotlib xticks are your friend. Will allow you to set where the ticks appear. +As for date formatting, make sure you're using dateutil objects, and you'll be able to handle the formatting.",0.1352210990936997,False,2,3051 2014-02-21 00:56:51.697,Reading values over ssh in python,"I would like to be able to gather the values for number of CPUs on a server and stuff like storage space etc and assign them to local variables in a python script. I have paramiko set up, so I can SSH to remote Linux nodes and run arbitrary commands on them, and then have the output returned to the script. However, many commands are very verbose ""such as df -h"", when all I want to assign is a single integer or value. For the case of number of CPUs, there is Python functionality such as through the psutil module to get this value. Such as 'psutil.NUM_CPUS' which returns an integer. However, while I can run this locally, I can't exactly execute it on remote nodes as they don't have the python environment configured. I am wondering how common it is to manually parse output of linux commands (such as df -h etc) and then grab an integer from it (similar to how bash has a ""cut"" function). Or whether it is somehow better to set up an environment on each remote server (or a better way).","If you can put your own programs or scripts on the remote machine there are a couple of things you can do: @@ -30824,8 +30824,8 @@ Run command prompt as administrator Give the command easy_install -m pip This may not uninstall pip completely. So again give this command pip uninstall pip If by previous command pip got uninstalled then this command wont run, else it will completely remove pip Now check by giving command pip --version This should give pip is not recognized as an internal or external command",0.2655860252697744,False,1,3062 -2014-02-27 01:15:24.537,Installed Python from source and cannot import Tkinter - how to install?,"I installed Python 2.6 from source for software testing (2.7 was preinstalled on my Linux distro). However, I cannot import Tkinter within 2.6, I suppose because it doesn't know where to find Tk. How do I either help 2.6 find the existing Tkinter install or reinstall Tkinter for 2.6?",Install the TCL and Tk development files and rebuild Python.,0.1352210990936997,False,3,3063 2014-02-27 01:15:24.537,Installed Python from source and cannot import Tkinter - how to install?,"I installed Python 2.6 from source for software testing (2.7 was preinstalled on my Linux distro). However, I cannot import Tkinter within 2.6, I suppose because it doesn't know where to find Tk. How do I either help 2.6 find the existing Tkinter install or reinstall Tkinter for 2.6?",Have you tried using pip-2.6 install package?,-0.1352210990936997,False,3,3063 +2014-02-27 01:15:24.537,Installed Python from source and cannot import Tkinter - how to install?,"I installed Python 2.6 from source for software testing (2.7 was preinstalled on my Linux distro). However, I cannot import Tkinter within 2.6, I suppose because it doesn't know where to find Tk. How do I either help 2.6 find the existing Tkinter install or reinstall Tkinter for 2.6?",Install the TCL and Tk development files and rebuild Python.,0.1352210990936997,False,3,3063 2014-02-27 01:15:24.537,Installed Python from source and cannot import Tkinter - how to install?,"I installed Python 2.6 from source for software testing (2.7 was preinstalled on my Linux distro). However, I cannot import Tkinter within 2.6, I suppose because it doesn't know where to find Tk. How do I either help 2.6 find the existing Tkinter install or reinstall Tkinter for 2.6?","I solved this by adding '/usr/lib/x86_64-linux-gnu' to lib_dirs in setup.py, then rebuilding python",1.2,True,3,3063 2014-02-27 11:54:53.770,How to re-architect a portal for creating mobile app,"Currently I am working on a portal which is exposed to end users. This portal is developed using Python 2.7, Django 1.6 and MySQL. Now we want to expose this portal as a mobile app. But current design does not support that as templates, views and database are tightly coupled with each other. So we decided to re-architect the whole portal. After some research I found following: @@ -30918,13 +30918,13 @@ Put all of the tutorial files under a separate directory with a clear name, e.g. If you are delivering documentation then use a separate repository for your generated documents that is used to store the deliveries. Always generate documents to a location outside of you code tree. Put your invocation of sphinx-apidoc into a batch or make file so that you are consistent with the settings that you use.",1.2,True,1,3067 -2014-02-28 21:42:27.107,How do I install pyPDF2 module using windows?,As a newbie... I am having difficulties installing pyPDF2 module. I have downloaded. Where and how do I install (setup.py) so I can use module in python interpreter?,"Here's how I did it: -After you have downloaded and installed Python (it usually installs under C:\Python** (** being python version - usually 27)), copy the extracted PyPDF2 contents to C:\Python** folder, after that enter in command prompt/terminal ""cd C:\Python27\python.exe setup.py install"". If you did everything right it should start installing PyPDF2.",0.1016881243684853,False,2,3068 2014-02-28 21:42:27.107,How do I install pyPDF2 module using windows?,As a newbie... I am having difficulties installing pyPDF2 module. I have downloaded. Where and how do I install (setup.py) so I can use module in python interpreter?,"If you have pip, PyPDF2 is on the Python Package Index, so you can install it with the following in your terminal/command prompt: Python 2: pip install PyPDF2 Python 3: pip3 install PyPDF2",0.9999449286177708,False,2,3068 +2014-02-28 21:42:27.107,How do I install pyPDF2 module using windows?,As a newbie... I am having difficulties installing pyPDF2 module. I have downloaded. Where and how do I install (setup.py) so I can use module in python interpreter?,"Here's how I did it: +After you have downloaded and installed Python (it usually installs under C:\Python** (** being python version - usually 27)), copy the extracted PyPDF2 contents to C:\Python** folder, after that enter in command prompt/terminal ""cd C:\Python27\python.exe setup.py install"". If you did everything right it should start installing PyPDF2.",0.1016881243684853,False,2,3068 2014-03-01 05:29:55.513,Insert a new database in redis using redis.StrictRedis(),"I know that Redis have 16 databases by default, but what if i need to add another database, how can i do that using redis-py?","You cannot. The number of databases is not a dynamic parameter in Redis. You can change it by updating the Redis configuration file (databases parameter) and restarting the server. From a client (Python or other), you can retrieve this value using the ""GET CONFIG DATABASES"" command. But the ""SET CONFIG DATABASES xxx"" command will be rejected.",0.0,False,1,3069 @@ -30947,17 +30947,17 @@ I hope this gets you going in the right direction.",0.0,False,1,3070 Aside from the particular strengths and weaknesses intrinsic to both programming languages, I'm wondering if there is any heuristic guidelines for making a decision on which way to go, based on the packages themselves. I'm thinking in terms of speed of training a model, scalability, availability of different kernels, and other such performance-related aspects. Given some data sets of different sizes, how could one decide which path to take? -I apologize in advance for such a possibly vague question.","I do not have experiece with e1070, however from googling it it seems that it either uses or is based on LIBSVM (I don't know enough R to determine which from the cran entry). Scilearnkit also uses LIBSVM. -In both cases the model is going to be trained by LIBSVM. Speed, scalability, variety of options available is going to be exactly the same, and in using SVMs with these libraries the main limitations you will face are the limitations of LIBSVM. -I think that giving further advice is going to be difficult unless you clarify a couple of things in your question: what is your objective? Do you already know LIBSVM? Is this a learning project? Who is paying for your time? Do you feel more comfortable in Python or in R?",1.2,True,2,3071 -2014-03-02 00:52:54.350,"What's the difference between using libSVM in sci-kit learn, or e1070 in R, for training and using support vector machines?","Recently I was contemplating the choice of using either R or Python to train support vector machines. -Aside from the particular strengths and weaknesses intrinsic to both programming languages, I'm wondering if there is any heuristic guidelines for making a decision on which way to go, based on the packages themselves. -I'm thinking in terms of speed of training a model, scalability, availability of different kernels, and other such performance-related aspects. -Given some data sets of different sizes, how could one decide which path to take? I apologize in advance for such a possibly vague question.","Sometime back I had the same question. Yes, both e1070 and scikit-learn use LIBSVM. I have experience with e1070 only. But there are some areas where R is better. I have read in the past that Python does not handle categorical features properly (at least not right out of the box). This could be a big deal for some. I also prefer R's formula interface. And some of the nice data manipulation packages. Python is definitely better for general purpose programming and scikit-learn aids in using a single programming language for all tasks.",0.0,False,2,3071 +2014-03-02 00:52:54.350,"What's the difference between using libSVM in sci-kit learn, or e1070 in R, for training and using support vector machines?","Recently I was contemplating the choice of using either R or Python to train support vector machines. +Aside from the particular strengths and weaknesses intrinsic to both programming languages, I'm wondering if there is any heuristic guidelines for making a decision on which way to go, based on the packages themselves. +I'm thinking in terms of speed of training a model, scalability, availability of different kernels, and other such performance-related aspects. +Given some data sets of different sizes, how could one decide which path to take? +I apologize in advance for such a possibly vague question.","I do not have experiece with e1070, however from googling it it seems that it either uses or is based on LIBSVM (I don't know enough R to determine which from the cran entry). Scilearnkit also uses LIBSVM. +In both cases the model is going to be trained by LIBSVM. Speed, scalability, variety of options available is going to be exactly the same, and in using SVMs with these libraries the main limitations you will face are the limitations of LIBSVM. +I think that giving further advice is going to be difficult unless you clarify a couple of things in your question: what is your objective? Do you already know LIBSVM? Is this a learning project? Who is paying for your time? Do you feel more comfortable in Python or in R?",1.2,True,2,3071 2014-03-02 19:27:46.970,"what does +=, -=, *= and /= stand for in Python?","what does +=, -=, *= and /= @@ -30976,6 +30976,15 @@ x=6; x/=2; x will be 3",0.0814518047658113,False,1,3072 2014-03-03 10:02:12.037,Examples on N-D arrays usage,"I was surprised when I started learning numpy that there are N dimensional arrays. I'm a programmer and all I thought that nobody ever use more than 2D array. Actually I can't even think beyond a 2D array. I don't know how think about 3D, 4D, 5D arrays or more. I don't know where to use them. +Can you please give me examples of where 3D, 4D, 5D ... etc arrays are used? And if one used numpy.sum(array, axis=5) for a 5D array would what happen?","A few simple examples are: + +A n x m 2D array of p-vectors represented as an n x m x p 3D matrix, as might result from computing the gradient of an image +A 3D grid of values, such as a volumetric texture +These can even be combined in the case of a gradient of a volume in which case you get a 4D matrix +Staying with the graphics paradigm, adding time adds an extra dimension, so a time-variant 3D gradient texture would be 5D + +numpy.sum(array, axis=5) is not valid for a 5D-array (as axes are numbered starting at 0)",0.0814518047658113,False,5,3073 +2014-03-03 10:02:12.037,Examples on N-D arrays usage,"I was surprised when I started learning numpy that there are N dimensional arrays. I'm a programmer and all I thought that nobody ever use more than 2D array. Actually I can't even think beyond a 2D array. I don't know how think about 3D, 4D, 5D arrays or more. I don't know where to use them. Can you please give me examples of where 3D, 4D, 5D ... etc arrays are used? And if one used numpy.sum(array, axis=5) for a 5D array would what happen?","Practical applications are hard to come up with but I can give you a simple example for 3D. Imagine taking a 3D world (a game or simulation for example) and splitting it into equally sized cubes. Each cube could contain a specific value of some kind (a good example is temperature for climate modelling). The matrix can then be used for further operations (simple ones like calculating its Transpose, its Determinant etc...). I recently had an assignment which involved modelling fluid dynamics in a 2D space. I could have easily extended it to work in 3D and this would have required me to use a 3D matrix instead. @@ -30986,15 +30995,6 @@ Can you please give me examples of where 3D, 4D, 5D ... etc arrays are used? And For a given time, the first two axes would give the coordinate of a pixel in the image, and the corresponding value would give the color of this pixel, or a grey scale level. The third axis would then represent time. For each time slot, you have a complete image. In this example, numpy.sum(array, axis=2) would integrate the exposure in a given pixel. If you think about a film taken in low light conditions, you could think of doing something like that to be able to see anything.",0.0,False,5,3073 2014-03-03 10:02:12.037,Examples on N-D arrays usage,"I was surprised when I started learning numpy that there are N dimensional arrays. I'm a programmer and all I thought that nobody ever use more than 2D array. Actually I can't even think beyond a 2D array. I don't know how think about 3D, 4D, 5D arrays or more. I don't know where to use them. -Can you please give me examples of where 3D, 4D, 5D ... etc arrays are used? And if one used numpy.sum(array, axis=5) for a 5D array would what happen?","A few simple examples are: - -A n x m 2D array of p-vectors represented as an n x m x p 3D matrix, as might result from computing the gradient of an image -A 3D grid of values, such as a volumetric texture -These can even be combined in the case of a gradient of a volume in which case you get a 4D matrix -Staying with the graphics paradigm, adding time adds an extra dimension, so a time-variant 3D gradient texture would be 5D - -numpy.sum(array, axis=5) is not valid for a 5D-array (as axes are numbered starting at 0)",0.0814518047658113,False,5,3073 -2014-03-03 10:02:12.037,Examples on N-D arrays usage,"I was surprised when I started learning numpy that there are N dimensional arrays. I'm a programmer and all I thought that nobody ever use more than 2D array. Actually I can't even think beyond a 2D array. I don't know how think about 3D, 4D, 5D arrays or more. I don't know where to use them. Can you please give me examples of where 3D, 4D, 5D ... etc arrays are used? And if one used numpy.sum(array, axis=5) for a 5D array would what happen?","There are so many examples... The way you are trying to represent it is probably wrong, let's take a simple example: You have boxes and a box stores N items in it. You can store up to 100 items in each box. @@ -31021,7 +31021,7 @@ runtime ""python"" exec ""rackspace.py"" pip ""pyrax"" full_remote_build true -Then I simply import pyrax in my python file.",It's difficult to know for sure what's happening without being able to see a traceback. Do you get anything like that which could be used to help figure out what's going on?,0.0,False,2,3075 +Then I simply import pyrax in my python file.","I figured out that it was a bad Ruby install. No idea why, but reinstalling it worked.",0.3869120172231254,False,2,3075 2014-03-03 14:10:16.427,"pip ""pyrax"" dependency with iron worker","I created a Python script to use Rackspace's API (Pyrax) to handle some image processing. It works perfect locally, but when I upload it to Iron.io worker, it builds but does not import. I am using a Windows 8 pc, but my boss runs OS X and uploading the exact worker package, it works fine. So I'm thinking it's something with Windows 8 but I don't know how to check/fix. I do apologize in advance if I ramble or do not explain things clearly enough but any help would be greatly appreciated. @@ -31030,7 +31030,7 @@ runtime ""python"" exec ""rackspace.py"" pip ""pyrax"" full_remote_build true -Then I simply import pyrax in my python file.","I figured out that it was a bad Ruby install. No idea why, but reinstalling it worked.",0.3869120172231254,False,2,3075 +Then I simply import pyrax in my python file.",It's difficult to know for sure what's happening without being able to see a traceback. Do you get anything like that which could be used to help figure out what's going on?,0.0,False,2,3075 2014-03-03 22:58:00.637,(Text Classification) Handling same words but from different documents [TFIDF ],"So I'm making a python class which calculates the tfidf weight of each word in a document. Now in my dataset I have 50 documents. In these documents many words intersect, thus having multiple same word features but with different tfidf weight. So the question is how do I sum up all the weights into one singular weight?","First, let's get some terminology clear. A term is a word-like unit in a corpus. A token is a term at a particular location in a particular document. There can be multiple tokens that use the same term. For example, in my answer, there are many tokens that use the term ""the"". But there is only one term for ""the"". I think you are a little bit confused. TF-IDF style weighting functions specify how to make a per term score out of the term's token frequency in a document and the background token document frequency in the corpus for each term in a document. TF-IDF converts a document into a mapping of terms to weights. So more tokens sharing the same term in a document will increase the corresponding weight for the term, but there will only be one weight per term. There is no separate score for tokens sharing a term inside the doc.",1.2,True,1,3076 2014-03-04 07:01:33.153,Permission to get the source code using spider,"I am working on creating a web spider in python. Do i have to worry about permissions from any sites for scanning there content? If so, how do i get those? Thanks in advance","robots.txt file does have limits. @@ -31153,9 +31153,9 @@ Display some of the data on the html view via jinja2 template values. The other is using hidden input form with angular data bind. Both of them not so nicely. 4.Compute the data and draw back to the view using d3js or other js lib. Any idea about this? I reckon there might be some angular way to do this beautifully but didnt figure out.","Since you are already going to build an Angular app for the front-end, why not make the whole architecture RESTful? That way the front-end Angular app will be in charge of presentation and the server of just the data. You can pass data between the server and front-end through JSON which has the benefit of not needing to deal with html or templates in the back end? Angular already has Service and $http that can abstract away the two-way data binding, and using webapp2's RESTful nature you can make this happen fairly painlessly.",0.3869120172231254,False,1,3093 +2014-03-14 19:10:24.020,Combining regular expressions in Python,"I'd like to combine the regular expressions \w+ and [a-z] together in Python to only accept a word that is all lowercase, but cannot seem to figure out the right way to do that. Does anyone know how?",So I was actually able to get it to work like this : [a-z]\w+.,-0.0679224682270276,False,2,3094 2014-03-14 19:10:24.020,Combining regular expressions in Python,"I'd like to combine the regular expressions \w+ and [a-z] together in Python to only accept a word that is all lowercase, but cannot seem to figure out the right way to do that. Does anyone know how?","If you only want lowercase words, all you need is [a-z]+ \w includes uppercase letters, digits, and underscore",1.2,True,2,3094 -2014-03-14 19:10:24.020,Combining regular expressions in Python,"I'd like to combine the regular expressions \w+ and [a-z] together in Python to only accept a word that is all lowercase, but cannot seem to figure out the right way to do that. Does anyone know how?",So I was actually able to get it to work like this : [a-z]\w+.,-0.0679224682270276,False,2,3094 2014-03-15 15:19:43.210,How many objects should I retrieve from server and How many can be stored in NSCache?,"My service return up to 500 objects at time i've notice that my iphone application is crashing when the amount of data goes over 60 objects. to workaround this issue I'm running a query that brings back only the top 40 results but that is slower than just returning the entire data what are the best practices and how can i retrieve more objects? @@ -31245,11 +31245,6 @@ My question is, how do you push a String to the top of the stack. Is it the same 2014-03-24 08:46:33.057,How to code in openerp so that user can create his fields?,"I have been developing modules in OpenERP-7 using Python on Ubuntu-12.04. I want to give my users a feature by which they will have the ability to create what ever fields they want to . Like they will set the name, data_type etc for the field and then on click , this field will be created. I dont have any idea how this will be implemented. I have set up mind to create a button that will call a function and it will create a new field according to the details entered by the user . Is this approach of mine is right or not? And will this work . ? Please guide me so that I can work smartly. Hopes for suggestion","The user can add fields, models, can customize the views etc from client side. These are in Settings/Technical/Database Structure, here you can find the menus Fields, Models etc where the user can add fields. And the views can be customized in Settings/Technical/User Interface.",0.0,False,1,3107 2014-03-24 20:04:59.297,How can i check in numpy if a binary image is almost all black?,"How can i see in if a binary image is almost all black or all white in numpy or scikit-image modules ? -I thought about numpy.all function or numpy.any but i do not know how neither for a total black image nor for a almost black image.","Here is a list of ideas I can think of: - -get the np.sum() and if it is lower than a threshold, then consider it almost black -calculate np.mean() and np.std() of the image, an almost black image is an image that has low mean and low variance",0.3869120172231254,False,2,3108 -2014-03-24 20:04:59.297,How can i check in numpy if a binary image is almost all black?,"How can i see in if a binary image is almost all black or all white in numpy or scikit-image modules ? I thought about numpy.all function or numpy.any but i do not know how neither for a total black image nor for a almost black image.","Assuming that all the pixels really are ones or zeros, something like this might work (not at all tested): def is_sorta_black(arr, threshold=0.8): @@ -31260,6 +31255,11 @@ def is_sorta_black(arr, threshold=0.8): else: print ""is kinda black"" return True",1.2,True,2,3108 +2014-03-24 20:04:59.297,How can i check in numpy if a binary image is almost all black?,"How can i see in if a binary image is almost all black or all white in numpy or scikit-image modules ? +I thought about numpy.all function or numpy.any but i do not know how neither for a total black image nor for a almost black image.","Here is a list of ideas I can think of: + +get the np.sum() and if it is lower than a threshold, then consider it almost black +calculate np.mean() and np.std() of the image, an almost black image is an image that has low mean and low variance",0.3869120172231254,False,2,3108 2014-03-24 21:46:48.337,Compile custom module for Kivy-ios,"I finally have some idea how to build Kivy app in Xcode with help of Kivy-ios. But Xcode and mac environment is new to me. My issue is: how to compile other python modules that required for my application. There is 'build-all.sh' in 'kivy-ios/tools' that builds standard things, but how to add some other module. In particular, I need Requests module. Maybe there's some template script to include custom python modules? Thanks in advance","I don't know how kivy-ios manages different modules, but in the absence of anything else you can simply copy the requests module into your app dir so it's included along with everything else.",1.2,True,1,3109 2014-03-25 01:55:09.347,Setting selection background in ListCtrl,I'm trying to set a custom background for selected items in wxPython 2.8. I cannot figure out how to do so. I've tried SetItemBackground with no luck.,"Selected items in wxListCtrl, wxListBox and so on always use the system background selection colour, it can't be changed.",1.2,True,1,3110 2014-03-25 11:19:55.923,Python: Generating a big uniform permutation cheaply,"I'm not sure whether this is possible even theoretically; but if it is, I'd like to know how to do it in Python. @@ -31546,14 +31546,14 @@ Assuming you're embedding IronPython, once you have the location you can just us 2014-04-16 13:13:32.607,"How do I find the slope (m) for a line given a point (x,y) on the line and the line's angle from the y axis in python?","I understand that the equation for a straight line is: y = (m * x) + c where m is the slope of the line which would be (ydelta/xdelta) but I dont know how to get this value when I only know a single point and an angle rather than two points. -Any help is appreciated. Thanks in advance.","With just a single point (and nothing else) you cannot solve such a problem, there are infinitely many lines going through a single point. -If you know the angle to x axis then simply m=tan(angle) (you do not need any points to do that, point is only required to figure out c value, which should now be simple). -To convert angle from the y-axis to the x-axis simply compute pi/2 - angle",1.2,True,3,3155 +Any help is appreciated. Thanks in advance.","Okay, let's say your point is (x,y)=(1,2) +Then you want to solve 2 = m + c. Obviously there is no way you can do this.",-0.1352210990936997,False,3,3155 2014-04-16 13:13:32.607,"How do I find the slope (m) for a line given a point (x,y) on the line and the line's angle from the y axis in python?","I understand that the equation for a straight line is: y = (m * x) + c where m is the slope of the line which would be (ydelta/xdelta) but I dont know how to get this value when I only know a single point and an angle rather than two points. -Any help is appreciated. Thanks in advance.","Okay, let's say your point is (x,y)=(1,2) -Then you want to solve 2 = m + c. Obviously there is no way you can do this.",-0.1352210990936997,False,3,3155 +Any help is appreciated. Thanks in advance.","With just a single point (and nothing else) you cannot solve such a problem, there are infinitely many lines going through a single point. +If you know the angle to x axis then simply m=tan(angle) (you do not need any points to do that, point is only required to figure out c value, which should now be simple). +To convert angle from the y-axis to the x-axis simply compute pi/2 - angle",1.2,True,3,3155 2014-04-16 13:13:32.607,"How do I find the slope (m) for a line given a point (x,y) on the line and the line's angle from the y axis in python?","I understand that the equation for a straight line is: y = (m * x) + c where m is the slope of the line which would be (ydelta/xdelta) but I dont know how to get this value when I only know a single point and an angle rather than two points. @@ -31832,43 +31832,6 @@ Read the file, convert it to pdf using software called docsplit create a folder on server disk (which will be used as static content later on) puts pdf file and its thumbnail and plain text and the original file -Considering the above use case, how can you setup up multiple web servers which can perform the same functionality?","What will strongly simplify your processing is some shared storage, accessible from all cooperating servers. With such design, you may distribute the work among more servers without worrying on which server will be next processing step done. -Using AWS S3 (or similar) cloud storage -If you can use some cloud storage, like AWS S3, use that. -In case you have your servers running at AWS too, you do not pay for traffic within the same region, and transfers are quite fast. -Main advantage is, your data are available from all the servers under the same bucket/key name, so you do not have to bother about who is processing which file, as all have shared storage on S3. -note: If you need to get rid of old files, you may even set up some policy file on give bucket, e.g. to delete files older than 1 day or 1 week. -Using other types of shared storage -There are more options - -Samba -central file server -FTP -Google storage (very similar to AWS S3) -Swift (from OpenStack) -etc. - -For small files you could even use Redis, but such solutions are for good reasons rather rare.",0.6730655149877884,False,2,3192 -2014-05-08 20:24:22.863,"django-celery infrastructure over multiple servers, broker is redis","Currently we have everything setup on single cloud server, that includes: - -Database server -Apache -Celery -redis to serve as a broker for celery and for some other tasks -etc - -Now we are thinking to break apart the main components to separate servers e.g. separate database server, separate storage for media files, web servers behind load balancers. The reason is to not to pay for one heavy server and use load balancers to create servers on demand to reduce cost and improve overall speed. -I am really confused about celery only, have anyone ever used celery on multiple production servers behind load balancers? Any guidance would be appreciated. -Consider one small use case which is currently how it is been done on single server (confusion is that how that can be done when we use multiple servers): - -User uploads a abc.pptx file->reference is stored in database->stored on server disk -A task (convert document to pdf) is created and goes in redis (broker) queue -celery which is running on same server picks the task from queue - -Read the file, convert it to pdf using software called docsplit -create a folder on server disk (which will be used as static content later on) puts pdf file and its thumbnail and plain text and the original file - - Considering the above use case, how can you setup up multiple web servers which can perform the same functionality?","Celery actually makes this pretty simple, since you're already putting the tasks on a queue. All that changes with more workers is that each worker takes whatever's next on the queue - so multiple workers can process at once, each on their own machine. There's three parts to this, and you've already got one of them. @@ -31896,6 +31859,43 @@ Key things to ensure: You must have shared storage, or this gets much more complicated Every worker machine must have the right Django/Celery settings to be able to find the redis broker and the shared storage (e.g. S3 bucket, keys etc)",0.5457054096481145,False,2,3192 +2014-05-08 20:24:22.863,"django-celery infrastructure over multiple servers, broker is redis","Currently we have everything setup on single cloud server, that includes: + +Database server +Apache +Celery +redis to serve as a broker for celery and for some other tasks +etc + +Now we are thinking to break apart the main components to separate servers e.g. separate database server, separate storage for media files, web servers behind load balancers. The reason is to not to pay for one heavy server and use load balancers to create servers on demand to reduce cost and improve overall speed. +I am really confused about celery only, have anyone ever used celery on multiple production servers behind load balancers? Any guidance would be appreciated. +Consider one small use case which is currently how it is been done on single server (confusion is that how that can be done when we use multiple servers): + +User uploads a abc.pptx file->reference is stored in database->stored on server disk +A task (convert document to pdf) is created and goes in redis (broker) queue +celery which is running on same server picks the task from queue + +Read the file, convert it to pdf using software called docsplit +create a folder on server disk (which will be used as static content later on) puts pdf file and its thumbnail and plain text and the original file + + +Considering the above use case, how can you setup up multiple web servers which can perform the same functionality?","What will strongly simplify your processing is some shared storage, accessible from all cooperating servers. With such design, you may distribute the work among more servers without worrying on which server will be next processing step done. +Using AWS S3 (or similar) cloud storage +If you can use some cloud storage, like AWS S3, use that. +In case you have your servers running at AWS too, you do not pay for traffic within the same region, and transfers are quite fast. +Main advantage is, your data are available from all the servers under the same bucket/key name, so you do not have to bother about who is processing which file, as all have shared storage on S3. +note: If you need to get rid of old files, you may even set up some policy file on give bucket, e.g. to delete files older than 1 day or 1 week. +Using other types of shared storage +There are more options + +Samba +central file server +FTP +Google storage (very similar to AWS S3) +Swift (from OpenStack) +etc. + +For small files you could even use Redis, but such solutions are for good reasons rather rare.",0.6730655149877884,False,2,3192 2014-05-09 14:53:12.973,PYQTGraph application slows down when mouse moves over application,"I have a multi-threaded (via pyqt) application which plots realtime data (data is processed in the second thread and passed to the gui thread to plot via a pyqt-signal). If I place the mouse over the application it continues to run at full speed (as measured by the time difference between calls to app.processEvents()). As soon as I begin moving the mouse, the update rate slows to a crawl, increasing again when I stop moving the mouse. Does anyone know how I can resolve this/debug the issue? The code is quite lengthy and complex so I'd rather not post it here. Thanks!","It's likely you have items in the scene that accept their own mouse input, but it's difficult to say without seeing code. In particular, be wary of complex plot lines that are made clickable--it is very expensive to compute the intersection of the mouse cursor with such complex shapes. @@ -32280,11 +32280,7 @@ Step 3) GAE replaces the contents of a particular (hard-coded path) text file on Step 4) (bonus step) GCE notices that the file has changed (either by detecting a change or by way of GAE alerting it when the new content is pushed) and runs a script to process the new file. I understand that this is easy to do using SCP or other terminal commands. I have already done that, and that works fine. What I need is a way for GAE to send that content directly, without my intervention. I have full access to all instances of GAE and GCE involved in this project, and can set up whatever code is needed on either of the platforms. -Thank you in advance for your help!","The most straightforward approach seems to be: - -A user submit a form on App Engine instance. -App Engine instance makes a POST call to a handler on GCE instance with the new data. -GCE instance updates its own file and processes it.",0.0,False,2,3240 +Thank you in advance for your help!","You can set an action URL in your form to point to the GCE instance (it can be load-balanced if you have more than one). Then all data will be uploaded directly to the GCE instance, and you don't have to worry about transferring data from your App Engine instance to GCE instance.",0.0,False,2,3240 2014-06-12 21:28:00.653,Using Google App Engine to update files on Google Compute Engine,"I am working on a project that involves using an Google App Engine (GAE) server to control one or more Google Compute Engine (GCE) instances. The rest of the project is working well, but I am having a problem with one specific aspect: file management. I want my GAE to edit a file on my GCE instance, and after days of research I have come up blank on how to do that. The most straightforward example of this is: Step 1) User enters text into a GAE form. @@ -32293,7 +32289,11 @@ Step 3) GAE replaces the contents of a particular (hard-coded path) text file on Step 4) (bonus step) GCE notices that the file has changed (either by detecting a change or by way of GAE alerting it when the new content is pushed) and runs a script to process the new file. I understand that this is easy to do using SCP or other terminal commands. I have already done that, and that works fine. What I need is a way for GAE to send that content directly, without my intervention. I have full access to all instances of GAE and GCE involved in this project, and can set up whatever code is needed on either of the platforms. -Thank you in advance for your help!","You can set an action URL in your form to point to the GCE instance (it can be load-balanced if you have more than one). Then all data will be uploaded directly to the GCE instance, and you don't have to worry about transferring data from your App Engine instance to GCE instance.",0.0,False,2,3240 +Thank you in advance for your help!","The most straightforward approach seems to be: + +A user submit a form on App Engine instance. +App Engine instance makes a POST call to a handler on GCE instance with the new data. +GCE instance updates its own file and processes it.",0.0,False,2,3240 2014-06-14 08:34:53.433,Python set up a timer for client connection,"I'll explain you better my problem. I've code a simple python server who listening for web client connection. The server is running but i must add a function and i don't know how resolve this.. @@ -32309,15 +32309,15 @@ As for what to send, it doesn't really matter if it's a non-browser application 2014-06-16 05:54:18.610,shared object in C# to be used in python script,"I have created a windows app which runs a python script. I'm able to capture the output of the script in textbox. Now i need to pass a shared object to python script as an argument from my app. what type of shared object should i create so that python script can accept it and run it or in simple words how do i create shared object which can be used by python script. -thanks","Since python is running as another process. This is no way for python to access object in c# directly since process isolation. -A way of marshal and un-marshal should be included to communicate between processes. -There are many way to communicate between processes. Share memory, file, TCP and so on.",0.2012947653214861,False,2,3243 -2014-06-16 05:54:18.610,shared object in C# to be used in python script,"I have created a windows app which runs a python script. I'm able to capture the output of the script in textbox. -Now i need to pass a shared object to python script as an argument from my app. -what type of shared object should i create so that python script can accept it and run it or in simple words how do i create shared object which can be used by python script. thanks","5.4. Extending Embedded Python will help you to access the application object. In this case both application and python running in single process.",0.2012947653214861,False,2,3243 +2014-06-16 05:54:18.610,shared object in C# to be used in python script,"I have created a windows app which runs a python script. I'm able to capture the output of the script in textbox. +Now i need to pass a shared object to python script as an argument from my app. +what type of shared object should i create so that python script can accept it and run it or in simple words how do i create shared object which can be used by python script. +thanks","Since python is running as another process. This is no way for python to access object in c# directly since process isolation. +A way of marshal and un-marshal should be included to communicate between processes. +There are many way to communicate between processes. Share memory, file, TCP and so on.",0.2012947653214861,False,2,3243 2014-06-16 18:20:15.053,In python how does the caller of something know if that something would throw an exception or not?,"In the Java world, we know that the exceptions are classified into checked vs runtime and whenever something throws a checked exception, the caller of that something will be forced to handle that exception, one way or another. Thus the caller would be well aware of the fact that there is an exception and be prepared/coded to handle that. But coming to Python, given there is no concept of checked exceptions (I hope that is correct), how does the caller of something know if that something would throw an exception or not? Given this ""lack of knowledge that an exception could be thrown"", how does the caller ever know that it could have handled an exception until it is too late?",As far as I know Python (6 years) there isn't anything similar to Java's throws keyword in Python.,0.0,False,2,3244 2014-06-16 18:20:15.053,In python how does the caller of something know if that something would throw an exception or not?,"In the Java world, we know that the exceptions are classified into checked vs runtime and whenever something throws a checked exception, the caller of that something will be forced to handle that exception, one way or another. Thus the caller would be well aware of the fact that there is an exception and be prepared/coded to handle that. @@ -32542,12 +32542,12 @@ You need to look at the heuristic value of each board state neighboring your cur If you are doing animations/transitions between board states, then you would have to look at the edge and figure out which piece is different between the two states, and animate that piece accordingly.",0.0,False,3,3263 2014-06-30 13:22:33.253,How to Get Move From Minimax Algorithm in Tic-Tac-Toe?,"So far I have successfully been able to use the Minimax algorithm in Python and apply it to a tic-tac-toe game. I can have my algorithm run through the whole search treee, and return a value. However, I am confused as to how to take this value, and transform it into a move? How am I supposed to know which move to make? -Thanks.","In using the MM algorithm, you must have had a way to generate the possible successor boards; each of those was the result of a move. As has been suggested, you can modify your algorithm to include tracking of the move that was used to generate a board (for example, adding it to the definition of a board, or using a structure that has the board and the move); or, you could have a special case for the top level of the algorithm, since that is the only one in which the particular move is important. -For example, if your function currently returns just the computed value of the board it was passed, it could instead return a dict (or tuple, which isn't as clear) with both the value and the first move used to obtain that value, and then modify your code to use whichever bit is needed.",0.0,False,3,3263 -2014-06-30 13:22:33.253,How to Get Move From Minimax Algorithm in Tic-Tac-Toe?,"So far I have successfully been able to use the Minimax algorithm in Python and apply it to a tic-tac-toe game. I can have my algorithm run through the whole search treee, and return a value. -However, I am confused as to how to take this value, and transform it into a move? How am I supposed to know which move to make? Thanks.","The simplest way to select your move is to choose your move that has the maximum number of winning positions stemming from that move. I would, for each node in your search tree (game state) keep a record of possible win states that can be created by the current game state.",0.0,False,3,3263 +2014-06-30 13:22:33.253,How to Get Move From Minimax Algorithm in Tic-Tac-Toe?,"So far I have successfully been able to use the Minimax algorithm in Python and apply it to a tic-tac-toe game. I can have my algorithm run through the whole search treee, and return a value. +However, I am confused as to how to take this value, and transform it into a move? How am I supposed to know which move to make? +Thanks.","In using the MM algorithm, you must have had a way to generate the possible successor boards; each of those was the result of a move. As has been suggested, you can modify your algorithm to include tracking of the move that was used to generate a board (for example, adding it to the definition of a board, or using a structure that has the board and the move); or, you could have a special case for the top level of the algorithm, since that is the only one in which the particular move is important. +For example, if your function currently returns just the computed value of the board it was passed, it could instead return a dict (or tuple, which isn't as clear) with both the value and the first move used to obtain that value, and then modify your code to use whichever bit is needed.",0.0,False,3,3263 2014-06-30 19:10:39.740,How do I terminate a long-running Django request if the XHR gets an abort()?,"I initiate a request client-side, then I change my mind and call xhr.abort(). How does Django react to this? Does it terminate the thread somehow? If not, how do I get Django to stop wasting time trying to respond to the aborted request? How do I handle it gracefully?","Just think of the Web as a platform for building easy-to-use, distributed, loosely couple systems, with no guarantee about the availability of resources as 404 status code suggests. I think that creating tightly coupled solutions such as your idea is going against web principles and usage of REST. xhr.abort() is client side programming, it's completely different from server side. It's a bad practice trying to tighten client side technology to server side internal behavior. @@ -32564,19 +32564,22 @@ I have all of the files stored in s3 however I would like to change some of that I have an object id with properties such as a date, etc which I know how to create a table of in dynamo. My issue is that each object also contains images, text files, and the original file. I would like to have the key for s3 for the original file in the properties of the file: Ex: FileX, date, originalfileLoc, etc, images pointer, text pointer. I looked online but I'm confused how to do the nesting. Does anyone know of any good examples? Is there another way? I assume I create an images and a text table. Each with the id and all of the file's s3 keys. Any example code of how to create the link itself? -I'm using python boto btw to do this.","If you stay between the limits of Dynamodb of 64Kb per item. -You can have one item (row) per file. -DynamoDB has String type (for file name, date, etc) and also a StringSet (SS) for list of attributes (for text files, images). -From what you write I assume you are will only save pointers (keys) to binary data in the S3. -You could also save binary data and binary sets in DynamoDB but I believe you will reach the limit AND have an expensive solution in terms of throughput.",1.2,True,2,3265 +I'm using python boto btw to do this.","From what you described, I think you just need to create one table with hashkey. The haskey should be object id. And you will have columns such as ""date"", ""image pointer"", ""text pointer"", etc. +DynamoDB is schema-less so you don't need to create the columns explicitly. When you call getItem the server will return you a dictionary with column name as key and the value. +Being schema-less also means you can create new column dynamically. Assuming you already have a row in the table with only ""date"" column. now you want to add the ""image pointer"" column. you just need to call UpdateItem and gives it the hashkey and image-pointer key-value pair.",0.0,False,2,3265 2014-07-01 22:25:44.313,How to correctly nest tables in DynamoDb,"I'm attempting to store information from a decompiled file in Dynamo. I have all of the files stored in s3 however I would like to change some of that. I have an object id with properties such as a date, etc which I know how to create a table of in dynamo. My issue is that each object also contains images, text files, and the original file. I would like to have the key for s3 for the original file in the properties of the file: Ex: FileX, date, originalfileLoc, etc, images pointer, text pointer. I looked online but I'm confused how to do the nesting. Does anyone know of any good examples? Is there another way? I assume I create an images and a text table. Each with the id and all of the file's s3 keys. Any example code of how to create the link itself? -I'm using python boto btw to do this.","From what you described, I think you just need to create one table with hashkey. The haskey should be object id. And you will have columns such as ""date"", ""image pointer"", ""text pointer"", etc. -DynamoDB is schema-less so you don't need to create the columns explicitly. When you call getItem the server will return you a dictionary with column name as key and the value. -Being schema-less also means you can create new column dynamically. Assuming you already have a row in the table with only ""date"" column. now you want to add the ""image pointer"" column. you just need to call UpdateItem and gives it the hashkey and image-pointer key-value pair.",0.0,False,2,3265 +I'm using python boto btw to do this.","If you stay between the limits of Dynamodb of 64Kb per item. +You can have one item (row) per file. +DynamoDB has String type (for file name, date, etc) and also a StringSet (SS) for list of attributes (for text files, images). +From what you write I assume you are will only save pointers (keys) to binary data in the S3. +You could also save binary data and binary sets in DynamoDB but I believe you will reach the limit AND have an expensive solution in terms of throughput.",1.2,True,2,3265 +2014-07-02 15:48:22.860,Python 3 Debugging issue,"I have recently started to learn Python 3 and have run into an issue while trying to learn how to debug using IDLE. I have created a basic program following a tutorial, which then explains how to use the debugger. However, I keep running into an issue while stepping through the code, which the tutorial does not explain (I have followed the instructions perfectly) nor does hours of searching on the internet. Basically if I step while already inside a function, usually following print() the debugger steps into pyshell.py, specifically, PyShell.py:1285: write() if i step out of pyshell, the debugger will simple step back in as soon as I try to move on, if this is repeated the step, go, etc buttons will grey out. +Any help will be greatly appreciated. +Thanks.",pyshell.py file opens during the debugging process when the function that is under review is found in Python's library - for example print() or input(). If you want to bypass this file/process click Over and it will step over this review of the function in Python's library.,0.0,False,2,3266 2014-07-02 15:48:22.860,Python 3 Debugging issue,"I have recently started to learn Python 3 and have run into an issue while trying to learn how to debug using IDLE. I have created a basic program following a tutorial, which then explains how to use the debugger. However, I keep running into an issue while stepping through the code, which the tutorial does not explain (I have followed the instructions perfectly) nor does hours of searching on the internet. Basically if I step while already inside a function, usually following print() the debugger steps into pyshell.py, specifically, PyShell.py:1285: write() if i step out of pyshell, the debugger will simple step back in as soon as I try to move on, if this is repeated the step, go, etc buttons will grey out. Any help will be greatly appreciated. Thanks.","In Python 3.4, I had the same problem. My tutorial is from Invent with Python by Al Sweigart, chapter 7. @@ -32584,9 +32587,6 @@ New file editor windows such as pyshell.py and random.pyopen when built-in funct If you click OVER, you will have to click it several times, but if you click OUT, pyshell.py will close immediately and you'll be back in the original file you were trying to debug. Also, I encountered problems confusing this one--the grayed-out buttons you mentioned--if I forgot to click in the shell and give input when the program asked. I tried Wing IDE and it didn't run the program correctly, although the program has no bugs. So I googled the problem, and there was no indication that IDLE is broken or useless. Therefore, I kept trying till the OUT button in the IDLE debugger solved the problem.",0.0,False,2,3266 -2014-07-02 15:48:22.860,Python 3 Debugging issue,"I have recently started to learn Python 3 and have run into an issue while trying to learn how to debug using IDLE. I have created a basic program following a tutorial, which then explains how to use the debugger. However, I keep running into an issue while stepping through the code, which the tutorial does not explain (I have followed the instructions perfectly) nor does hours of searching on the internet. Basically if I step while already inside a function, usually following print() the debugger steps into pyshell.py, specifically, PyShell.py:1285: write() if i step out of pyshell, the debugger will simple step back in as soon as I try to move on, if this is repeated the step, go, etc buttons will grey out. -Any help will be greatly appreciated. -Thanks.",pyshell.py file opens during the debugging process when the function that is under review is found in Python's library - for example print() or input(). If you want to bypass this file/process click Over and it will step over this review of the function in Python's library.,0.0,False,2,3266 2014-07-02 16:36:50.627,How to Combine pyWavelet and openCV for image processing?,"I need to do an image processing in python. i want to use wavelet transform as the filterbank. Can anyone suggest me which one library should i use? I had pywavelet installed, but i don't know how to combine it with opencv. If i use wavedec2 command, it raise ValueError(""Expected 2D input data."") Can anyone help me?","Answer of Navaneeth is correct but with two correction: @@ -32634,14 +32634,6 @@ In this specific example, you could also have your polls app set up so that its 2014-07-08 18:52:40.960,How to use/decompress the file made by img2py,I have used img2py to convert an image into a .py file. But how to use that converted file in pygame. Is there any specific code for it?,"The PyEmbeddedImage class has a GetData method (or Data property) that can be used to fetch the raw data of the embedded image, in PNG format.",0.6730655149877884,False,1,3273 2014-07-09 21:03:02.513,Python script requires input in command line,"I'm new to python and I'm attempting to run a script provided to me that requires to input the name of a text file to run. I changed my pathing to include the Python directory and my input in the command line - ""python name_of_script.py"" - is seemingly working. However, I'm getting the error: ""the following arguments are required: --input"". This makes sense, as I need this other text file for the program to run, but I don't know how to input it on the command line, as I'm never prompted to enter any input. I tried just adding it to the end of my command prompt line, but to no avail. Does anybody know how this could be achieved? -Thanks tons","if you pasted the code here that would help but -the answer you are most likely looking for is commandline arguements. -If I were to guess, in the command line the input would look something like: -python name_of_script.py ""c:\thefilepath\totheinputfile"" {enter} -{enter} being the actually key pressed on the keyboard and not typed in as the word -Hopefully this starts you on the right answer :)",0.0,False,2,3274 -2014-07-09 21:03:02.513,Python script requires input in command line,"I'm new to python and I'm attempting to run a script provided to me that requires to input the name of a text file to run. I changed my pathing to include the Python directory and my input in the command line - ""python name_of_script.py"" - is seemingly working. However, I'm getting the error: ""the following arguments are required: --input"". This makes sense, as I need this other text file for the program to run, but I don't know how to input it on the command line, as I'm never prompted to enter any input. I tried just adding it to the end of my command prompt line, but to no avail. -Does anybody know how this could be achieved? Thanks tons","Without reading your code, I guess if I tried just adding it to the end of my command prompt line, but to no avail. @@ -32649,6 +32641,14 @@ I tried just adding it to the end of my command prompt line, but to no avail. it means that you need to make your code aware the command line argument. Unless you do some fancy command line processing, for which you need to import optparse or argparse, try: import sys # do something with sys.argv[-1] (ie, the last argument)",0.0,False,2,3274 +2014-07-09 21:03:02.513,Python script requires input in command line,"I'm new to python and I'm attempting to run a script provided to me that requires to input the name of a text file to run. I changed my pathing to include the Python directory and my input in the command line - ""python name_of_script.py"" - is seemingly working. However, I'm getting the error: ""the following arguments are required: --input"". This makes sense, as I need this other text file for the program to run, but I don't know how to input it on the command line, as I'm never prompted to enter any input. I tried just adding it to the end of my command prompt line, but to no avail. +Does anybody know how this could be achieved? +Thanks tons","if you pasted the code here that would help but +the answer you are most likely looking for is commandline arguements. +If I were to guess, in the command line the input would look something like: +python name_of_script.py ""c:\thefilepath\totheinputfile"" {enter} +{enter} being the actually key pressed on the keyboard and not typed in as the word +Hopefully this starts you on the right answer :)",0.0,False,2,3274 2014-07-10 19:00:43.527,Python Export Program to PDF using Latex format,"I have a GUI program in Python which calculates graphs of certain functions. These functions are mathematical like say, cos(theta) etc. At present I save the graphs of these functions and compile them to PDF in Latex and write down the equation manually in Latex. But now I wish to simplify this process by creating a template in Latex that arranges, The Function Name, Graph, Equation and Table and complies them to a single PDF format with just a click. Can this be done? And how do I do it? @@ -32725,14 +32725,6 @@ Select Modules in the list on the left Select the Python module in the list of modules On the right-hand side, either choose an existing Python SDK from the dropdown list, or click on the New... button to create either a virtualenv, or create a new Python SDK from a Python installation on your system.",0.2401167094949473,False,3,3283 2014-07-15 22:18:30.117,How do I configure a Python interpreter in IntelliJ IDEA with the PyCharm plugin?,"There is a tutorial in the IDEA docs on how to add a Python interpreter in PyCharm, which involves accessing the ""Project Interpreter"" page. Even after installing the Python plugin, I don't see that setting anywhere. -Am I missing something obvious?","With the Python plugin installed: - -Navigate to File > Project Structure. -Under the Project menu for Project SDK, select ""New"" and -Select ""Python SDK"", then select ""Local"". - -Provided you have a Python SDK installed, the flow should be natural from there - navigate to the location your Python installation lives.",1.0,False,3,3283 -2014-07-15 22:18:30.117,How do I configure a Python interpreter in IntelliJ IDEA with the PyCharm plugin?,"There is a tutorial in the IDEA docs on how to add a Python interpreter in PyCharm, which involves accessing the ""Project Interpreter"" page. Even after installing the Python plugin, I don't see that setting anywhere. Am I missing something obvious?","Follow these steps: Open Setting (Ctrl + Alt + s) @@ -32743,6 +32735,14 @@ Select Python SDK or pycharm Restart the IDE Go to project structure Select the python SDK in projects or create a new project with python SDK.",0.1618299653758019,False,3,3283 +2014-07-15 22:18:30.117,How do I configure a Python interpreter in IntelliJ IDEA with the PyCharm plugin?,"There is a tutorial in the IDEA docs on how to add a Python interpreter in PyCharm, which involves accessing the ""Project Interpreter"" page. Even after installing the Python plugin, I don't see that setting anywhere. +Am I missing something obvious?","With the Python plugin installed: + +Navigate to File > Project Structure. +Under the Project menu for Project SDK, select ""New"" and +Select ""Python SDK"", then select ""Local"". + +Provided you have a Python SDK installed, the flow should be natural from there - navigate to the location your Python installation lives.",1.0,False,3,3283 2014-07-15 23:02:00.583,Uploading code to server and run automatically,"I'm fairly competent with Python but I've never 'uploaded code' to a server before and have it run automatically. I'm working on a project that would require some code to be running 24/7. At certain points of the day, if a criteria is met, a process is started. For example: a database may contain records of what time each user wants to receive a daily newsletter (for some subjective reason) - the code would at the right time of day send the newsletter to the correct person. But of course, all of this is running out on a Cloud server. Any help would be appreciated - even correcting my entire formulation of the problem! If you know how to do this in any other language - please reply with your solutions! @@ -32865,8 +32865,6 @@ The sa_mask field specified in act is not allowed to block SIGKILL or SIGSTOP. Abaqus couldn't even start so I guess that such approach is incorrect. Are there any suggestions on how to overcome such issue? Thanks guys","I have similar problems. As an (annoying) work around I usually write out important data in text files using the regular python. Afterwards, using a bash script, I start a second python (different version) to further analyse the data (matplotlib etc).",0.0,False,1,3301 -2014-07-24 21:51:36.090,Python-bytes() vs struct.pack(),"I'm just curious here, but I have been using bytes() to convert things to bytes ever since I learned python. It was until recently that I saw struct.pack(). I didn't bother learning how to use it because I thought It did essentially did the same thing as bytes(). But it appears many people prefer to use struct.pack(). Why? what are the advantages of one over the other?","They do two different things; compare bytes(1234) with struct.pack(""!H"", 1234). The first just provides a 4-byte string representation of the number bytes object with 1,234 null bytes; the second provides a two-byte string with the (big-endian) value of the integer. -(Edit: Struck out irrelevant Python 2 definition of bytes(1234).)",0.3869120172231254,False,2,3302 2014-07-24 21:51:36.090,Python-bytes() vs struct.pack(),"I'm just curious here, but I have been using bytes() to convert things to bytes ever since I learned python. It was until recently that I saw struct.pack(). I didn't bother learning how to use it because I thought It did essentially did the same thing as bytes(). But it appears many people prefer to use struct.pack(). Why? what are the advantages of one over the other?","bytes() does literally what the name implies: Return a new “bytes” object, which is an immutable sequence of @@ -32877,6 +32875,8 @@ struck.pack() does something very different: This module performs conversions between Python values and C structs represented as Python strings While for some inputs these might be equivalent, they are not at all the same operation. struct.pack() is essentially producing a byte-string that represents a POD C-struct in memory. It's useful for serializing/deserializing data.",1.2,True,2,3302 +2014-07-24 21:51:36.090,Python-bytes() vs struct.pack(),"I'm just curious here, but I have been using bytes() to convert things to bytes ever since I learned python. It was until recently that I saw struct.pack(). I didn't bother learning how to use it because I thought It did essentially did the same thing as bytes(). But it appears many people prefer to use struct.pack(). Why? what are the advantages of one over the other?","They do two different things; compare bytes(1234) with struct.pack(""!H"", 1234). The first just provides a 4-byte string representation of the number bytes object with 1,234 null bytes; the second provides a two-byte string with the (big-endian) value of the integer. +(Edit: Struck out irrelevant Python 2 definition of bytes(1234).)",0.3869120172231254,False,2,3302 2014-07-26 02:41:50.317,One-hot encoding of large dataset with scikit-learn,"I have a large dataset which I plan to do logistic regression on. It has lots of categorical variables, each having thousands of features which I am planning to use one hot encoding on. I will need to deal with the data in small batches. My question is how to make sure that one hot encoding sees all the features of each categorical variable during the first run?","There is no way around finding out which possible values your categorical features can take, which probably implies that you have to go through your data fully once in order to obtain a list of unique values of your categorical variables. After that it is a matter of transforming your categorical variables to integer values and setting the n_values= kwarg in OneHotEncoder to an array corresponding to the number of different values each variable can take.",0.5457054096481145,False,1,3303 2014-07-26 17:19:11.993,How do I remove/add the python interpreter from eclipse?,"I'm an eclipse noob. @@ -33081,6 +33081,18 @@ Bonus points if you tell me how I can link the file on my local computer to auto The problem is how to make a trial version which stop working after 10 days of installation and even if the user un-install and install it again after trial period get over it should not work. Giving partial feature in trial version is not an option. Evnironment +Mac OS and Python 2.7 with Kivy","My idea is + +Make a table in database +Use datetime module and put system date in that table as begining date +Use timedelta module timedelta(15)( for calculating the date that program needs to be expired here i used 15 day trial in code) and store it in table of database as expiry date +Now each time your app start put this logic that it checks on if current date is matches with expiry if it does show error it is expired of your explicit logic + +Note:- make sure begining and expiry runs only once instead date will be changed again and again.",0.0,False,2,3330 +2014-08-12 16:52:01.097,How to make trial period for my python application?,"I have made a desktop application in kivy and able to make single executable(.app) with pyinstaller. Now I wanted to give it to customers with the trial period of 10 days or so. +The problem is how to make a trial version which stop working after 10 days of installation and even if the user un-install and install it again after trial period get over it should not work. +Giving partial feature in trial version is not an option. +Evnironment Mac OS and Python 2.7 with Kivy","You need a web server and a database to get this working. Create a licenses table in your database. @@ -33090,18 +33102,6 @@ Each time a client tries to install the software on their computers, you ask for Using that, people can still just create multiple emails and thus potentially get an infinite amount of trial versions. You can then try to add a file somewhere in the person's computer, a place where nobody would ever look for, and just paste the old license there so that when the app starts again (even from a new installation), it can read the license from there and contact the webserver without asking for a license. With this method, when your app contacts the server with an expired trial license, your server can reply with a ""license expired"" signal to let your app know that it has to ask for a non-trial license now, and the server should only accept non-trial licenses coming from that app from now on. This whole method breaks if your clients realize that your app is taking this information from a local file because they can just delete it when found. Another idea that comes to mind is to associate the MAC address of a laptop (or any other unique identifier you can think of) to one license instead of an email address, either at license-creation time (the client would need to send you his MAC address when asking for a trial) or at installation time (your app can check for the MAC address of the laptop it's running on).",1.2,True,2,3330 -2014-08-12 16:52:01.097,How to make trial period for my python application?,"I have made a desktop application in kivy and able to make single executable(.app) with pyinstaller. Now I wanted to give it to customers with the trial period of 10 days or so. -The problem is how to make a trial version which stop working after 10 days of installation and even if the user un-install and install it again after trial period get over it should not work. -Giving partial feature in trial version is not an option. -Evnironment -Mac OS and Python 2.7 with Kivy","My idea is - -Make a table in database -Use datetime module and put system date in that table as begining date -Use timedelta module timedelta(15)( for calculating the date that program needs to be expired here i used 15 day trial in code) and store it in table of database as expiry date -Now each time your app start put this logic that it checks on if current date is matches with expiry if it does show error it is expired of your explicit logic - -Note:- make sure begining and expiry runs only once instead date will be changed again and again.",0.0,False,2,3330 2014-08-12 21:03:23.017,How to get shapefile geometry type in PyQGIS?,"I'm writing a script that is dependent on knowing the geometry type of the loaded shapefile. but I've looked in the pyqgis cookbook and API and can't figure out how to call it. infact, I have trouble interpreting the API, so any light shed on that subject would be appreciated. @@ -33139,8 +33139,8 @@ I ask this because Verilog mainly deals with state-machines which can be impleme Also, if I may add, in case of recursive function calls, if there is a bug, I rely more on the input which is causing this bug rather than the stack trace. I am new to Python, so maybe experts might argue that the Python stack trace is quite useful to debug recursive function calls...if that is the case, I would be more than happy to learn how to do that. Lastly, is it advisable to write recursive functions in Python or should I be moving to other languages? -If there any work-around such that I can continue using python for recursive functions, I would like to know if there any performance impact (I can do profiling though).","I use sys.setrecursionlimit to set the recursion limit to its maximum possible value because I have had issues with large classes/functions hitting the default maximum recursion depth. Setting a large value for the recursion limit should not affect the performance of your script, i.e. it will take the same amount of time to complete if it completes under both a high and a low recursion limit. The only difference is that if you have a low recursion limit, it prevents you from doing stupid things (like running an infinitely recursive loop). With a high limit, rather than hit the limit, a horribly inefficient script that uses recursion too much will just run forever (or until it runs out of memory depending on the task). -As the other answers explain in more detail, most of the time there is a faster way to do whatever it is that you are doing other than a long series of recursive calls.",0.0,False,3,3335 +If there any work-around such that I can continue using python for recursive functions, I would like to know if there any performance impact (I can do profiling though).","Note: This answer is limited to your topmost question, i.e. ""Is it advisable to write recursive functions in Python?"". +The short answer is no, it's not exactly ""advisable"". Without tail-call optimization, recursion can get painfully slow in Python given how intensive function calls are on both memory and processor time. Whenever possible, it's best to rewrite your code iteratively.",0.0582430451621389,False,3,3335 2014-08-13 22:47:06.127,Is it advisable to write recursive functions in Python,"I have written a verilog (logic gates and their connectivity description basically) simulator in python as a part of an experiment. I faced an issue with the stack limit so I did some reading and found that Python does not have a ""tail call optimization"" feature (i.e. removing stack entries dynamically as recursion proceeds) I mainly have two questions in this regard: @@ -33162,8 +33162,8 @@ I ask this because Verilog mainly deals with state-machines which can be impleme Also, if I may add, in case of recursive function calls, if there is a bug, I rely more on the input which is causing this bug rather than the stack trace. I am new to Python, so maybe experts might argue that the Python stack trace is quite useful to debug recursive function calls...if that is the case, I would be more than happy to learn how to do that. Lastly, is it advisable to write recursive functions in Python or should I be moving to other languages? -If there any work-around such that I can continue using python for recursive functions, I would like to know if there any performance impact (I can do profiling though).","Note: This answer is limited to your topmost question, i.e. ""Is it advisable to write recursive functions in Python?"". -The short answer is no, it's not exactly ""advisable"". Without tail-call optimization, recursion can get painfully slow in Python given how intensive function calls are on both memory and processor time. Whenever possible, it's best to rewrite your code iteratively.",0.0582430451621389,False,3,3335 +If there any work-around such that I can continue using python for recursive functions, I would like to know if there any performance impact (I can do profiling though).","I use sys.setrecursionlimit to set the recursion limit to its maximum possible value because I have had issues with large classes/functions hitting the default maximum recursion depth. Setting a large value for the recursion limit should not affect the performance of your script, i.e. it will take the same amount of time to complete if it completes under both a high and a low recursion limit. The only difference is that if you have a low recursion limit, it prevents you from doing stupid things (like running an infinitely recursive loop). With a high limit, rather than hit the limit, a horribly inefficient script that uses recursion too much will just run forever (or until it runs out of memory depending on the task). +As the other answers explain in more detail, most of the time there is a faster way to do whatever it is that you are doing other than a long series of recursive calls.",0.0,False,3,3335 2014-08-14 16:04:56.843,How to prevent user changing URL to see other submission data Django,"I'm new to the web development world, to Django, and to applications that require securing the URL from users that change the foo/bar/pk to access other user data. Is there a way to prevent this? Or is there a built-in way to prevent this from happening in Django? E.g.: @@ -33268,10 +33268,12 @@ Note that other geometric objects in the program have a rotation method that is I'm trying to use buildozer and seem to be able to get the application built and deployed with the command, buildozer -v android debug deploy run, which ends with the application being pushed, and displayed on my android phone, connected via USB. However, when I try ssh -p8000 admin@127.0.0.1 from a terminal on the ubuntu machine I pushed the app from I get Connection Refused. It seems to me that there should be a process on the host (ubuntu) machine in order to proxy the connection, or maybe I just don't see how this works? -Am I missing something simple, or do I need to dig in a debug a bit more?","127.0.0.1 - -This indicates something has gone wrong - 127.0.0.1 is a standard loopback address that simply refers to localhost, i.e. it's trying to ssh into your current computer. -If this is the ip address suggested by kivy-remote-shell then there must be some other problem, though I don't know what - does it work on another device?",0.1352210990936997,False,3,3351 +Am I missing something simple, or do I need to dig in a debug a bit more?","Don't know you found the answer or not. But what i have understood is that you are trying to connect android device from Ubuntu. If I am right then (go on reading) you are following wrong steps. +First :- Your Ubuntu does not have ssh server by default so you get this error message. +Second :- You are using 127.0.0.1 address i.e your Ubuntu machine itself. +Method to do this shall be +Give your android machine a static address or if it gets dynamic its OK. +know the IP address of android and then from Ubuntu typessh -p8000 admin@IP_Of_andrid_device and this should solve the issue.",0.0,False,3,3351 2014-08-21 06:23:51.930,How to connect to kivy-remote-shell?,"This seems to be a dumb question, but how do I ssh into the kivy-remote-shell? I'm trying to use buildozer and seem to be able to get the application built and deployed with the command, buildozer -v android debug deploy run, which ends with the application being pushed, and displayed on my android phone, connected via USB. However, when I try ssh -p8000 admin@127.0.0.1 from a terminal on the ubuntu machine I pushed the app from I get Connection Refused. @@ -33281,12 +33283,10 @@ Am I missing something simple, or do I need to dig in a debug a bit more?","When I'm trying to use buildozer and seem to be able to get the application built and deployed with the command, buildozer -v android debug deploy run, which ends with the application being pushed, and displayed on my android phone, connected via USB. However, when I try ssh -p8000 admin@127.0.0.1 from a terminal on the ubuntu machine I pushed the app from I get Connection Refused. It seems to me that there should be a process on the host (ubuntu) machine in order to proxy the connection, or maybe I just don't see how this works? -Am I missing something simple, or do I need to dig in a debug a bit more?","Don't know you found the answer or not. But what i have understood is that you are trying to connect android device from Ubuntu. If I am right then (go on reading) you are following wrong steps. -First :- Your Ubuntu does not have ssh server by default so you get this error message. -Second :- You are using 127.0.0.1 address i.e your Ubuntu machine itself. -Method to do this shall be -Give your android machine a static address or if it gets dynamic its OK. -know the IP address of android and then from Ubuntu typessh -p8000 admin@IP_Of_andrid_device and this should solve the issue.",0.0,False,3,3351 +Am I missing something simple, or do I need to dig in a debug a bit more?","127.0.0.1 + +This indicates something has gone wrong - 127.0.0.1 is a standard loopback address that simply refers to localhost, i.e. it's trying to ssh into your current computer. +If this is the ip address suggested by kivy-remote-shell then there must be some other problem, though I don't know what - does it work on another device?",0.1352210990936997,False,3,3351 2014-08-21 09:29:58.523,Customized Execution status in Robot Framework,"In Robot Framework, the execution status for each test case can be either PASS or FAIL. But I have a specific requirement to mark few tests as NOT EXECUTED when it fails due to dependencies. I'm not sure on how to achieve this. I need expert's advise for me to move ahead.","Actually, you can SET TAG to run whatever keyword you like (for sanity testing, regression testing...) Just go to your test script configuration and set tags @@ -33294,8 +33294,6 @@ And whenever you want to run, just go to Run tab and select check-box Only run t And click Start button :) Robot framework will select any keyword that match and run it. Sorry, I don't have enough reputation to post images :(",-0.0814518047658113,False,1,3352 2014-08-22 05:17:32.777,how to display matplotlib plots on local machine?,"I am running ipython remotely on a remote server. I access it using serveraddress:8888/ etc to write code for my notebooks. -When I use matplotlib of course the plots are inline. Is there any way to remotely send data so that plot window opens up? I want the whole interactive environment on matplotlib on my local machine and all the number crunching on the server machine? This is something very basic....but somehow after rumaging through google for quite a while i can't figure it out.","You want to get the regular (zoomable) plot window, right? I think you can not do it in the same kernel as, unfortunately, you can't switch from inline to qt and such because the backend has already been chosen: your calls to matplotlib.use() are always before pylab.",0.0,False,2,3353 -2014-08-22 05:17:32.777,how to display matplotlib plots on local machine?,"I am running ipython remotely on a remote server. I access it using serveraddress:8888/ etc to write code for my notebooks. When I use matplotlib of course the plots are inline. Is there any way to remotely send data so that plot window opens up? I want the whole interactive environment on matplotlib on my local machine and all the number crunching on the server machine? This is something very basic....but somehow after rumaging through google for quite a while i can't figure it out.","There are a few possibilities If your remote machine is somehow unixish, you may use the X Windows (then your session is on the remote machine and display on the local machine) @@ -33306,6 +33304,8 @@ nbagg backend of matplotlib.¨ Alternative #1 requires you to have an X server on your machine and a connection between the two machines (possibly tunneled through ssh, etc.) So, this is OS dependent, and the performance depends on the connection between the two machines. Alternatives #2 and #3 are very new but promising. They have quite different approaches, mpl3d enables the use of standard matplotlib plotting commands, but with large datasets bokeh may be more useful. Alternative #4 is probably the ultimate solution (see tcaswell's comments), but not yet available without using a development version of matplotlib (i.e. there may be some installation challenges). On the other hand, if you can hold your breath for a week, 1.4.0 will be out.",1.2,True,2,3353 +2014-08-22 05:17:32.777,how to display matplotlib plots on local machine?,"I am running ipython remotely on a remote server. I access it using serveraddress:8888/ etc to write code for my notebooks. +When I use matplotlib of course the plots are inline. Is there any way to remotely send data so that plot window opens up? I want the whole interactive environment on matplotlib on my local machine and all the number crunching on the server machine? This is something very basic....but somehow after rumaging through google for quite a while i can't figure it out.","You want to get the regular (zoomable) plot window, right? I think you can not do it in the same kernel as, unfortunately, you can't switch from inline to qt and such because the backend has already been chosen: your calls to matplotlib.use() are always before pylab.",0.0,False,2,3353 2014-08-22 06:22:10.197,Running an .exe script from a VB script by passing arguments during runtime,"I have converted a python script to .exe file. I just want to run the exe file from a VB script. Now the problem is that the python script accepts arguments during run-time (e.g.: serial port number, baud rate, etc.) and I cannot do the same with the .exe file. Can someone help me how to proceed?","If you don't have the source to the python exe convertor and if the arguments don't need to change on each execution, you could probably open the exe in a debugger like ollydbg and search for shellexecute or createprocess and then create a string in a code cave and use that for the arguments. I think that's your only option. Another idea: Maybe make your own extractor that includes the python script, vbscript, and python interpreter. You could just use a 7zip SFX or something.",1.2,True,1,3354 2014-08-23 06:55:49.593,Making unique screen transitions - kivy,"I have two screens and want to change the SlideTransition from my second to first screen to direction: 'right' while keeping the first to second transition the default. The docs only show how to change the transition for every transition. How would I make a transition unique to one screen, done in the kv file? @@ -33341,17 +33341,17 @@ The solution i thought was to redirect terminal output to a text file and read t Thanks","The one way I can think of doing this is to refresh the page. So, you could set the page to refresh itself every X seconds. You would hope that the file you are reading is not large though, or it will impact performance. Better to have the output in memory.",0.0,False,1,3358 2014-08-28 13:33:34.857,Access Django app from other computers,"I am developing a web application on my local computer in Django. +Now I want my webapp to be accessible to other computers on my network. We have a common network drive ""F:/"". Should I place my files on this drive or can I just write something like ""python manage.py runserver test_my_app:8000"" in the command prompt to let other computers in the network access the web server by writing ""test_my_app:8000"" in the browser address field? Do I have to open any ports and how can I do this?","Just add your own IP Address to ALLOWED_HOSTS +ALLOWED_HOSTS = ['192.168.1.50', '127.0.0.1', 'localhost'] +and run your server python manage.py runserver 192.168.1.50:8000 +and access your own server to other computer in your network",0.5658516464399139,False,3,3359 +2014-08-28 13:33:34.857,Access Django app from other computers,"I am developing a web application on my local computer in Django. Now I want my webapp to be accessible to other computers on my network. We have a common network drive ""F:/"". Should I place my files on this drive or can I just write something like ""python manage.py runserver test_my_app:8000"" in the command prompt to let other computers in the network access the web server by writing ""test_my_app:8000"" in the browser address field? Do I have to open any ports and how can I do this?","very simple, first you need to add ip to allowed host, ALLOWED_HOST =['*'] 2. then execute python manage.py runserver 0.0.0.0:8000 now you can access the local project on different system in the same network",0.0,False,3,3359 2014-08-28 13:33:34.857,Access Django app from other computers,"I am developing a web application on my local computer in Django. -Now I want my webapp to be accessible to other computers on my network. We have a common network drive ""F:/"". Should I place my files on this drive or can I just write something like ""python manage.py runserver test_my_app:8000"" in the command prompt to let other computers in the network access the web server by writing ""test_my_app:8000"" in the browser address field? Do I have to open any ports and how can I do this?","Just add your own IP Address to ALLOWED_HOSTS -ALLOWED_HOSTS = ['192.168.1.50', '127.0.0.1', 'localhost'] -and run your server python manage.py runserver 192.168.1.50:8000 -and access your own server to other computer in your network",0.5658516464399139,False,3,3359 -2014-08-28 13:33:34.857,Access Django app from other computers,"I am developing a web application on my local computer in Django. Now I want my webapp to be accessible to other computers on my network. We have a common network drive ""F:/"". Should I place my files on this drive or can I just write something like ""python manage.py runserver test_my_app:8000"" in the command prompt to let other computers in the network access the web server by writing ""test_my_app:8000"" in the browser address field? Do I have to open any ports and how can I do this?","Run the application with IP address then access it in other machines. python manage.py runserver 192.168.56.22:1234 Both machines should be in same network, then only this will work.",0.336246259354525,False,3,3359 @@ -33463,9 +33463,6 @@ Any idea on how to do this? I have tried to create the cluster using Amazon's co Another option is being able to change the default permissions for EMR instances so mrjob will be able to take advantage of it.","Well, after many searches, it seems there is no such option",1.2,True,1,3362 2014-09-02 13:51:47.310,Error installing Pygame / Python 3.4.1,"I'm trying to install Pygame and it returns me the following error ""Python version 3.4 required which was not found in the registry"". However I already have the Python 3.4.1 installed on my system. Does anyone know how to solve that problem? I've been using Windows 8.1 -Thanks in advance.",Are you using a 64-bit operating system? Try using the 32-bit installer.,0.5457054096481145,False,2,3363 -2014-09-02 13:51:47.310,Error installing Pygame / Python 3.4.1,"I'm trying to install Pygame and it returns me the following error ""Python version 3.4 required which was not found in the registry"". However I already have the Python 3.4.1 installed on my system. Does anyone know how to solve that problem? -I've been using Windows 8.1 Thanks in advance.","Tips I can provide: Add Python to your Path file in the Advanced settings of your Environmental Variables (just search for it in the control panel) @@ -33475,6 +33472,9 @@ python setup.py But this will only work if the pygame setup file is called setup.py (it's been a while since I downloaded it), you added Python to the Path file and you're currently in the correct directory in command prompt. To test if it worked try importing pygame and see if you got an error or not.",0.0,False,2,3363 +2014-09-02 13:51:47.310,Error installing Pygame / Python 3.4.1,"I'm trying to install Pygame and it returns me the following error ""Python version 3.4 required which was not found in the registry"". However I already have the Python 3.4.1 installed on my system. Does anyone know how to solve that problem? +I've been using Windows 8.1 +Thanks in advance.",Are you using a 64-bit operating system? Try using the 32-bit installer.,0.5457054096481145,False,2,3363 2014-09-03 16:04:56.840,Start Tkinter in background,"Comically enough, I was really annoyed when tkinter windows opened in the background on Mac. However, now I am on Linux, and I want tkinter to open in background. I don't know how to do this, and when I google how to do it, all I can find are a lot of angry Mac users who can't get tkinter to open in the foreground. I should note that I am using python2.7 and thus Tkinter not tkinter (very confusing).","I am using Linux Mint. In order to make a program not show up in the foreground (i.e. be hidden behind all of the other windows), one should use root.lower() as aforementioned in the comments. However, please note (and this seems to happen on multiple platforms) that root.lower() will not change the focus of the window. Therefore, even if you use .lower() and run the script, and if you press [alt] + [F4], for example, the Tkinter window that was just opened (even though you cannot see it) will be closed. @@ -33600,10 +33600,10 @@ It's schedule the job correctly and run it, but it store the job in apscheduler Can please tell me how to store the job in my own database instead of default db.","Simply give the mongodb jobstore a different ""database"" argument. It seems like the API documentation for this job store was not included in what is available on ReadTheDocs, but you can inspect the source and see how it works.",0.3869120172231254,False,1,3383 2014-09-17 13:05:59.280,How can I get Python to recognize the SPSSClient Module?,"I originally installed Canopy to use Python, but it would not recognize the SPSS modules, so I removed canopy, re-downloaded python2.7, and changed my PATH to ;C:\Python27. In SPSS, I changed the default python file directory to C:\Python27. Python still will not import the SPSS modules. I have a copy of SPSS 22, so python is integrated into it... -Any thoughts on what might be causing this, and how to fix it?","I figured this out only with some help from a friend who had a similar issue. I had downloaded python from python.org, without realizing it was 32 bit. All of the SPSS modules are 64 bit! I downloaded the correct version of python, and then copied the spss modules from my spss install (inside the python folder within spss) into my python library. modules are working now!",1.2,True,2,3384 +Any thoughts on what might be causing this, and how to fix it?",Glad that is solved. The 32/64-bit issue has been a regular confusion for Statistics users.,0.2012947653214861,False,2,3384 2014-09-17 13:05:59.280,How can I get Python to recognize the SPSSClient Module?,"I originally installed Canopy to use Python, but it would not recognize the SPSS modules, so I removed canopy, re-downloaded python2.7, and changed my PATH to ;C:\Python27. In SPSS, I changed the default python file directory to C:\Python27. Python still will not import the SPSS modules. I have a copy of SPSS 22, so python is integrated into it... -Any thoughts on what might be causing this, and how to fix it?",Glad that is solved. The 32/64-bit issue has been a regular confusion for Statistics users.,0.2012947653214861,False,2,3384 +Any thoughts on what might be causing this, and how to fix it?","I figured this out only with some help from a friend who had a similar issue. I had downloaded python from python.org, without realizing it was 32 bit. All of the SPSS modules are 64 bit! I downloaded the correct version of python, and then copied the spss modules from my spss install (inside the python folder within spss) into my python library. modules are working now!",1.2,True,2,3384 2014-09-18 00:24:41.657,"In Python, how can I run a module that's not in my path?","I'm using PyCharm, and in the shell, I can't run a file that isn't in the current directory. I know how to change directories in the terminal. But I can't run files from other folders. How can I fix this? Using Mac 2.7.8. Thanks!","There are multiple ways to solve this. In PyCharm go to Run/Edit Configurations and add the environment variable PYTHONPATH to $PYTHONPATH: and hit apply. The problem with this approach is that the imports will still be unresolved but the code will run fine as python knows where to find your modules at run time. @@ -33886,11 +33886,11 @@ If your client side needs dynamic, two-way connections using non-HTTP protocols, 2014-10-21 13:14:05.840,Run specific django manage.py commands at intervals,"I need to run a specific manage.py commands on an EC2 instance every X minutes. For example: python manage.py some_command. I have looked up django-chronograph. Following the instructions, I've added chronograph to my settings.py but on runserver it keeps telling me No module named chronograph. Is there something I'm missing to get this running? And after running how do I get manage.py commands to run using chronograph? -Edit: It's installed in the EC2 instance's virtualenv.",I would suggest you to configure cron to run your command at specific times/intervals.,0.1352210990936997,False,2,3434 +Edit: It's installed in the EC2 instance's virtualenv.","First, install it by running pip install django-chronograph.",0.0,False,2,3434 2014-10-21 13:14:05.840,Run specific django manage.py commands at intervals,"I need to run a specific manage.py commands on an EC2 instance every X minutes. For example: python manage.py some_command. I have looked up django-chronograph. Following the instructions, I've added chronograph to my settings.py but on runserver it keeps telling me No module named chronograph. Is there something I'm missing to get this running? And after running how do I get manage.py commands to run using chronograph? -Edit: It's installed in the EC2 instance's virtualenv.","First, install it by running pip install django-chronograph.",0.0,False,2,3434 +Edit: It's installed in the EC2 instance's virtualenv.",I would suggest you to configure cron to run your command at specific times/intervals.,0.1352210990936997,False,2,3434 2014-10-21 14:00:35.233,32bit exe on 64bit Python using py2exe,"I need to make an 32bit exe file using py2exe. The problem is that my machine and Python are 64bit. Is there some simple way how to make 32bit using 64bit Python and py2exe? I heard that I should uninstall py2exe and install new py2exe 32bit, can this help me? EDIT: If 32bit py2exe works, can I install 32bit py2exe next to my 64bit py2exe?","You should install the 32-bit python (in a separate directory, you can do it on the same machine). Install 32-bit py2exe for this 32-bit Python installation plus all Python packages that you need. Then you can build a 32-bit eecutable.",1.2,True,1,3435 @@ -33926,18 +33926,18 @@ What I would like to do is to perform something like bootstrap action on the alr I can imagine doing this in 2 steps: 1) run the script on all the running instances (It would be nice if that would be somehow possible for example from boto) 2) adding the script to bootstrap actions for case that I'd like to resize the cluster. -So my question is: Is something like this possible using boto or at least AWS CLI? I am going through the documentation and source code on github, but I am not able to figure out how to add new ""bootstrap"" actions when the cluster is already running.","Late answer, but I'll give it a shot: -That is going to be tough. -You could install Amazon SSM Agent and use the remote command interface to launch a command on all instances. However, you will have to assign the appropriate SSM roles to the instances, which will require rebuilding the cluster AFAIK. However, any future commands will not require rebuilding. -You would then be able to use the CLI to run commands on all nodes (probably boto as well, haven't checked that).",0.9950547536867304,False,2,3440 +So my question is: Is something like this possible using boto or at least AWS CLI? I am going through the documentation and source code on github, but I am not able to figure out how to add new ""bootstrap"" actions when the cluster is already running.","bootstrap script executed once the cluster started (first time or at the beginning), however AWS provide ssh to master and other nodes there you can write shell script,install libs, packages, python program , git clone your repo etc... +Hope this may be helpful. +Amit",0.0,False,2,3440 2014-10-26 17:18:47.110,"AWS EMR perform ""bootstrap"" script on all the already running machines in cluster","I have one EMR cluster which is running 24/7. I can't turn it off and launch the new one. What I would like to do is to perform something like bootstrap action on the already running cluster, preferably using Python and boto or AWS CLI. I can imagine doing this in 2 steps: 1) run the script on all the running instances (It would be nice if that would be somehow possible for example from boto) 2) adding the script to bootstrap actions for case that I'd like to resize the cluster. -So my question is: Is something like this possible using boto or at least AWS CLI? I am going through the documentation and source code on github, but I am not able to figure out how to add new ""bootstrap"" actions when the cluster is already running.","bootstrap script executed once the cluster started (first time or at the beginning), however AWS provide ssh to master and other nodes there you can write shell script,install libs, packages, python program , git clone your repo etc... -Hope this may be helpful. -Amit",0.0,False,2,3440 +So my question is: Is something like this possible using boto or at least AWS CLI? I am going through the documentation and source code on github, but I am not able to figure out how to add new ""bootstrap"" actions when the cluster is already running.","Late answer, but I'll give it a shot: +That is going to be tough. +You could install Amazon SSM Agent and use the remote command interface to launch a command on all instances. However, you will have to assign the appropriate SSM roles to the instances, which will require rebuilding the cluster AFAIK. However, any future commands will not require rebuilding. +You would then be able to use the CLI to run commands on all nodes (probably boto as well, haven't checked that).",0.9950547536867304,False,2,3440 2014-10-27 19:39:08.317,Using numpy with PyDev,"Although I've been doing things with python by myself for a while now, I'm completely new to using python with external libraries. As a result, I seem to be having trouble getting numpy to work with PyDev. Right now I'm using PyDev in Eclipse, so I first tried to go to My Project > Properties > PyDev - PYTHONPATH > External Libraries > Add zip/jar/egg, similar to how I would add libraries in Eclipse. I then selected the numpy-1.9.0.zip file that I had downloaded. I tried importing numpy and using it, but I got the following error message in Eclipse: @@ -33968,10 +33968,17 @@ build\lib.win-amd64-2.7\numpy\linalg\lapack_lite.pyd : fatal error LNK1120: 7 un error: Setup script exited with error: Command ""C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\BLAS /LIBPATH:C:\Python27\libs /LIBPATH:C:\Python27\PCbuild\amd64 /LIBPATH:build\temp.win-amd64-2.7 lapack.lib blas.lib /EXPORT:initlapack_lite build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_litemodule.obj /OUT:build\lib.win-amd64-2.7\numpy\linalg\lapack_lite.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_lite.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_lite.pyd.manifest"" failed with exit status 1120 -What is the correct way to install the 64-bit versions NumPy and SciPy on a 64-bit Windows machine? Did I miss anything? Do I need to specify something somewhere? There is no information for Windows on these problems that I can find, only for Linux or Mac OS X, but they don't help me as I can't use their commands.","for python 3.6, the following worked for me -launch cmd.exe as administrator -pip install numpy-1.13.0+mkl-cp36-cp36m-win32 -pip install scipy-0.19.1-cp36-cp36m-win32",0.0,False,2,3444 +What is the correct way to install the 64-bit versions NumPy and SciPy on a 64-bit Windows machine? Did I miss anything? Do I need to specify something somewhere? There is no information for Windows on these problems that I can find, only for Linux or Mac OS X, but they don't help me as I can't use their commands.","Follow these steps: + +Open CMD as administrator +Enter this command : cd.. +cd.. +cd Program Files\Python38\Scripts +Download the package you want and put it in Python38\Scripts folder. +pip install packagename.whl +Done + +You can write your python version instead of ""38""",0.0,False,2,3444 2014-10-30 15:39:47.537,Installing NumPy and SciPy on 64-bit Windows (with Pip),"I found out that it's impossible to install NumPy/SciPy via installers on Windows 64-bit, that's only possible on 32-bit. Because I need more memory than a 32-bit installation gives me, I need the 64-bit version of everything. I tried to install everything via Pip and most things worked. But when I came to SciPy, it complained about missing a Fortran compiler. So I installed Fortran via MinGW/MSYS. But you can't install SciPy right away after that, you need to reinstall NumPy. So I tried that, but now it doesn't work anymore via Pip nor via easy_install. Both give these errors: @@ -33985,17 +33992,10 @@ build\lib.win-amd64-2.7\numpy\linalg\lapack_lite.pyd : fatal error LNK1120: 7 un error: Setup script exited with error: Command ""C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\BLAS /LIBPATH:C:\Python27\libs /LIBPATH:C:\Python27\PCbuild\amd64 /LIBPATH:build\temp.win-amd64-2.7 lapack.lib blas.lib /EXPORT:initlapack_lite build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_litemodule.obj /OUT:build\lib.win-amd64-2.7\numpy\linalg\lapack_lite.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_lite.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_lite.pyd.manifest"" failed with exit status 1120 -What is the correct way to install the 64-bit versions NumPy and SciPy on a 64-bit Windows machine? Did I miss anything? Do I need to specify something somewhere? There is no information for Windows on these problems that I can find, only for Linux or Mac OS X, but they don't help me as I can't use their commands.","Follow these steps: - -Open CMD as administrator -Enter this command : cd.. -cd.. -cd Program Files\Python38\Scripts -Download the package you want and put it in Python38\Scripts folder. -pip install packagename.whl -Done - -You can write your python version instead of ""38""",0.0,False,2,3444 +What is the correct way to install the 64-bit versions NumPy and SciPy on a 64-bit Windows machine? Did I miss anything? Do I need to specify something somewhere? There is no information for Windows on these problems that I can find, only for Linux or Mac OS X, but they don't help me as I can't use their commands.","for python 3.6, the following worked for me +launch cmd.exe as administrator +pip install numpy-1.13.0+mkl-cp36-cp36m-win32 +pip install scipy-0.19.1-cp36-cp36m-win32",0.0,False,2,3444 2014-11-02 11:30:39.970,32 bit python on 64 bit windows machine,"I've downloaded pythonxy (2.7.6.1) on my new 64 bit Windows machine (Windows 7 Enterprise, SP1). When I try to run python, I get an error saying the side-by-side configuration was incorrect. WinPython 32 bit (2.7.6.3) shows the same behavior, WinPython 64 bit is fine. However, I badly need to compile Python modules with boost and found myself taking the first few steps into what I believe will be searching-the-internet/configuration/compilation hell for 64 bit, so I'd rather try to make the 32-bit python work, for which I have my whole MinGW procedure set up and working. Does anybody know what I need to do in order to fix the side-by-side error? Install some redristributable package or something like that?","I just got an answer from one of my colleagues who told me had the exact same problem. The solution was indeed downloading and installing a version of vcredist_x86.exe, but the trick is to find the exact right one. Apparently you can get to a page somewhere from where you can choose the right version. Sorry for not being able to give more exact information, I just have the file now and it works, but it doesn't even say the version number in the file name. This is all very obscure for my taste, but then I'm not a Windows guy.",0.0,False,1,3445 2014-11-02 14:08:08.190,ZeroRPC auto-assign free port number,"I am using ZeroRPC for a project, where there may be multiple instances running on the same machine. For this reason, I need to abe able to auto-assign unused port numbers. I know how to accomplish this with regular sockets using socket.bind(('', 0)) or with ZeroMQ using the bind_to_random_port method, but I cannot figure out how to do this with ZeroRPC. @@ -34063,11 +34063,6 @@ Alternately, you could choose something like zeromq that provides a message tran 2014-11-11 00:01:06.530,python 2.7 - how to print with utf-8 characters?,"i´m working with python version 2.7 and I need to know how to print utf-8 characters. Can anyone help me? ->I already tried putting # coding: iso-8859-1 -*- on top, ->using encode like print ""nome do seu chápa"".encode('iso-8859-1') also doesn't work and even --> using print u""Nâo"" doesn't work","I got the answer: my console needed to be restarted. I use Spyder(from Python x,y) for development and this error occcured, so beware. -UPDATE: Spyder console seems to suck, because to get it to work, I had to use string.encode('latin1') and (now here's the catch) OPEN A NEW CONSOLE! If I try to reuse my already open console, special characters just won't work.",0.0,False,2,3458 -2014-11-11 00:01:06.530,python 2.7 - how to print with utf-8 characters?,"i´m working with python version 2.7 and I need to know how to print utf-8 characters. Can anyone help me? -->I already tried putting # coding: iso-8859-1 -*- on top, -->using encode like print ""nome do seu chápa"".encode('iso-8859-1') also doesn't work and even -> using print u""Nâo"" doesn't work","A more complete response. Strings have two types in Python 2, str and unicode. When using str, you are using bytes so you can write them directly to files like stdout. @@ -34077,6 +34072,11 @@ You have bytes but you try to encode them so Python 2 first decodes them behind Now, when doing the following: print u""Nâo"".encode('utf-8') You are telling Python 2 that you start with Unicode so then it will encode it without the problematic decode. Python 3 solved this nastiness.",0.0,False,2,3458 +2014-11-11 00:01:06.530,python 2.7 - how to print with utf-8 characters?,"i´m working with python version 2.7 and I need to know how to print utf-8 characters. Can anyone help me? +->I already tried putting # coding: iso-8859-1 -*- on top, +->using encode like print ""nome do seu chápa"".encode('iso-8859-1') also doesn't work and even +-> using print u""Nâo"" doesn't work","I got the answer: my console needed to be restarted. I use Spyder(from Python x,y) for development and this error occcured, so beware. +UPDATE: Spyder console seems to suck, because to get it to work, I had to use string.encode('latin1') and (now here's the catch) OPEN A NEW CONSOLE! If I try to reuse my already open console, special characters just won't work.",0.0,False,2,3458 2014-11-12 07:42:59.927,how to start iPython in xshell,"I just begin to use xshell in Windows 7, it looks good, but how can I enter interactive console of iPython in xshell? In cmd of windows, when I type ""ipython"", it will bring me to the interactive console automatically. However, in xshell, I've tried several command like ""ipython"", ""ipython console"", all of them would not bring me to the interactive console of ipython. @@ -34116,11 +34116,11 @@ Automatic Upload I find Automatic Upload handy for when I want the changes in newly saved Django files reflected on the server within seconds of hitting save.",0.0,False,1,3464 2014-11-17 04:17:52.957,Which version of Python did pip or easy_install refer to by default?,"I am a non-programmer who started to learn Python. My Mac OS X Yosemite shipped with Python 2.7.6. I installed Python 3.4.2 too. If I use pip or easy_install in the terminal to install a package, how do I know which Python I installed the package in? It seems Python 3.4.2 shipped with pip and easy_install, but I think Python 2.7.6 may also have some version of pip or easy_install. I know my system can have both versions of Python, but can it have multiple versions of pip or easy_install?","There's an easy way around it - use pip2 or pip2.7 or pip-2.7 for Python 2, and pip3 or pip3.4 or pip-3.4 for Python 3. Both version ship with easy_install, but Python 2 does not contain pip by default - you have to install it yourself.",1.2,True,1,3465 2014-11-18 19:04:52.423,Using Anaconda modules outside of IPython,"I'm interested in creating physics simulations with Python so I decided to download Anaconda. Inside of an IPython notebook I can use the pylab module to plot functions, for example, with ease. However, if I try to import pylab in a script outside of IPython, it won't work; Python claims that the pylab module doesn't exist. -So how can I use Anaconda's modules outside of IPython?","I bet it will work if you use Anaconda's Python distribution. -Try running ./anaconda/bin/python and importing it from that Python session.",0.2012947653214861,False,2,3466 -2014-11-18 19:04:52.423,Using Anaconda modules outside of IPython,"I'm interested in creating physics simulations with Python so I decided to download Anaconda. Inside of an IPython notebook I can use the pylab module to plot functions, for example, with ease. However, if I try to import pylab in a script outside of IPython, it won't work; Python claims that the pylab module doesn't exist. So how can I use Anaconda's modules outside of IPython?","As a side note, If you want to keep this functionality and move to a more script-like environment I would suggest using something like Spyder IDE. It comes with an editor linked with the IPython console that supports all the same magics as the IPython notebook.",0.0,False,2,3466 +2014-11-18 19:04:52.423,Using Anaconda modules outside of IPython,"I'm interested in creating physics simulations with Python so I decided to download Anaconda. Inside of an IPython notebook I can use the pylab module to plot functions, for example, with ease. However, if I try to import pylab in a script outside of IPython, it won't work; Python claims that the pylab module doesn't exist. +So how can I use Anaconda's modules outside of IPython?","I bet it will work if you use Anaconda's Python distribution. +Try running ./anaconda/bin/python and importing it from that Python session.",0.2012947653214861,False,2,3466 2014-11-19 10:10:02.570,IDLE crashes for certain buttons on Mac,"I am running OS X 10.9.5, and IDLE w/ Python 3.4.1. When I press the buttons for (¨/^) or (´/`), IDLE crashes and the program closes. This causes me to lose changes to files, as well as time. My fellow students using Mac experience the same problem. @@ -34144,13 +34144,13 @@ In java its like this: Import processing.sound.*; Thanks","Use the add_library function: add_library(""sound"")",0.0,False,2,3471 -2014-11-21 16:50:49.297,"django development server, how to stop it when it run in background?","I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?","As far as i know ctrl+c or kill process is only ways to do that on remote machine. -If you will use Gunicorn server or somethink similar you will be able to do that using Supervisor.",0.1218406379589197,False,5,3472 -2014-11-21 16:50:49.297,"django development server, how to stop it when it run in background?","I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?",well it seems that it's a bug that django hadn't provided a command to stop the development server . I thought it have one before~~~~~,0.2401167094949473,False,5,3472 +2014-11-21 16:50:49.297,"django development server, how to stop it when it run in background?","I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?",Ctrl+c should work. If it doesn't Ctrl+/ will force kill the process.,0.1618299653758019,False,5,3472 +2014-11-21 16:50:49.297,"django development server, how to stop it when it run in background?","I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?",You can Quit the server by hitting CTRL-BREAK.,-0.1218406379589197,False,5,3472 2014-11-21 16:50:49.297,"django development server, how to stop it when it run in background?","I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?","From task manager you can end the python tasks that are running. Now run python manage.py runserver from your project directory and it will work.",0.0407936753323291,False,5,3472 -2014-11-21 16:50:49.297,"django development server, how to stop it when it run in background?","I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?",You can Quit the server by hitting CTRL-BREAK.,-0.1218406379589197,False,5,3472 -2014-11-21 16:50:49.297,"django development server, how to stop it when it run in background?","I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?",Ctrl+c should work. If it doesn't Ctrl+/ will force kill the process.,0.1618299653758019,False,5,3472 +2014-11-21 16:50:49.297,"django development server, how to stop it when it run in background?","I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?",well it seems that it's a bug that django hadn't provided a command to stop the development server . I thought it have one before~~~~~,0.2401167094949473,False,5,3472 +2014-11-21 16:50:49.297,"django development server, how to stop it when it run in background?","I use a Cloud server to test my django small project, I type in manage.py runserver and then I log out my cloud server, I can visit my site normally, but when I reload my cloud server, I don't know how to stop the development server, I had to kill the process to stop it, is there anyway to stop the development?","As far as i know ctrl+c or kill process is only ways to do that on remote machine. +If you will use Gunicorn server or somethink similar you will be able to do that using Supervisor.",0.1218406379589197,False,5,3472 2014-11-22 19:06:19.233,Trouble grasping MIBs with PySNMP,"I am fairly new to the SNMP protocol and have only been introduced to it recently in my computer networking course. I understand how the manager sends Gets, Sets, GetNext, GetBulk and all that, it will catch Traps and such. One thing I don't entirely understand is the MIB From what I gather, the MIB is chillen on an agent and the Manager will query for the MIB tree. That is fine, although the Manager needs the OID to be able to properly query. One question I have regards if these are hardcoded or not. Are the OIDs hardcoded in the manager or not? @@ -34366,17 +34366,17 @@ You can bind to . That binding will tell you what key was pressed, and 2014-12-05 03:32:26.493,How to install python package with a different name using PIP,"When installing a new python package with PIP, can I change the package name because there is another package with the same name? Or, how can I change the existing package's name?","This is not possible with the pip command line tool. All of the packages on PyPI have unique names. Packages often require and depend on each other, and assume the name will not change.",-0.0904550252145576,False,5,3495 2014-12-05 03:32:26.493,How to install python package with a different name using PIP,"When installing a new python package with PIP, can I change the package name because there is another package with the same name? -Or, how can I change the existing package's name?","I Don't think it is possible to change the name of package by using pip. -Because pip can install packages which are exist and gives error if there is no package name which you write for change the name of package.",0.0,False,5,3495 -2014-12-05 03:32:26.493,How to install python package with a different name using PIP,"When installing a new python package with PIP, can I change the package name because there is another package with the same name? Or, how can I change the existing package's name?","If you are struggling to install the correct package when using pip install 'module', you could always download its corresponding wheel file (.whl extension) and then install this directly using pip. This has worked for me in various situations in the past.",0.0904550252145576,False,5,3495 2014-12-05 03:32:26.493,How to install python package with a different name using PIP,"When installing a new python package with PIP, can I change the package name because there is another package with the same name? -Or, how can I change the existing package's name?","Create a new virtualenv and then install the package on new virtualenv, with this you can have the different version of packages as well.",0.1794418372930847,False,5,3495 +Or, how can I change the existing package's name?","I Don't think it is possible to change the name of package by using pip. +Because pip can install packages which are exist and gives error if there is no package name which you write for change the name of package.",0.0,False,5,3495 2014-12-05 03:32:26.493,How to install python package with a different name using PIP,"When installing a new python package with PIP, can I change the package name because there is another package with the same name? Or, how can I change the existing package's name?","It's not possible to change ""import path"" (installed name) by specifying arguments to pip. All other options require some form of ""changes to the package"": A. Use pip install -e git+http://some_url#egg=some-name: that way even if both packages have the same import path, they will be saved under different directories (using some-name provided after #egg=). After this you can go to the source directories of packages (usually venv/src/some-name) and rename some folders to change import paths B-C. Fork the repository, make changes, then install the package from that repository. Or you can publish your package on PyPI using different name and install it by name D. use pip download to put one of the packages in your project, then rename folders as you like",0.5295856727919357,False,5,3495 +2014-12-05 03:32:26.493,How to install python package with a different name using PIP,"When installing a new python package with PIP, can I change the package name because there is another package with the same name? +Or, how can I change the existing package's name?","Create a new virtualenv and then install the package on new virtualenv, with this you can have the different version of packages as well.",0.1794418372930847,False,5,3495 2014-12-05 04:35:08.907,"In using OpenErp 7 or Odoo 8, how do I modify it such that a manager assigned to a project is the one who will approve all timesheet entries for it?","I have downloaded and installed and also tested via a virtual machine online Odoo 8 and OpenErp 7. I have spent many hours tinkering with the apps and features of both. I am unable to find any way from hours I spend searching or tinkering for a method to change the approve timesheet functionality in the manner I will explain below. Each project will have an assigned manager. Any number employees can enter time for a project. Once employees send their timesheet to be be approved, each respective manager will only get that portion of the timesheet for which time was charged to the project they managed. They should be able to view each project and the employees in them.",You can manage this by grouping each employee according to their privilege. For example you have two groups Managerial and employee group so each of them might have different or some how common privilege on certain python objects from OpenERP so please identify those python objects and explore more in Setting >> Users >> Groups,1.2,True,1,3496 2014-12-06 23:03:39.810,Starting a python script at boot and loading GUI after that,"Can anyone tel me how to start a python script on boot, and then also load the GUI ? I am debian based Raspbian OS. @@ -34390,13 +34390,6 @@ In Kivy, Canvas.size doesn't exists, but i guess you called your widget a canvas 2014-12-08 16:06:27.003,Automating IBM SPSS Data Collection survey export?,"I'm so sorry for the vague question here, but I'm hoping an SPSS expert will be able to help me out here. We have some surveys that are done via SPSS, from which we extract data for an internal report. Right now the process is very cumbersome and requires going to the SPSS Data Collection Interviewer Server Administration page and manually exporting data from two different projects (which takes hours at a time!). We then take that data, massage it, and upload it to another database that drives the internal report. My question is, does anyone out there know how to automate this process? Is there a SQL Server database behind the SPSS data? Where does the .mdd file come in to play? Can my team (who is well-versed in extracting data from various sources) tap into the SQL Server database behind SPSS to get our data? Or do we need some sort of Python script and plugin? If I'm missing information that would be helpful in answering the question, please let me know. I'm happy to provide it; I just don't know what to provide. -Thanks so much.","This isn't as clean as working directly with whatever database is holding the data, but you could do something with an exported data set: -There may or may not be a way for you to write and run an export script from inside your Admin panel or whatever. If not, you could write a simple Python script using Selenium WebDriver which logs into your admin panel and exports all data to a *.sav data file. -Then you can use the Python SPSS extensions to write your analysis scripts. Note that these scripts have to run on a machine that has a copy of SPSS installed. -Once you have your data and analysis results accessible to Python, you should be able to easily write that to your other database.",1.2,True,3,3499 -2014-12-08 16:06:27.003,Automating IBM SPSS Data Collection survey export?,"I'm so sorry for the vague question here, but I'm hoping an SPSS expert will be able to help me out here. We have some surveys that are done via SPSS, from which we extract data for an internal report. Right now the process is very cumbersome and requires going to the SPSS Data Collection Interviewer Server Administration page and manually exporting data from two different projects (which takes hours at a time!). We then take that data, massage it, and upload it to another database that drives the internal report. -My question is, does anyone out there know how to automate this process? Is there a SQL Server database behind the SPSS data? Where does the .mdd file come in to play? Can my team (who is well-versed in extracting data from various sources) tap into the SQL Server database behind SPSS to get our data? Or do we need some sort of Python script and plugin? -If I'm missing information that would be helpful in answering the question, please let me know. I'm happy to provide it; I just don't know what to provide. Thanks so much.","There are a number of different ways you can accomplish easing this task and even automate it completely. However, if you are not an IBM SPSS Data Collection expert and don't have access to somebody who is or have the time to become one, I'd suggest getting in touch with some of the consultants who offer services on the platform. Internally IBM doesn't have many skilled SPSS resources available, so they rely heavily on external partners to do services on a lot of their products. This goes for IBM SPSS Data Collection in particular, but is also largely true for SPSS Statistics. As noted by previous contributors there is an approach using Python for data cleaning, merging and other transformations and then loading that output into your report database. For maintenance reasons I'd probably not suggest this approach. Though you are most likely able to automate the export of data from SPSS Data Collection to a sav file with a simple SPSS Syntax (and an SPSS add-on data component), it is extremely error prone when upgrading either SPSS Statistics or SPSS Data Collection. From a best practice standpoint, you ought to use the SPSS Data Collection Data Management module. It is very flexible and hardly requires any maintenance on upgrades, because you are working within the same data model framework (e.g. survey metadata, survey versions, labels etc. is handled implicitly) right until you load your transformed data into your reporting database. @@ -34420,6 +34413,13 @@ Hope that helps.",0.1352210990936997,False,3,3499 2014-12-08 16:06:27.003,Automating IBM SPSS Data Collection survey export?,"I'm so sorry for the vague question here, but I'm hoping an SPSS expert will be able to help me out here. We have some surveys that are done via SPSS, from which we extract data for an internal report. Right now the process is very cumbersome and requires going to the SPSS Data Collection Interviewer Server Administration page and manually exporting data from two different projects (which takes hours at a time!). We then take that data, massage it, and upload it to another database that drives the internal report. My question is, does anyone out there know how to automate this process? Is there a SQL Server database behind the SPSS data? Where does the .mdd file come in to play? Can my team (who is well-versed in extracting data from various sources) tap into the SQL Server database behind SPSS to get our data? Or do we need some sort of Python script and plugin? If I'm missing information that would be helpful in answering the question, please let me know. I'm happy to provide it; I just don't know what to provide. +Thanks so much.","This isn't as clean as working directly with whatever database is holding the data, but you could do something with an exported data set: +There may or may not be a way for you to write and run an export script from inside your Admin panel or whatever. If not, you could write a simple Python script using Selenium WebDriver which logs into your admin panel and exports all data to a *.sav data file. +Then you can use the Python SPSS extensions to write your analysis scripts. Note that these scripts have to run on a machine that has a copy of SPSS installed. +Once you have your data and analysis results accessible to Python, you should be able to easily write that to your other database.",1.2,True,3,3499 +2014-12-08 16:06:27.003,Automating IBM SPSS Data Collection survey export?,"I'm so sorry for the vague question here, but I'm hoping an SPSS expert will be able to help me out here. We have some surveys that are done via SPSS, from which we extract data for an internal report. Right now the process is very cumbersome and requires going to the SPSS Data Collection Interviewer Server Administration page and manually exporting data from two different projects (which takes hours at a time!). We then take that data, massage it, and upload it to another database that drives the internal report. +My question is, does anyone out there know how to automate this process? Is there a SQL Server database behind the SPSS data? Where does the .mdd file come in to play? Can my team (who is well-versed in extracting data from various sources) tap into the SQL Server database behind SPSS to get our data? Or do we need some sort of Python script and plugin? +If I'm missing information that would be helpful in answering the question, please let me know. I'm happy to provide it; I just don't know what to provide. Thanks so much.","As mentioned by other contributors, there are a few ways to achieve this. The simplest I can suggest is using the DMS (data management script) and windows scheduler. Ideally you should follow below steps. Prerequisite: 1. You should have access to the server running IBM Data collection @@ -34464,7 +34464,8 @@ When I try to run my tests, however, I now bomb out at step 2 above. When I do i What should I do? EDIT: More info I first made a class, class A and did a migration to create the table. Then I ran this against my db. Then I wrote a manual migration to populate some data that I knew would be there. I ra n this against the db. I realized sometime later that I need an extra field on the model. I added that field and did a migration and ran it against the database. Everything worked fine and I confirmed the new column is in the database. -Now, I went to run my tests. It tried to create the test db and bombed out, saying ""1054 - Unknown column [my new column that I added to an existing table]"" at the time when it is trying to run the populate data script that I wrote. It is likely looking at the table, noticing that the third field exists in the model, but not yet in the database, but I don't know how to do it better.","I believe this was because the migration scripts were getting called out of order, due to a problem I had setting them up. Everything is ok now.",1.2,True,4,3501 +Now, I went to run my tests. It tried to create the test db and bombed out, saying ""1054 - Unknown column [my new column that I added to an existing table]"" at the time when it is trying to run the populate data script that I wrote. It is likely looking at the table, noticing that the third field exists in the model, but not yet in the database, but I don't know how to do it better.","This happened to me because I faked one migration (m1), created another (m2), and then tried to migrate m2 before I had faked my initial migration (m1). +So in my case I had to migrate --fake m1 and then migrate m2.",0.0,False,4,3501 2014-12-10 14:05:23.033,Django 1054 - Unknown Column in field list,"I have a Django project and I did the following: Added a table with some columns @@ -34477,13 +34478,7 @@ When I try to run my tests, however, I now bomb out at step 2 above. When I do i What should I do? EDIT: More info I first made a class, class A and did a migration to create the table. Then I ran this against my db. Then I wrote a manual migration to populate some data that I knew would be there. I ra n this against the db. I realized sometime later that I need an extra field on the model. I added that field and did a migration and ran it against the database. Everything worked fine and I confirmed the new column is in the database. -Now, I went to run my tests. It tried to create the test db and bombed out, saying ""1054 - Unknown column [my new column that I added to an existing table]"" at the time when it is trying to run the populate data script that I wrote. It is likely looking at the table, noticing that the third field exists in the model, but not yet in the database, but I don't know how to do it better.","I faced the same issue all what i do to get out this issue just drop all tables in my DB and then run: - -python manage.py makemigrations - -and : - -python manage.py migrate",0.0,False,4,3501 +Now, I went to run my tests. It tried to create the test db and bombed out, saying ""1054 - Unknown column [my new column that I added to an existing table]"" at the time when it is trying to run the populate data script that I wrote. It is likely looking at the table, noticing that the third field exists in the model, but not yet in the database, but I don't know how to do it better.","Unless the new column has a default value defined, the insert statement will expect to add data to that column. Can you move the data load to be after the second migration. (I would have commented, but do not yet have sufficient reputation.)",0.0,False,4,3501 2014-12-10 14:05:23.033,Django 1054 - Unknown Column in field list,"I have a Django project and I did the following: Added a table with some columns @@ -34496,7 +34491,13 @@ When I try to run my tests, however, I now bomb out at step 2 above. When I do i What should I do? EDIT: More info I first made a class, class A and did a migration to create the table. Then I ran this against my db. Then I wrote a manual migration to populate some data that I knew would be there. I ra n this against the db. I realized sometime later that I need an extra field on the model. I added that field and did a migration and ran it against the database. Everything worked fine and I confirmed the new column is in the database. -Now, I went to run my tests. It tried to create the test db and bombed out, saying ""1054 - Unknown column [my new column that I added to an existing table]"" at the time when it is trying to run the populate data script that I wrote. It is likely looking at the table, noticing that the third field exists in the model, but not yet in the database, but I don't know how to do it better.","Unless the new column has a default value defined, the insert statement will expect to add data to that column. Can you move the data load to be after the second migration. (I would have commented, but do not yet have sufficient reputation.)",0.0,False,4,3501 +Now, I went to run my tests. It tried to create the test db and bombed out, saying ""1054 - Unknown column [my new column that I added to an existing table]"" at the time when it is trying to run the populate data script that I wrote. It is likely looking at the table, noticing that the third field exists in the model, but not yet in the database, but I don't know how to do it better.","I faced the same issue all what i do to get out this issue just drop all tables in my DB and then run: + +python manage.py makemigrations + +and : + +python manage.py migrate",0.0,False,4,3501 2014-12-10 14:05:23.033,Django 1054 - Unknown Column in field list,"I have a Django project and I did the following: Added a table with some columns @@ -34509,8 +34510,7 @@ When I try to run my tests, however, I now bomb out at step 2 above. When I do i What should I do? EDIT: More info I first made a class, class A and did a migration to create the table. Then I ran this against my db. Then I wrote a manual migration to populate some data that I knew would be there. I ra n this against the db. I realized sometime later that I need an extra field on the model. I added that field and did a migration and ran it against the database. Everything worked fine and I confirmed the new column is in the database. -Now, I went to run my tests. It tried to create the test db and bombed out, saying ""1054 - Unknown column [my new column that I added to an existing table]"" at the time when it is trying to run the populate data script that I wrote. It is likely looking at the table, noticing that the third field exists in the model, but not yet in the database, but I don't know how to do it better.","This happened to me because I faked one migration (m1), created another (m2), and then tried to migrate m2 before I had faked my initial migration (m1). -So in my case I had to migrate --fake m1 and then migrate m2.",0.0,False,4,3501 +Now, I went to run my tests. It tried to create the test db and bombed out, saying ""1054 - Unknown column [my new column that I added to an existing table]"" at the time when it is trying to run the populate data script that I wrote. It is likely looking at the table, noticing that the third field exists in the model, but not yet in the database, but I don't know how to do it better.","I believe this was because the migration scripts were getting called out of order, due to a problem I had setting them up. Everything is ok now.",1.2,True,4,3501 2014-12-11 06:46:30.953,How to track django user details using zoho CRM,"How to track django user details using zoho CRM? I am new zoho CRM, I got the few information and details how ZOHO CRm will be. Now I want to know one thing, I had implement the django project and also have a account in zoho CRM. Now I would like to Tacke all my user details from app database in zoho crm. @@ -34669,11 +34669,11 @@ Edit: Question answered","According to Lukas Graf: Replace source with . (a single dot) and the relative path after it with a full, absolute path",1.2,True,1,3518 2014-12-31 00:22:51.247,how to do the sum of pixels with Python and OpenCV,"I have an image and want to find the sum of a part of it and then compared to a threshold. I have a rectangle drawn on the image and this is the area I need to apply the sum. -I know the cv2.integral function, but this gives me a matrix as a result. Do you have any suggestion?","sumElems function in OpenCV will help you to find out the sum of the pixels of the whole of the image in python. If you want to find only the sum of a particular portion of an image, you will have to select the ROI of the image on the sum is to be calculated. -As a side note, if you had found out the integral image, the very last pixel represents the sum of all the pixels of the image.",0.5457054096481145,False,2,3519 +I know the cv2.integral function, but this gives me a matrix as a result. Do you have any suggestion?","np.sum(img[y1:y2, x1:x2, c1:c2]) Where c1 and c2 are the channels.",0.9866142981514304,False,2,3519 2014-12-31 00:22:51.247,how to do the sum of pixels with Python and OpenCV,"I have an image and want to find the sum of a part of it and then compared to a threshold. I have a rectangle drawn on the image and this is the area I need to apply the sum. -I know the cv2.integral function, but this gives me a matrix as a result. Do you have any suggestion?","np.sum(img[y1:y2, x1:x2, c1:c2]) Where c1 and c2 are the channels.",0.9866142981514304,False,2,3519 +I know the cv2.integral function, but this gives me a matrix as a result. Do you have any suggestion?","sumElems function in OpenCV will help you to find out the sum of the pixels of the whole of the image in python. If you want to find only the sum of a particular portion of an image, you will have to select the ROI of the image on the sum is to be calculated. +As a side note, if you had found out the integral image, the very last pixel represents the sum of all the pixels of the image.",0.5457054096481145,False,2,3519 2014-12-31 05:50:25.153,Python: comparing list to a string,"I want to know how to compare a string to a list. For example I have string 'abcdab' and a list ['ab','bcd','da']. Is there any way to compare all possible list combinations to the string, and avoid overlaping elements. so that output will be a list of tuples like @@ -34765,7 +34765,7 @@ The directory '/Users/Parthenon/Library/Logs/pi' or its parent directory is not because I now have to install using sudo. I had python and a handful of libraries already installed on my Mac, I'm running Yosemite. I recently had to do a clean wipe and then reinstall of the OS. Now I'm getting this prompt and I'm having trouble figuring out how to change it Before my command line was Parthenon$ now it's Philips-MBP:~ Parthenon$ -I am the sole owner of this computer and this is the only account on it. This seems to be a problem when upgrading to python 3.4, nothing seems to be in the right place, virtualenv isn't going where I expect it to, etc.","If you altered your $PATH variable that could also cause the problem. If you think that might be the issue, check your ~/.bash_profile or ~/.bashrc",0.0,False,2,3530 +I am the sole owner of this computer and this is the only account on it. This seems to be a problem when upgrading to python 3.4, nothing seems to be in the right place, virtualenv isn't going where I expect it to, etc.",pip install --user (no sudo needed) worked for me for a very similar problem.,0.999999999949389,False,2,3530 2015-01-09 22:05:23.353,pip install: Please check the permissions and owner of that directory,"While installing pip and python I have ran into a that says: The directory '/Users/Parthenon/Library/Logs/pi' or its parent directory is not owned by the current user and the debug log has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want the -H flag. @@ -34773,7 +34773,7 @@ The directory '/Users/Parthenon/Library/Logs/pi' or its parent directory is not because I now have to install using sudo. I had python and a handful of libraries already installed on my Mac, I'm running Yosemite. I recently had to do a clean wipe and then reinstall of the OS. Now I'm getting this prompt and I'm having trouble figuring out how to change it Before my command line was Parthenon$ now it's Philips-MBP:~ Parthenon$ -I am the sole owner of this computer and this is the only account on it. This seems to be a problem when upgrading to python 3.4, nothing seems to be in the right place, virtualenv isn't going where I expect it to, etc.",pip install --user (no sudo needed) worked for me for a very similar problem.,0.999999999949389,False,2,3530 +I am the sole owner of this computer and this is the only account on it. This seems to be a problem when upgrading to python 3.4, nothing seems to be in the right place, virtualenv isn't going where I expect it to, etc.","If you altered your $PATH variable that could also cause the problem. If you think that might be the issue, check your ~/.bash_profile or ~/.bashrc",0.0,False,2,3530 2015-01-11 09:36:44.637,how to setup virtualenv to use a different python version in each virtual env,"using autoenv and virtualenvwrapper in python and trying to configure in it the specific python version. the autoenv file (called .env) contains (simply) echo 'my_env' @@ -34797,20 +34797,20 @@ A common convention is '\t' for tab and '\r' for CR, '\n' for newline.",1.2,True How I normally ran my programs was with the terminal like so: program.py -t input1 -t1 input2 I was wondering how can I debug this? +For other programs I wrote, I did not have any arguments so debugging was simply setting break points and pressing debug.","It was almost correct but just needed little correction with full script path. +Menu: Run->Edit configurations->""+"" (add new config)->Python. +Script name: path + /program.py +Script params: -t input1 -t1 input2",0.1352210990936997,False,2,3534 +2015-01-14 20:59:06.920,Debugging with PyCharm terminal arguments,"I have been using PyCharm for a bit so I am not an expert. +How I normally ran my programs was with the terminal like so: +program.py -t input1 -t1 input2 +I was wondering how can I debug this? For other programs I wrote, I did not have any arguments so debugging was simply setting break points and pressing debug.","Menu: Run -> Edit configurations -> ""+"" (add new config) -> Python. Script name: program.py If you need to debug a script from installed packages, such as tox, you can specify the full path too. For example: Script name: /home/your_user/.envs/env_name/bin/tox Above /home/your_user/.envs/env_name is a path to virtual environment containing tox package. Script params: -t input1 -t1 input2",1.2,True,2,3534 -2015-01-14 20:59:06.920,Debugging with PyCharm terminal arguments,"I have been using PyCharm for a bit so I am not an expert. -How I normally ran my programs was with the terminal like so: -program.py -t input1 -t1 input2 -I was wondering how can I debug this? -For other programs I wrote, I did not have any arguments so debugging was simply setting break points and pressing debug.","It was almost correct but just needed little correction with full script path. -Menu: Run->Edit configurations->""+"" (add new config)->Python. -Script name: path + /program.py -Script params: -t input1 -t1 input2",0.1352210990936997,False,2,3534 2015-01-15 01:51:12.603,Java/python using processBuilder,"Good evening all, am running a python script inside java using processBuilder. the python script returns a list and i dont know how to get it java and use it since all i can do for the moment with process builder is print errors or outputs. @@ -34852,12 +34852,12 @@ Also, the Gram matrix has shape (n_samples, n_samples) so it should also be too 2015-01-19 12:26:37.383,Django Navigation from Template-Login to a self written index.html,"Im using the Django template login and want to navigate from the login to my own written index.html file. so if a user push the ""login"" button the result page is my index file. My second question is how to use logos in django python and what structure i need in my project. -best regards","1: create your own view that the login button take the person to when clicked and load your index.html template. you do not have to use the built in login. -2: logo? you can use any logo/format you want. Django doesn't come with a template that creates the look of the site (beside the admin one); so you need to create it.",0.0,False,2,3541 +best regards","create custom log-in and registration in your project, and write the custom back-end if you have more user ,if request is came from user to log-in then redirect to index,html,",0.0,False,2,3541 2015-01-19 12:26:37.383,Django Navigation from Template-Login to a self written index.html,"Im using the Django template login and want to navigate from the login to my own written index.html file. so if a user push the ""login"" button the result page is my index file. My second question is how to use logos in django python and what structure i need in my project. -best regards","create custom log-in and registration in your project, and write the custom back-end if you have more user ,if request is came from user to log-in then redirect to index,html,",0.0,False,2,3541 +best regards","1: create your own view that the login button take the person to when clicked and load your index.html template. you do not have to use the built in login. +2: logo? you can use any logo/format you want. Django doesn't come with a template that creates the look of the site (beside the admin one); so you need to create it.",0.0,False,2,3541 2015-01-21 00:14:50.383,Trying to understand buffering in Python socket module,"I'm trying to learn how socket module works and I have a dumb question: Where is socket.send()'s sent data stored before being cleared by socket.recv()?. I believe there must be a buffer somewhere in the middle awaiting for socket.recv() calls to pull this data out. @@ -34985,6 +34985,13 @@ I have the following general surface: Ax^2 + By^2 + Cz^2 + Dxy + Gyz + Hzx + Ix + Jy + Kz + L = 0 I need to produce a model that can represent the parabola accurately using (I'm assuming) least squares fitting. I cannot seem to figure out how this works. I have though of rotating the parabola until its central axis lines up with z-axis but I do not know what this axis is. Matlab's cftool only seems to fit equations of the form z = f(x, y) and I am not aware of anything in python that can solve this. I also tried solving for the parameters numerically. When I tried making this into a matrix equation and solving by least squares, the matrix turned out to be invertible and hence my parameters were just all zero. I also am stuck on this and any help would be appreciated. I don't really mind the method as I am familiar with matlab, python and linear algebra if need be. +Thanks","Do you have enough data points to fit all 10 parameters - you will need at least 10? +I also suspect that 10 parameters are to many to describe a general paraboloid, meaning that some of the parameters are dependent. My fealing is that a translated and rotated paraboloid needs 7 parameters (although I'm not really sure)",0.0,False,2,3560 +2015-01-28 07:56:44.233,Rotated Paraboloid Surface Fitting,"I have a set of experimentally determined (x, y, z) points which correspond to a parabola. Unfortunately, the data is not aligned along any particular axis, and hence corresponds to a rotated parabola. +I have the following general surface: +Ax^2 + By^2 + Cz^2 + Dxy + Gyz + Hzx + Ix + Jy + Kz + L = 0 +I need to produce a model that can represent the parabola accurately using (I'm assuming) least squares fitting. I cannot seem to figure out how this works. I have though of rotating the parabola until its central axis lines up with z-axis but I do not know what this axis is. Matlab's cftool only seems to fit equations of the form z = f(x, y) and I am not aware of anything in python that can solve this. +I also tried solving for the parameters numerically. When I tried making this into a matrix equation and solving by least squares, the matrix turned out to be invertible and hence my parameters were just all zero. I also am stuck on this and any help would be appreciated. I don't really mind the method as I am familiar with matlab, python and linear algebra if need be. Thanks","Dont use any toolboxes, GUIs or special functions for this problem. Your problem is very common and the equation you provided may be solved in a very straight-forward manner. The solution to the linear least squares problem can be outlined as: The basis of the vector space is x^2, y^2, z^2, xy, yz, zx, x, y, z, 1. Therefore your vector has 10 dimensions. @@ -34996,13 +35003,6 @@ A = [x(1)^2 y(1)^2 ... y(1) z(1) 1 x(N)^2 y(N)^2 ... y(N) z(N) 1] Solve the overdetermined system of linear equations by computing p = A\b.",0.3869120172231254,False,2,3560 -2015-01-28 07:56:44.233,Rotated Paraboloid Surface Fitting,"I have a set of experimentally determined (x, y, z) points which correspond to a parabola. Unfortunately, the data is not aligned along any particular axis, and hence corresponds to a rotated parabola. -I have the following general surface: -Ax^2 + By^2 + Cz^2 + Dxy + Gyz + Hzx + Ix + Jy + Kz + L = 0 -I need to produce a model that can represent the parabola accurately using (I'm assuming) least squares fitting. I cannot seem to figure out how this works. I have though of rotating the parabola until its central axis lines up with z-axis but I do not know what this axis is. Matlab's cftool only seems to fit equations of the form z = f(x, y) and I am not aware of anything in python that can solve this. -I also tried solving for the parameters numerically. When I tried making this into a matrix equation and solving by least squares, the matrix turned out to be invertible and hence my parameters were just all zero. I also am stuck on this and any help would be appreciated. I don't really mind the method as I am familiar with matlab, python and linear algebra if need be. -Thanks","Do you have enough data points to fit all 10 parameters - you will need at least 10? -I also suspect that 10 parameters are to many to describe a general paraboloid, meaning that some of the parameters are dependent. My fealing is that a translated and rotated paraboloid needs 7 parameters (although I'm not really sure)",0.0,False,2,3560 2015-01-29 13:05:18.690,Run replace command on svn:externals (python),"I am currently writing a python script which needs to run a sed command to replace stuff from the svn:externals data. I tried to run sed on ""svn propedit svn:externals ."" but the outcome is not the one expected. Does anyone know how to do this ?","First of all, don't use sed. Use Python's string methods or the re module. @@ -35035,16 +35035,10 @@ It seems like I have to put the breakpoint there before I start the debugging (Ctrl+F5). Do you have a solution or maybe can you tell me how you debug Python scripts and functions? -I am using fresh install of Anaconda on a Windows 8.1 64bit.","(Spyder maintainer here) After our 4.2.0 version, released in November 2020, the debugging experience in Spyder is quite good. What we provide now is what people coming from Matlab would expect from a debugger, i.e. something that works like IPython and lets you inspect and plot variables at the current breakpoint or frame. -Now about your points: - -If there is a breakpoint present in the file you're trying to debug, then Spyder enters in debug mode and continues until the first breakpoint is met. If it's present in another file, then you still need to press first Debug and then Continue. - -IPdb is the IPython debugger console. In Spyder 4.2.0 or above it comes with code completion, syntax highlighting, history browsing of commands with the up/down arrows (separate from the IPython history), multi-line evaluation of code, and inline and interactive plots with Matplotlib. - -This is fixed now. Also, to avoid clashes between Python code and Pdb commands, if you have (for instance) a variable called n and write n in the prompt to see its value, we will show it instead of running the n Pdb command. To run that command instead, you have to prefix it with an exclamation mark, like this: !n - -This is fixed too. You can set breakpoints in IPdb and they will be taken into account in your current session.",1.2,True,4,3565 +I am using fresh install of Anaconda on a Windows 8.1 64bit.","You can use debug shortcut keys like: +Step Over F10 +Step Into F11 +in tools>preferences>keyboard shortcuts",0.0,False,4,3565 2015-02-02 14:48:09.337,How do I debug efficiently with Spyder in Python?,"I like Python and I like Spyder but I find debugging with Spyder terrible! Every time I put a break point, I need to press two buttons: first @@ -35058,8 +35052,13 @@ It seems like I have to put the breakpoint there before I start the debugging (Ctrl+F5). Do you have a solution or maybe can you tell me how you debug Python scripts and functions? -I am using fresh install of Anaconda on a Windows 8.1 64bit.","One minor extra regarding point 3: -It also seemed to me the debug console frequently froze, doing prints, evaluating, etc, but pressing the stop (Exit debug) button usually got it back to the bottom of the call stack and then I could go back up ('u') to the frame I was debugging in. Worth a try. This might be for a later version of Spyder (2.3.5.2)",0.0,False,4,3565 +I am using fresh install of Anaconda on a Windows 8.1 64bit.","Here is how I debug in Spyder in order to avoid freezing the IDE. I do this if I alter the script while in debugging mode. + +I close out the current IPython (debugging) console [x] +Open a new one [Menu bar-> Consoles-> Open an IPython Console] +Enter debug mode again [blue play pause button]. + +Still a bit annoying, but it has the added benefit of clearing (resetting) variable list.",0.0582430451621389,False,4,3565 2015-02-02 14:48:09.337,How do I debug efficiently with Spyder in Python?,"I like Python and I like Spyder but I find debugging with Spyder terrible! Every time I put a break point, I need to press two buttons: first @@ -35073,13 +35072,8 @@ It seems like I have to put the breakpoint there before I start the debugging (Ctrl+F5). Do you have a solution or maybe can you tell me how you debug Python scripts and functions? -I am using fresh install of Anaconda on a Windows 8.1 64bit.","Here is how I debug in Spyder in order to avoid freezing the IDE. I do this if I alter the script while in debugging mode. - -I close out the current IPython (debugging) console [x] -Open a new one [Menu bar-> Consoles-> Open an IPython Console] -Enter debug mode again [blue play pause button]. - -Still a bit annoying, but it has the added benefit of clearing (resetting) variable list.",0.0582430451621389,False,4,3565 +I am using fresh install of Anaconda on a Windows 8.1 64bit.","One minor extra regarding point 3: +It also seemed to me the debug console frequently froze, doing prints, evaluating, etc, but pressing the stop (Exit debug) button usually got it back to the bottom of the call stack and then I could go back up ('u') to the frame I was debugging in. Worth a try. This might be for a later version of Spyder (2.3.5.2)",0.0,False,4,3565 2015-02-02 14:48:09.337,How do I debug efficiently with Spyder in Python?,"I like Python and I like Spyder but I find debugging with Spyder terrible! Every time I put a break point, I need to press two buttons: first @@ -35093,10 +35087,16 @@ It seems like I have to put the breakpoint there before I start the debugging (Ctrl+F5). Do you have a solution or maybe can you tell me how you debug Python scripts and functions? -I am using fresh install of Anaconda on a Windows 8.1 64bit.","You can use debug shortcut keys like: -Step Over F10 -Step Into F11 -in tools>preferences>keyboard shortcuts",0.0,False,4,3565 +I am using fresh install of Anaconda on a Windows 8.1 64bit.","(Spyder maintainer here) After our 4.2.0 version, released in November 2020, the debugging experience in Spyder is quite good. What we provide now is what people coming from Matlab would expect from a debugger, i.e. something that works like IPython and lets you inspect and plot variables at the current breakpoint or frame. +Now about your points: + +If there is a breakpoint present in the file you're trying to debug, then Spyder enters in debug mode and continues until the first breakpoint is met. If it's present in another file, then you still need to press first Debug and then Continue. + +IPdb is the IPython debugger console. In Spyder 4.2.0 or above it comes with code completion, syntax highlighting, history browsing of commands with the up/down arrows (separate from the IPython history), multi-line evaluation of code, and inline and interactive plots with Matplotlib. + +This is fixed now. Also, to avoid clashes between Python code and Pdb commands, if you have (for instance) a variable called n and write n in the prompt to see its value, we will show it instead of running the n Pdb command. To run that command instead, you have to prefix it with an exclamation mark, like this: !n + +This is fixed too. You can set breakpoints in IPdb and they will be taken into account in your current session.",1.2,True,4,3565 2015-02-03 20:38:58.087,Python what is the best way to handle multiple threads,"Since my scaper is running so slow (one page at a time) so I'm trying to use thread to make it work faster. I have a function scrape(website) that take in a website to scrape, so easily I can create each thread and call start() on each of them. Now I want to implement a num_threads variable that is the number of threads that I want to run at the same time. What is the best way to handle those multiple threads? For ex: supposed num_threads = 5 , my goal is to start 5 threads then grab the first 5 website in the list and scrape them, then if thread #3 finishes, it will grab the 6th website from the list to scrape immidiately, not wait until other threads end. @@ -35134,6 +35134,12 @@ You should not try to prevent Apache from serving multiple processes. If you do, Instead, you should fix your AppConfig. Rather than blindly spawning a listener, you should check to see if it has already been created before starting a new one.",0.3869120172231254,False,2,3568 2015-02-04 17:36:50.273,Running Python 3 from Light Table,"I am trying Light Table and learning how to use it. Overall, I like it, but I noticed that the only means of making the watches and inline evaluation work in Python programs uses Python 2.7.8, making it incompatible with some of my code. Is there a way to make it use Python 3 instead? I looked on Google and GitHub and I couldn't find anything promising. +I am using a Mac with OS X 10.10.2. I have an installation of Python 3.4.0 that runs fine from the Terminal.",I got the same problem. It worked for me after saving the file with a .py extension and then typing Cmd+Enter.,0.0,False,3,3569 +2015-02-04 17:36:50.273,Running Python 3 from Light Table,"I am trying Light Table and learning how to use it. Overall, I like it, but I noticed that the only means of making the watches and inline evaluation work in Python programs uses Python 2.7.8, making it incompatible with some of my code. Is there a way to make it use Python 3 instead? +I looked on Google and GitHub and I couldn't find anything promising. +I am using a Mac with OS X 10.10.2. I have an installation of Python 3.4.0 that runs fine from the Terminal.",Hit Ctrl + Space to bring up the control pane. Then start typing Set Syntax and select Set Syntax to Python. Start typing your Python then press Ctrl + Shift + Enter to build and run the program.,0.0,False,3,3569 +2015-02-04 17:36:50.273,Running Python 3 from Light Table,"I am trying Light Table and learning how to use it. Overall, I like it, but I noticed that the only means of making the watches and inline evaluation work in Python programs uses Python 2.7.8, making it incompatible with some of my code. Is there a way to make it use Python 3 instead? +I looked on Google and GitHub and I couldn't find anything promising. I am using a Mac with OS X 10.10.2. I have an installation of Python 3.4.0 that runs fine from the Terminal.","I had the same problem with using a syntax that was only valid on Python3.3. - Go to Settings:User Behaviour - add the line (find the real path of your python binary): @@ -35141,12 +35147,6 @@ I am using a Mac with OS X 10.10.2. I have an installation of Python 3.4.0 that - Save and test in your lighttable It worked for me :) Hope it helps",1.2,True,3,3569 -2015-02-04 17:36:50.273,Running Python 3 from Light Table,"I am trying Light Table and learning how to use it. Overall, I like it, but I noticed that the only means of making the watches and inline evaluation work in Python programs uses Python 2.7.8, making it incompatible with some of my code. Is there a way to make it use Python 3 instead? -I looked on Google and GitHub and I couldn't find anything promising. -I am using a Mac with OS X 10.10.2. I have an installation of Python 3.4.0 that runs fine from the Terminal.",Hit Ctrl + Space to bring up the control pane. Then start typing Set Syntax and select Set Syntax to Python. Start typing your Python then press Ctrl + Shift + Enter to build and run the program.,0.0,False,3,3569 -2015-02-04 17:36:50.273,Running Python 3 from Light Table,"I am trying Light Table and learning how to use it. Overall, I like it, but I noticed that the only means of making the watches and inline evaluation work in Python programs uses Python 2.7.8, making it incompatible with some of my code. Is there a way to make it use Python 3 instead? -I looked on Google and GitHub and I couldn't find anything promising. -I am using a Mac with OS X 10.10.2. I have an installation of Python 3.4.0 that runs fine from the Terminal.",I got the same problem. It worked for me after saving the file with a .py extension and then typing Cmd+Enter.,0.0,False,3,3569 2015-02-05 09:21:04.480,How to install python weka wrapper on ubuntu 32 bit?,The official website shows how weka-wrapper can install on ubuntu 64 bit. I want toknowhow it can be install on ubuntu 32 bit?,"Before installing weka wrapper for python you are suppose to install the weka itself using sudo apt-get install weka or build from source code and add the path the enviroment variable using export wekahome=""your weka path"" this will make sure you have the required weka jar file in the directory",0.0,False,1,3570 2015-02-07 16:26:18.777,Create a numpy array (10x1) with zeros and fives,I'm having trouble figuring out how to create a 10x1 numpy array with the number 5 in the first 3 elements and the other 7 elements with the number 0. Any thoughts on how to do this efficiently?,"Just do the following. import numpy as np @@ -35186,7 +35186,7 @@ Exception: File ""/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py"", line 157, in makedirs mkdir(name, mode) OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/django' -Obviously my path is pointing to the old version of Python that came preinstalled on my computer, but I don't know how to run the pip on the new version of Python. I am also worried that if I change my file path, it will mess up other programs on my computer. Is there a way to point to version 3.4 without changing the file path? If not how do I update my file path to 3.4?",Try adding sudo. sudo pip install Django,0.0,False,2,3574 +Obviously my path is pointing to the old version of Python that came preinstalled on my computer, but I don't know how to run the pip on the new version of Python. I am also worried that if I change my file path, it will mess up other programs on my computer. Is there a way to point to version 3.4 without changing the file path? If not how do I update my file path to 3.4?","Try to create a virtual environment. This can be achieved by using python modules like venv or virtualenv. There you can change your python path without affecting any other programs on your machine. If then the error is is still that you do not have permission to read files, try sudo pip install. But only as a last resort since pip recommends not using it as root.",0.0,False,2,3574 2015-02-10 01:19:45.890,Mac OSX Trouble Running pip commands,"I recently installed Python 3.4 on my Mac and now want to install Django using pip. I tried running pip install Django==1.7.4 from the command line and received the following error: Exception: Traceback (most recent call last): @@ -35207,7 +35207,7 @@ Exception: File ""/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py"", line 157, in makedirs mkdir(name, mode) OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/django' -Obviously my path is pointing to the old version of Python that came preinstalled on my computer, but I don't know how to run the pip on the new version of Python. I am also worried that if I change my file path, it will mess up other programs on my computer. Is there a way to point to version 3.4 without changing the file path? If not how do I update my file path to 3.4?","Try to create a virtual environment. This can be achieved by using python modules like venv or virtualenv. There you can change your python path without affecting any other programs on your machine. If then the error is is still that you do not have permission to read files, try sudo pip install. But only as a last resort since pip recommends not using it as root.",0.0,False,2,3574 +Obviously my path is pointing to the old version of Python that came preinstalled on my computer, but I don't know how to run the pip on the new version of Python. I am also worried that if I change my file path, it will mess up other programs on my computer. Is there a way to point to version 3.4 without changing the file path? If not how do I update my file path to 3.4?",Try adding sudo. sudo pip install Django,0.0,False,2,3574 2015-02-11 00:08:18.797,numpy.loadtxt: how to ignore comma delimiters that appear inside quotes?,"I have a csv file where a line of data might look like this: 10,""Apple, Banana"",20,... When I load the data in Python, the extra comma inside the quotes shifts all my column indices around, so my data is no longer a consistent structure. While I could probably write a complex algorithm that iterates through each row and fixes the issue, I was hoping there was an elegant way to just pass an extra parameter to loadtxt (or some other function) that will properly ignore commas inside quotes and treat the entire quote as one value. @@ -35345,12 +35345,12 @@ If you want to run only your application in fullscreen mode use the ~/.xinitrc t ~Jimnebob","It seems like Beep function couldn't play several notes at the same time. You can record the sound of 'Beep' through sounddevice library, save the sound in wav files. Then, use subprocess.Popen to achieve multiprocess. The subprocess would play the wav files.",0.0,False,1,3594 2015-02-27 12:42:35.740,How to fetch data from a website using Python that is being populated by Javascript?,"I want to fetch few data/values from a website. I have used beautifulsoup for this and the fields are blank when I try to fetch them from my Python script, whereas when I am inspecting elements of the webpage I can clearly see the values are available in the table row data. When i saw the HTML Source I noticed its blank there too. +I came up with a reason, the website is using Javascript to populate the values in their corresponding fields from its own database. If so then how can i fetch them using Python?",The Python binding for Selenium and phantomjs (if you want to use a headless browser as backend) are the appropriate tools for this job.,0.2012947653214861,False,2,3595 +2015-02-27 12:42:35.740,How to fetch data from a website using Python that is being populated by Javascript?,"I want to fetch few data/values from a website. I have used beautifulsoup for this and the fields are blank when I try to fetch them from my Python script, whereas when I am inspecting elements of the webpage I can clearly see the values are available in the table row data. +When i saw the HTML Source I noticed its blank there too. I came up with a reason, the website is using Javascript to populate the values in their corresponding fields from its own database. If so then how can i fetch them using Python?","Yes, you can scrape JS data, it just takes a bit more hacking. Anything a browser can do, python can do. If you're using firebug, look at the network tab to see from which particular request your data is coming from. In chrome element inspection, you can find this information in a tab named network, too. Just hit ctrl-F to search the response content of the requests. If you found the right request, the data might be embedded in JS code, in which case you'll have some regex parsing to do. If you're lucky, the format is xml or json, in which case you can just use the associated builtin parser.",0.0,False,2,3595 -2015-02-27 12:42:35.740,How to fetch data from a website using Python that is being populated by Javascript?,"I want to fetch few data/values from a website. I have used beautifulsoup for this and the fields are blank when I try to fetch them from my Python script, whereas when I am inspecting elements of the webpage I can clearly see the values are available in the table row data. -When i saw the HTML Source I noticed its blank there too. -I came up with a reason, the website is using Javascript to populate the values in their corresponding fields from its own database. If so then how can i fetch them using Python?",The Python binding for Selenium and phantomjs (if you want to use a headless browser as backend) are the appropriate tools for this job.,0.2012947653214861,False,2,3595 2015-02-28 21:09:22.660,How to make a webpage display dynamic data in real time using Python?,"I am working on making a GUI front end for a Python program using HTML and CSS (sort of similar to how a router is configured using a web browser). The program assigns values given by the user to variables and performs calculations with those variables, outputting the results. I have a few snags to work out: How do I design the application so that the data is constantly updated, in real-time? I.e. the user does not need to hit a ""calculate"" button nor refresh the page to get the results. If the user changes the value in a field, all other are fields simultaneously updated, et cetera. @@ -35518,10 +35518,10 @@ After some reading I found that scipy.sparse module has a nice collection of var Can you provide an example of how to convert the dictionary above to correct matrix type?","With standard dict methods you can get a list of the keys, and another list of the values. Pass the 2nd to numpy.array and you should get a 100 x 7000 array. The keys list could also be made into array, but it might not be any more useful than the list. The values array could be turned into a sparse matrix. But its size isn't exceptional, and arrays have more methods. Tomorrow I can add sample code if needed.",1.2,True,1,3617 2015-03-12 20:15:29.760,Accidentally deleted a folder's contents in iPython/Jupyter and I can recover it from trash on Mac OSX Yosemite. Is there anyway I can get it back?,"Just installed iPython/Jupyter and accidentally deleted pictures from a file that was living on my desktop. I don't know how to undo what I just deleted and can't seem to find any of the pictures in my trash. Is there anyway I can recover them? My instance of iPython/Jupyter is still open. -Thanks.","No, you can't easily recover the files. The files are gone. Your option is to restore from a backup, or use a data recovery tool of some sort.",0.2012947653214861,False,2,3618 -2015-03-12 20:15:29.760,Accidentally deleted a folder's contents in iPython/Jupyter and I can recover it from trash on Mac OSX Yosemite. Is there anyway I can get it back?,"Just installed iPython/Jupyter and accidentally deleted pictures from a file that was living on my desktop. I don't know how to undo what I just deleted and can't seem to find any of the pictures in my trash. Is there anyway I can recover them? My instance of iPython/Jupyter is still open. Thanks.","Check in the hidden directory "".ipynb_checkpoints"" inside of the directory that used to hold the notebook. If you had recently been running the notebook prior to deleting it, you may be able to find a recent copy of it saved at the last ""checkpoint"".",0.0,False,2,3618 +2015-03-12 20:15:29.760,Accidentally deleted a folder's contents in iPython/Jupyter and I can recover it from trash on Mac OSX Yosemite. Is there anyway I can get it back?,"Just installed iPython/Jupyter and accidentally deleted pictures from a file that was living on my desktop. I don't know how to undo what I just deleted and can't seem to find any of the pictures in my trash. Is there anyway I can recover them? My instance of iPython/Jupyter is still open. +Thanks.","No, you can't easily recover the files. The files are gone. Your option is to restore from a backup, or use a data recovery tool of some sort.",0.2012947653214861,False,2,3618 2015-03-13 20:40:03.103,"Associate file extension to python script, so that I can open the file by double click, in windows","I want to do the following: Save numeric data in a CSV-like formatting, with a "".foo"" extension; @@ -35746,18 +35746,18 @@ For example, 2004 begins on a Thursday, so the first week of ISO year 2004 begin 2015-03-26 16:48:45.493,How to install in python 3.4 - .whl files,"I recently tried to re-install numpy for python 3.4, since I got a new computer, and am struggling. I am on windows 8.1, and from what I remember I previously used a .exe file that did everything for me. However, this time I was given a .whl file (apparently this is a ""Wheel"" file), which I cannot figure out how to install. Other posts have explained that I have to use PIP, however the explanations of how to install these files that I have been able to find are dreadful. The command ""python install pip"" or ""pip install numpy"" or all the other various commands I have seen only return an error that ""python is not recognized as an internal or external command, operable program or batch file"", or ""pip is not recognised as an internal...."" ect. I have also tried ""python3.4"", ""python.exe"" and many others since it does not like python. The file name of the numpy file that I downloaded is ""numpy-1.9.2+mkl-cp34-none-win_amd64.whl"". -So can anybody give me a Detailed tutorial of how to use these, as by the looks of things all modules are using these now. Also, why did people stop using .exe files to install these? It was so much easier!","Python 3.4 comes with PIP already included in the package, so you should be able to start using PIP immediately after installing Python 3.4. Commands like pip install only work if the path to PIP is included in your path environment variable. If it's not, and you'd rather not edit your environment variables, you need to provide the full path. The default location for PIP in Python 3.4 is in C:\Python34\Scripts\pip3.4.exe. If that file exists there (it should), enter the command C:\Python34\Scripts\pip3.4.exe install , where is the full path to your numpy .whl file. For example: C:\Python34\Scripts\pip3.4.exe install C:\Users\mwinfield\Downloads\numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl.",1.2,True,2,3644 +So can anybody give me a Detailed tutorial of how to use these, as by the looks of things all modules are using these now. Also, why did people stop using .exe files to install these? It was so much easier!",See the easiest solution is to unzip the .whl file using 7-zip. Then in the unzipped directory you will find the module which you can copy and paste in the directory C:/Python34/Lib/site-packages/ (or wherever else you have installed Python).,0.999329299739067,False,2,3644 2015-03-26 16:48:45.493,How to install in python 3.4 - .whl files,"I recently tried to re-install numpy for python 3.4, since I got a new computer, and am struggling. I am on windows 8.1, and from what I remember I previously used a .exe file that did everything for me. However, this time I was given a .whl file (apparently this is a ""Wheel"" file), which I cannot figure out how to install. Other posts have explained that I have to use PIP, however the explanations of how to install these files that I have been able to find are dreadful. The command ""python install pip"" or ""pip install numpy"" or all the other various commands I have seen only return an error that ""python is not recognized as an internal or external command, operable program or batch file"", or ""pip is not recognised as an internal...."" ect. I have also tried ""python3.4"", ""python.exe"" and many others since it does not like python. The file name of the numpy file that I downloaded is ""numpy-1.9.2+mkl-cp34-none-win_amd64.whl"". -So can anybody give me a Detailed tutorial of how to use these, as by the looks of things all modules are using these now. Also, why did people stop using .exe files to install these? It was so much easier!",See the easiest solution is to unzip the .whl file using 7-zip. Then in the unzipped directory you will find the module which you can copy and paste in the directory C:/Python34/Lib/site-packages/ (or wherever else you have installed Python).,0.999329299739067,False,2,3644 +So can anybody give me a Detailed tutorial of how to use these, as by the looks of things all modules are using these now. Also, why did people stop using .exe files to install these? It was so much easier!","Python 3.4 comes with PIP already included in the package, so you should be able to start using PIP immediately after installing Python 3.4. Commands like pip install only work if the path to PIP is included in your path environment variable. If it's not, and you'd rather not edit your environment variables, you need to provide the full path. The default location for PIP in Python 3.4 is in C:\Python34\Scripts\pip3.4.exe. If that file exists there (it should), enter the command C:\Python34\Scripts\pip3.4.exe install , where is the full path to your numpy .whl file. For example: C:\Python34\Scripts\pip3.4.exe install C:\Users\mwinfield\Downloads\numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl.",1.2,True,2,3644 2015-03-26 22:57:04.797,A focus point on the raspberry pi camera,"I just got my raspberry pi yesterday and have gone through all the setup and update steps required to enable the camera extension (which took me like 6 hrs; yes, I am a newbie). I need to create a focus point on the camera's output and use the arrow keys to move this point around the screen. -My question is how to access the pixel addresses in order to achieve this (if that is even how to do it). Please can one of you gurus out there point me in the right direction.","You do realise that the Pi Camera board has a fixed focus at 1m to infinity ? -& If you want focus <1m you're gonna have to manually twist the lens, after removing the glue that fixates it in the housing.",0.0,False,2,3645 +My question is how to access the pixel addresses in order to achieve this (if that is even how to do it). Please can one of you gurus out there point me in the right direction.",If you need to take close-ups or if you are capturing image very close to camera lens then you need to manually set the focus.,0.0,False,2,3645 2015-03-26 22:57:04.797,A focus point on the raspberry pi camera,"I just got my raspberry pi yesterday and have gone through all the setup and update steps required to enable the camera extension (which took me like 6 hrs; yes, I am a newbie). I need to create a focus point on the camera's output and use the arrow keys to move this point around the screen. -My question is how to access the pixel addresses in order to achieve this (if that is even how to do it). Please can one of you gurus out there point me in the right direction.",If you need to take close-ups or if you are capturing image very close to camera lens then you need to manually set the focus.,0.0,False,2,3645 +My question is how to access the pixel addresses in order to achieve this (if that is even how to do it). Please can one of you gurus out there point me in the right direction.","You do realise that the Pi Camera board has a fixed focus at 1m to infinity ? +& If you want focus <1m you're gonna have to manually twist the lens, after removing the glue that fixates it in the housing.",0.0,False,2,3645 2015-03-27 10:14:59.570,how to use a library that's compiled for python 2.7 in python 2.4,"I want to use a library which is available from python 2.7 onwards on a system with python 2.4. I cannot upgrade the system to python 2.7, as many other libraries and softwares are written in python 2.4. For instance, i want to use the xml.eTree library in python 2.4. Can i take the source code of that library and do few changes and compile it on 2.4 ? If yes, could you please tell how to proceed?","You don't need to upgrade the system Python. Install your own local version of 2.7 into your home directory, create a virtualenv using that version, and install your libraries there.",0.0,False,1,3646 @@ -35766,74 +35766,74 @@ Unfortunately my computer has strong firewall restrictions and I am not able to Is there a way to install the package manually? I use win 7 64 by the way Many thanks!!!","If you are using conda, use the --offline flag when installing the conda package that you downloaded, like conda install --offline pandas-0.15.2-np19py27.tar.bz2.",1.2,True,1,3647 2015-03-28 12:24:45.223,What is the structure of a vim .swp file?,"An application wants to shell text out to vim and know what edits are being made, in real time. -The .swp file provides this information. Can anyone provide guidance on how to read this binary file, say, with Python?","I wouldn't rely on the swapfile contents to get real-time updates. Its format is geared towards Vim's uses, and its format isn't documented other than by its implementation. You would have to duplicate large parts of the algorithm, and maintain that whenever the internal format changes (without prior notice). -Alternatively, I would use one of the embedded languages (e.g. Python) to interface with the outside program that wants to get real-time updates. A Python function could periodically send along the entire buffer contents on a socket, for example.",0.1352210990936997,False,2,3648 -2015-03-28 12:24:45.223,What is the structure of a vim .swp file?,"An application wants to shell text out to vim and know what edits are being made, in real time. The .swp file provides this information. Can anyone provide guidance on how to read this binary file, say, with Python?","Thanks everyone who replied. I hoped .swp would be documented, maybe even code available to access it, seems not. The suggestion to write a plugin in Python probably makes the most sense, I bet it's possible to hook to something like 'on_keystroke' and maintain a mirror I can understand. 'shell out' as in 'write this chunk of text to a temp file, open that file in vim, when vim exits, write the temp file contents to a replacement chunk of text' PS: $100 is way too much to shell out for those tickets",0.0,False,2,3648 +2015-03-28 12:24:45.223,What is the structure of a vim .swp file?,"An application wants to shell text out to vim and know what edits are being made, in real time. +The .swp file provides this information. Can anyone provide guidance on how to read this binary file, say, with Python?","I wouldn't rely on the swapfile contents to get real-time updates. Its format is geared towards Vim's uses, and its format isn't documented other than by its implementation. You would have to duplicate large parts of the algorithm, and maintain that whenever the internal format changes (without prior notice). +Alternatively, I would use one of the embedded languages (e.g. Python) to interface with the outside program that wants to get real-time updates. A Python function could periodically send along the entire buffer contents on a socket, for example.",0.1352210990936997,False,2,3648 2015-03-28 16:27:34.090,How do I suppress the console window when debugging python code in Python Tools for Visual Studio (PTVS)?,"In PTVS the default behavior is for the program to print to the Python console window and the Visual Studio Debug Output window. Realizing that it won't be able to accept user input, how do I suppress the Python console window?",Use the Python Interactive Window (CTRL-ALT-F8 or Debug Menu). You will have the code output on the python interactive shell (where you can obviously interact). The win terminal will not appear anymore.,0.0,False,1,3649 2015-03-30 03:25:11.703,How to remove anaconda from windows completely?,"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7. I removed Anaconda and deleted all the directories and installed python 2.7. -But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","there is a start item folder in C:\ drive. Remove ur anaconda3 folder there, simple and you are good to go. In my case I found here ""C:\Users\pravu\AppData\Roaming\Microsoft\Windows\Start Menu\Programs""",0.0872412088103126,False,13,3650 +But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","It looks that some files are still left and some registry keys are left. So you can run revocleaner tool to remove those entries as well. Do a reboot and install again it should be doing it now. +I also faced issue and by complete cleaning I got Rid of it.",0.0872412088103126,False,13,3650 2015-03-30 03:25:11.703,How to remove anaconda from windows completely?,"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7. I removed Anaconda and deleted all the directories and installed python 2.7. -But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","For windows- - -In the Control Panel, choose Add or Remove Programs or Uninstall a program, and then select Python 3.6 (Anaconda) or your version of Python. -Use Windows Explorer to delete the envs and pkgs folders prior to Running the uninstall in the root of your installation.",0.0872412088103126,False,13,3650 +But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?",Since I didn't have the uninstaller listed - the solution turned out to be to reinstall Anaconda and then uninstall it.,1.2,True,13,3650 2015-03-30 03:25:11.703,How to remove anaconda from windows completely?,"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7. I removed Anaconda and deleted all the directories and installed python 2.7. -But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","Uninstall Anaconda from control Panel -Delete related folders, cache data and configurations from Users/user -Delete from AppData folder from hidden list -To remove start menu entry -> Go to C:/ProgramsData/Microsoft/Windows/ and delete Anaconda folder or search for anaconda in start menu and right click on anaconda prompt -> Show in Folder option. -This will do almost cleaning of every anaconda file on your system.",0.0291462614471899,False,13,3650 +But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","If a clean re-install/uninstall did not work, this is because the Anaconda install is still listed in the registry. + +Start -> Run -> Regedit +Navigate to HKEY_CURRENT_USER -> Software -> Python +You may see 2 subfolders, Anaconda and PythonCore. Expand both and check the ""Install Location"" in the Install folder, it will be listed on the right. +Delete either or both Anaconda and PythonCore folders, or the entire Python folder and the Registry path to install your Python Package to Anaconda will be gone.",0.4813818266442933,False,13,3650 2015-03-30 03:25:11.703,How to remove anaconda from windows completely?,"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7. I removed Anaconda and deleted all the directories and installed python 2.7. -But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","Method1: -To uninstall Anaconda3 go to the Anaconda3 folder, there u will be able to find an executable called Uninstall-Anaconda3.exe, double click on it. This should uninstall ur application. -There are times when the shortcut of anaconda command prompt,jupyter notebook, spyder, etc exists, so delete those files too. -Method2 (Windows8): -Go to control panel->Programs->Uninstall a Program and then select Anaconda3(Python3.1. 64-bit)in the menu.",0.1160922760327606,False,13,3650 +But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","In the folder where you installed Anaconda (Example: C:\Users\username\Anaconda3) there should be an executable called Uninstall-Anaconda.exe. Double click on this file to start uninstall Anaconda. +That should do the trick as well.",0.9999999999923213,False,13,3650 2015-03-30 03:25:11.703,How to remove anaconda from windows completely?,"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7. I removed Anaconda and deleted all the directories and installed python 2.7. -But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","On my machine (Win10), the uninstaller was located at C:\ProgramData\Anaconda3\Uninstall-Anaconda3.exe.",0.0872412088103126,False,13,3650 +But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?",To use Uninstall-Anaconda.exe in C:\Users\username\Anaconda3 is a good way.,0.2012947653214861,False,13,3650 2015-03-30 03:25:11.703,How to remove anaconda from windows completely?,"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7. I removed Anaconda and deleted all the directories and installed python 2.7. -But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?",Go to C:\Users\username\Anaconda3 and search for Uninstall-Anaconda3.exe which will remove all the components of Anaconda.,0.0291462614471899,False,13,3650 +But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","In my computer there wasn't a uninstaller in the Start Menu as well. But it worked it the Control Panel > Programs > Uninstall a Program, and selecting Python(Anaconda64bits) in the menu. +(Note that I'm using Win10)",0.5034642428123463,False,13,3650 2015-03-30 03:25:11.703,How to remove anaconda from windows completely?,"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7. I removed Anaconda and deleted all the directories and installed python 2.7. -But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","Anaconda comes with an uninstaller, which should have been installed in the Start menu.",0.229096917477335,False,13,3650 +But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","there is a start item folder in C:\ drive. Remove ur anaconda3 folder there, simple and you are good to go. In my case I found here ""C:\Users\pravu\AppData\Roaming\Microsoft\Windows\Start Menu\Programs""",0.0872412088103126,False,13,3650 2015-03-30 03:25:11.703,How to remove anaconda from windows completely?,"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7. I removed Anaconda and deleted all the directories and installed python 2.7. -But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?",To use Uninstall-Anaconda.exe in C:\Users\username\Anaconda3 is a good way.,0.2012947653214861,False,13,3650 +But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?",Go to C:\Users\username\Anaconda3 and search for Uninstall-Anaconda3.exe which will remove all the components of Anaconda.,0.0291462614471899,False,13,3650 2015-03-30 03:25:11.703,How to remove anaconda from windows completely?,"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7. I removed Anaconda and deleted all the directories and installed python 2.7. -But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","If a clean re-install/uninstall did not work, this is because the Anaconda install is still listed in the registry. +But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","For windows- -Start -> Run -> Regedit -Navigate to HKEY_CURRENT_USER -> Software -> Python -You may see 2 subfolders, Anaconda and PythonCore. Expand both and check the ""Install Location"" in the Install folder, it will be listed on the right. -Delete either or both Anaconda and PythonCore folders, or the entire Python folder and the Registry path to install your Python Package to Anaconda will be gone.",0.4813818266442933,False,13,3650 +In the Control Panel, choose Add or Remove Programs or Uninstall a program, and then select Python 3.6 (Anaconda) or your version of Python. +Use Windows Explorer to delete the envs and pkgs folders prior to Running the uninstall in the root of your installation.",0.0872412088103126,False,13,3650 2015-03-30 03:25:11.703,How to remove anaconda from windows completely?,"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7. I removed Anaconda and deleted all the directories and installed python 2.7. -But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","In the folder where you installed Anaconda (Example: C:\Users\username\Anaconda3) there should be an executable called Uninstall-Anaconda.exe. Double click on this file to start uninstall Anaconda. -That should do the trick as well.",0.9999999999923213,False,13,3650 +But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","Anaconda comes with an uninstaller, which should have been installed in the Start menu.",0.229096917477335,False,13,3650 2015-03-30 03:25:11.703,How to remove anaconda from windows completely?,"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7. I removed Anaconda and deleted all the directories and installed python 2.7. -But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","In my computer there wasn't a uninstaller in the Start Menu as well. But it worked it the Control Panel > Programs > Uninstall a Program, and selecting Python(Anaconda64bits) in the menu. -(Note that I'm using Win10)",0.5034642428123463,False,13,3650 +But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","Method1: +To uninstall Anaconda3 go to the Anaconda3 folder, there u will be able to find an executable called Uninstall-Anaconda3.exe, double click on it. This should uninstall ur application. +There are times when the shortcut of anaconda command prompt,jupyter notebook, spyder, etc exists, so delete those files too. +Method2 (Windows8): +Go to control panel->Programs->Uninstall a Program and then select Anaconda3(Python3.1. 64-bit)in the menu.",0.1160922760327606,False,13,3650 2015-03-30 03:25:11.703,How to remove anaconda from windows completely?,"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7. I removed Anaconda and deleted all the directories and installed python 2.7. -But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?",Since I didn't have the uninstaller listed - the solution turned out to be to reinstall Anaconda and then uninstall it.,1.2,True,13,3650 +But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","On my machine (Win10), the uninstaller was located at C:\ProgramData\Anaconda3\Uninstall-Anaconda3.exe.",0.0872412088103126,False,13,3650 2015-03-30 03:25:11.703,How to remove anaconda from windows completely?,"I installed Anaconda a while ago but recently decided to uninstall it and just install basic python 2.7. I removed Anaconda and deleted all the directories and installed python 2.7. -But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","It looks that some files are still left and some registry keys are left. So you can run revocleaner tool to remove those entries as well. Do a reboot and install again it should be doing it now. -I also faced issue and by complete cleaning I got Rid of it.",0.0872412088103126,False,13,3650 +But when I go to install PyGTK for Windows it says it will install it to the c:/users/.../Anaconda directory - this doesn't even exist. I want to install it to the c:/python-2.7 directory. Why does it think Anaconda is still installed? And how can I change this?","Uninstall Anaconda from control Panel +Delete related folders, cache data and configurations from Users/user +Delete from AppData folder from hidden list +To remove start menu entry -> Go to C:/ProgramsData/Microsoft/Windows/ and delete Anaconda folder or search for anaconda in start menu and right click on anaconda prompt -> Show in Folder option. +This will do almost cleaning of every anaconda file on your system.",0.0291462614471899,False,13,3650 2015-03-30 08:38:26.157,How to use external Auth system in Pyramid,"Context My app relies on external service for authentication, python API has function authentiate_request witch takes request instance as a param, and returns result dict: @@ -35971,9 +35971,6 @@ I use PyQt4","I see that this thread is kinda old. But I hope this will still he You can use the remove() method to ""hide"" the tab. There's no way to really hide them in pyqt4. when you remove it, it's gone from the ui. But in the back end, the tab object with all your settings still exist. I'm sure you can find a way to improvise it back. Give it a try!",0.0,False,1,3668 2015-04-11 23:33:45.970,How do you make a Python executable file on Mac?,"My google searching has failed me. I'd like to know how to make an executable Python file on OS X, that is, how to go about making an .exe file that can launch a Python script with a double click (not from the shell). For that matter I'd assume the solution for this would be similar between different scripting languages, is this the case?","You can run python scripts through OS X Terminal. You just have to write a python script with an editor, open your Terminal and enter python path_to_my_script/my_script.py",0.2012947653214861,False,1,3669 2015-04-12 01:10:46.060,I don't know how to update my Python version to 3.4?,"I'm on OSX, and I installed IDLE for Python 3.4. However, in Terminal my python -V and pip --version are both Python 2.7. -How do I fix this? I really have no idea how any of this works, so please bear with my lack of knowledge.","Try python3 or python3.4. It should print out the right version if correctly installed. -Python 3.4 already has pip with it. You can use python3 -m pip to access pip. Or python3 -m ensurepip to make sure that it's correctly installed.",0.0,False,2,3670 -2015-04-12 01:10:46.060,I don't know how to update my Python version to 3.4?,"I'm on OSX, and I installed IDLE for Python 3.4. However, in Terminal my python -V and pip --version are both Python 2.7. How do I fix this? I really have no idea how any of this works, so please bear with my lack of knowledge.","I have found that making the 'python' alias replace the default version of python that the system comes with is a bad idea. When you install a new version of python (3.4 for instance), these two new commands are installed, specifically for the version you installed: @@ -35981,6 +35978,9 @@ pip3.4 python3.4 If you're using an IDE that wants you to indicate which python version you are using the IDE will let you navigate to it in the Library folder pip will still be for python2.7 after you download some other python version, as I think that's the current version osx comes installed with",0.0,False,2,3670 +2015-04-12 01:10:46.060,I don't know how to update my Python version to 3.4?,"I'm on OSX, and I installed IDLE for Python 3.4. However, in Terminal my python -V and pip --version are both Python 2.7. +How do I fix this? I really have no idea how any of this works, so please bear with my lack of knowledge.","Try python3 or python3.4. It should print out the right version if correctly installed. +Python 3.4 already has pip with it. You can use python3 -m pip to access pip. Or python3 -m ensurepip to make sure that it's correctly installed.",0.0,False,2,3670 2015-04-12 22:27:33.050,Custom user model in Django?,"I know how to make custom user models, my question is about style and best practices. What are the consequences of custom user model in Django? Is it really better to use auxiliary one-to-one model? And for example if I have a UserProfile models which is one-to-one to User, should I create friends relationship (which would be only specific to my app) between UserProfile or between User? @@ -36011,14 +36011,14 @@ after a lot of trying I've made (.*)[\(*]|[\[*] but it doesn't seem to work very I'm using the python regex engine",Use the regexp ^[^[]* to match everything up to the first [.,1.2,True,1,3674 2015-04-14 07:08:10.117,how to execute shell script in the same process in python,"I need to execute several shell scripts with python, some scripts would export environment parameters, so I need to execute them in the same process, otherwise, other scripts can't see the new environment parameters in one word, I want to let the shell script change the environment of the python process +so I should not use subprocess, any idea how to realize it?","What if you make a 'master' shell script that would execute all the others in sequence? This way you'll only have to create a single sub-process yourself, and the individual scripts will share the same environment. +If, however, you would like to interleave script executions with Python code, then you would probably have to make each of the scripts echo its environment to stdout before exiting, parse that, and then pass it into the next script (subprocess.Popen() accepts the env parameter, which is a map.)",1.2,True,2,3675 +2015-04-14 07:08:10.117,how to execute shell script in the same process in python,"I need to execute several shell scripts with python, some scripts would export environment parameters, so I need to execute them in the same process, otherwise, other scripts can't see the new environment parameters +in one word, I want to let the shell script change the environment of the python process so I should not use subprocess, any idea how to realize it?","No, you cannot run more than one program (bash, python) in the same process at the same time. But you can run them in sequence using exec in bash or one of the exec commands in python, like os.execve. Several things survive the ""exec boundary"", one of which is the environment block. So in each bash script you exec the next, and finally exec your python. You might also consider using an IPC mechanism like a named pipe to pass data between processes. I respectfully suggest that you look at your design again. Why are you mixing bash and python? Is it just to reuse code? Even if you managed this you will end with a real mess. It is generally easier to stick with one language.",0.2012947653214861,False,2,3675 -2015-04-14 07:08:10.117,how to execute shell script in the same process in python,"I need to execute several shell scripts with python, some scripts would export environment parameters, so I need to execute them in the same process, otherwise, other scripts can't see the new environment parameters -in one word, I want to let the shell script change the environment of the python process -so I should not use subprocess, any idea how to realize it?","What if you make a 'master' shell script that would execute all the others in sequence? This way you'll only have to create a single sub-process yourself, and the individual scripts will share the same environment. -If, however, you would like to interleave script executions with Python code, then you would probably have to make each of the scripts echo its environment to stdout before exiting, parse that, and then pass it into the next script (subprocess.Popen() accepts the env parameter, which is a map.)",1.2,True,2,3675 2015-04-15 10:21:55.367,Defining inputs and fitness in ANN with GA Python,"I am attempting to create a program that can find the best solution for winning a game using NN and I was hoping to get some help from the wonderful community here. The game is a strategy war game, you have your soldiers and a land you need to conquer. There is also the opponent's soldiers you need to be aware from them, for every second you have a land in your possession you get a certain amount of points. @@ -36094,9 +36094,9 @@ I would like to find a balance and make the spider run in 15 days (3x the origin 2015-04-20 17:08:54.103,How to Set Scrapy Auto_Throttle Settings,"My use case is this: I have 10 spiders and the AUTO_THROTTLE_ENABLED setting is set to True, globally. The problem is that for one of the spiders the runtime WITHOUT auto-throttling is 4 days, but the runtime WITH auto-throttling is 40 days... I would like to find a balance and make the spider run in 15 days (3x the original amount). I've been reading through the scrapy documentation this morning but the whole thing has confused me quite a bit. Can anyone tell me how to keep auto-throttle enabled globally, and just turn down the amount to which it throttles?","Auto_throttle is specifically designed so that you don't manually adjust DOWNLOAD_DELAY. Setting the DOWNLOAD_DELAY to some number will set an lower bound, meaning your AUTO_THROTTLE will not go faster than the number set in DOWNLOAD_DELAY. Since this is not what you want, your best bet would be to set AUTO_THROTTLE to all spiders except for the one you want to go faster, and manually set DOWNLOAD_DELAY for just that one spider without AUTO_THROTTLE to achieve whatever efficiency you desire.",0.1016881243684853,False,2,3684 2015-04-20 21:15:35.967,Scrapy crawl blocked with 403/503,"I'm running Scrapy 0.24.4, and have encountered quite a few sites that shut down the crawl very quickly, typically within 5 requests. The sites return 403 or 503 for every request, and Scrapy gives up. I'm running through a pool of 100 proxies, with the RotateUserAgentMiddleware enabled. -Does anybody know how a site could identify Scrapy that quickly, even with the proxies and user agents changing? Scrapy doesn't add anything to the request headers that gives it away, does it?",I simply set AutoThrottle_ENABLED to True and my script was able to run.,0.0,False,2,3685 -2015-04-20 21:15:35.967,Scrapy crawl blocked with 403/503,"I'm running Scrapy 0.24.4, and have encountered quite a few sites that shut down the crawl very quickly, typically within 5 requests. The sites return 403 or 503 for every request, and Scrapy gives up. I'm running through a pool of 100 proxies, with the RotateUserAgentMiddleware enabled. Does anybody know how a site could identify Scrapy that quickly, even with the proxies and user agents changing? Scrapy doesn't add anything to the request headers that gives it away, does it?","It appears that the primary problem was not having cookies enabled. Having enabled cookies, I'm having more success now. Thanks.",1.2,True,2,3685 +2015-04-20 21:15:35.967,Scrapy crawl blocked with 403/503,"I'm running Scrapy 0.24.4, and have encountered quite a few sites that shut down the crawl very quickly, typically within 5 requests. The sites return 403 or 503 for every request, and Scrapy gives up. I'm running through a pool of 100 proxies, with the RotateUserAgentMiddleware enabled. +Does anybody know how a site could identify Scrapy that quickly, even with the proxies and user agents changing? Scrapy doesn't add anything to the request headers that gives it away, does it?",I simply set AutoThrottle_ENABLED to True and my script was able to run.,0.0,False,2,3685 2015-04-21 02:17:24.163,How to uninstall and/or manage multiple versions of python in OS X 10.10.3,"I have installed the Python IDE Spyder. For me it's a great development environment. Some how in this process I have managed to install three versions of Python on my system.These can be located as following: @@ -36118,8 +36118,8 @@ how do i install numpy in pydev. tried putting numpy in site-packages folder. doesnt seem to work","Pandas can be installed after install python in to your pc. to install pandas go to command prompt and type ""pip install pandas"" this command collecting packages related to pandas. After if it asking to upgrade pip or if pip is not recognized by the command prompt use this command: python -m pip install --upgrade pip.",0.0,False,1,3687 -2015-04-21 16:46:04.380,File permission gets changed after file gets downloaded on client machine,"How to execute a file after it gets downloaded on client side,File is a python script, User dont know how to change permission of a file, How to solve this issue??",Change file permissions to make it executable: sudo chmod +x file.py,0.2012947653214861,False,2,3688 2015-04-21 16:46:04.380,File permission gets changed after file gets downloaded on client machine,"How to execute a file after it gets downloaded on client side,File is a python script, User dont know how to change permission of a file, How to solve this issue??",Maybe you can try teaching them how to use chmod +x command? Or actualy even more simple it would be to change it using GUI: right click -> properties -> permissions-> pick what is needed,0.0,False,2,3688 +2015-04-21 16:46:04.380,File permission gets changed after file gets downloaded on client machine,"How to execute a file after it gets downloaded on client side,File is a python script, User dont know how to change permission of a file, How to solve this issue??",Change file permissions to make it executable: sudo chmod +x file.py,0.2012947653214861,False,2,3688 2015-04-22 00:24:01.460,How to attach to PyCharm debugger when executing python script from bash?,"I know how to set-up run configurations to pass parameters to a specific python script. There are several entry points, I don't want a run configuration for each one do I? What I want to do instead is launch a python script from a command line shell script and be able to attach the PyCharm debugger to the python script that is executed and have it stop at break points. I've tried to use a pre-launch condition of a utility python script that will sleep for 10 seconds so I can attempt to ""attach to process"" of the python script. That didn't work. I tried to import pdb and settrace to see if that would stop it for attaching to the process, but that looks to be command line debugging specific only. Any clues would be appreciated. Thanks!","You can attach the debugger to a python process launched from terminal: Use Menu Tools --> Attach to process then select python process to debug. @@ -36143,9 +36143,17 @@ and set it to but this didn't help either. Any ideas? -EDIT: I set up a virtualenv to no avail and figured out how to add a path to the current framework on the new PyCharm version and it turns out the path to cv2.so has already been given yet it is still complaining.","I got the same situation under win7x64 with pycharm version 2016.1.1, after a quick glimpse into the stack frame, I think it is a bug! -Pycharm ipython patches import action for loading QT, matplotlib, ..., and finally sys.path lost its way! -anyway, there is a workaround, copy Lib/site-packages/cv2.pyd or cv2.so to $PYTHONROOT, problem solved!",0.0,False,3,3691 +EDIT: I set up a virtualenv to no avail and figured out how to add a path to the current framework on the new PyCharm version and it turns out the path to cv2.so has already been given yet it is still complaining.","Do the following steps: + +Download and install the OpenCV executable. +Add OpenCV in the system path(%OPENCV_DIR% = /path/of/opencv/directory) +Go to C:\opencv\build\python\2.7\x86 folder and copy cv2.pyd file. +Go to C:\Python27\DLLs directory and paste the cv2.pyd file. +Go to C:\Python27\Lib\site-packages directory and paste the cv2.pyd file. +Go to PyCharm IDE and go to DefaultSettings > PythonInterpreter. +Select the Python which you have installed. +Install the packages numpy, matplotlib and pip in pycharm. +Restart your PyCharm.",0.0,False,3,3691 2015-04-22 12:40:03.030,Cannot import cv2 in PyCharm,"I am working on a project that requires OpenCV and I am doing it in PyCharm on a Mac. I have managed to successfully install OpenCV using Homebrew, and I am able to import cv2 when I run Python (version 2.7.6) in Terminal and I get no errors. The issue arises when I try importing it in PyCharm. I get a red underline with: no module named cv2 @@ -36182,17 +36190,9 @@ and set it to but this didn't help either. Any ideas? -EDIT: I set up a virtualenv to no avail and figured out how to add a path to the current framework on the new PyCharm version and it turns out the path to cv2.so has already been given yet it is still complaining.","Do the following steps: - -Download and install the OpenCV executable. -Add OpenCV in the system path(%OPENCV_DIR% = /path/of/opencv/directory) -Go to C:\opencv\build\python\2.7\x86 folder and copy cv2.pyd file. -Go to C:\Python27\DLLs directory and paste the cv2.pyd file. -Go to C:\Python27\Lib\site-packages directory and paste the cv2.pyd file. -Go to PyCharm IDE and go to DefaultSettings > PythonInterpreter. -Select the Python which you have installed. -Install the packages numpy, matplotlib and pip in pycharm. -Restart your PyCharm.",0.0,False,3,3691 +EDIT: I set up a virtualenv to no avail and figured out how to add a path to the current framework on the new PyCharm version and it turns out the path to cv2.so has already been given yet it is still complaining.","I got the same situation under win7x64 with pycharm version 2016.1.1, after a quick glimpse into the stack frame, I think it is a bug! +Pycharm ipython patches import action for loading QT, matplotlib, ..., and finally sys.path lost its way! +anyway, there is a workaround, copy Lib/site-packages/cv2.pyd or cv2.so to $PYTHONROOT, problem solved!",0.0,False,3,3691 2015-04-23 14:19:53.433,I can't install eyeD3 0.7.5 into Python in windows,"could you help me with that. I can't manage to install this plugin. I tried: 1) install it through pip 2) through setup.py in win console @@ -36264,7 +36264,9 @@ I dont know how to create that file (is it a text file?) and where to put it?! (in which folder? in the Anaconda folder?) Any help appreciated -Thanks!",There are chances that the .condarc file is hidden as was in my case. I was using Linux Mint (Sarah) and couldn't find the file though later on I found that it was hidden in the home directory and hence when I opted to show hidden files I could find it.,0.1352210990936997,False,2,3701 +Thanks!","to create the .condarc file open Anaconda Prompt and type: +conda config +it will appear in your user's home directory",0.0,False,2,3701 2015-04-27 12:50:23.680,how to create a .condarc file for Anaconda?,"I am trying to set up a proxy server in Anaconda because my firewall does not allow me to run online commands such as conda update @@ -36275,9 +36277,7 @@ I dont know how to create that file (is it a text file?) and where to put it?! (in which folder? in the Anaconda folder?) Any help appreciated -Thanks!","to create the .condarc file open Anaconda Prompt and type: -conda config -it will appear in your user's home directory",0.0,False,2,3701 +Thanks!",There are chances that the .condarc file is hidden as was in my case. I was using Linux Mint (Sarah) and couldn't find the file though later on I found that it was hidden in the home directory and hence when I opted to show hidden files I could find it.,0.1352210990936997,False,2,3701 2015-04-27 18:31:33.507,Webapp architecture: Putting python in a MEAN stack app,"I currently have a small webapp on AWS based on the MEAN (Mongo, Express, Angular, Node) but have a python script I would like to execute on the front end. Is there a way to incorporate this? Basically, I have some data objects on my AngularJS frontend from a mongoDB that I would like to manipulate with python and don't know how to get them into a python scope, do something to them, and send them to a view. Is this possible? If so, how could it be done? Or is this totally against framework conventions and should never be done? from","To answer my own question about a year later, what I would do now is just run my python script in tiny web server that lived on the same server as my MEAN app. It wouldn't have any external ports exposed and the MEAN app would just ping it for information and get JSON back. Just in case anyone is looking at this question down the road... @@ -36294,6 +36294,8 @@ I attempted to stop and start the ""backend"" modules a few times to no avail. I One final symptom: I am able to upload my non-default modules fine, but cannot upload my default front-end module. The process continually says ""Checking if deployment succeeded...Will check again in 60 seconds."", even after rolling back the update. I Googled the error from the logs and found almost literally nothing. Anyone have any idea what's going on here, or how to fix it?",Fixed by shutting down all instances (on all modules/versions just to be safe).,1.2,True,1,3703 2015-04-28 19:43:33.607,Displaying pyqtgraph and pyqt widgets on web,"Is there a way to take existing python pyqtgraph and pyqt application and have it display on a web page to implement software as a service? I suspect that there has to be a supporting web framework like Django in between, but I am not sure how this is done. +Any hints links examples welcome.","If all you need are static plots, then it should be straightforward to draw and export to an SVG file, then display the SVG in a webpage (or export to image, as svg rendering is not reliable in all browsers). If you need interactivity, then you're going to need a different solution and probably pyqtgraph is not the tool for this job. VisPy does have some early browser support but this has only been demonstrated with ipython notebook.",0.0,False,2,3704 +2015-04-28 19:43:33.607,Displaying pyqtgraph and pyqt widgets on web,"Is there a way to take existing python pyqtgraph and pyqt application and have it display on a web page to implement software as a service? I suspect that there has to be a supporting web framework like Django in between, but I am not sure how this is done. Any hints links examples welcome.","Here is what I have sort of put together by pulling several threads online: Ruby On Rails seems to be more popular than python at this moment. @@ -36302,8 +36304,6 @@ bokeh seems to be a good way of plotting to a browser. AFAIK, there is no way to take an existing PyQt or pyqtgraph application and have it run on the web. I am not sure how Twisted (Tornado, Node.js and Friends) fits in to the web SaaS, but I see it referred to occasionally since it is asynchronous event-driven. People often suggest using Rest, but that seems slow to me. Not sure why...",1.2,True,2,3704 -2015-04-28 19:43:33.607,Displaying pyqtgraph and pyqt widgets on web,"Is there a way to take existing python pyqtgraph and pyqt application and have it display on a web page to implement software as a service? I suspect that there has to be a supporting web framework like Django in between, but I am not sure how this is done. -Any hints links examples welcome.","If all you need are static plots, then it should be straightforward to draw and export to an SVG file, then display the SVG in a webpage (or export to image, as svg rendering is not reliable in all browsers). If you need interactivity, then you're going to need a different solution and probably pyqtgraph is not the tool for this job. VisPy does have some early browser support but this has only been demonstrated with ipython notebook.",0.0,False,2,3704 2015-04-29 05:38:50.567,Django rest framework: correctly handle incoming array of model ids,"I have a question about REST design in general and specifically what the best way to implement a solution is in Django Rest Framework. Here it the situation: Say I have an app for keeping track of albums that the user likes. In the browser, the user sees a list of albums and each one has a check box next to it. Checking the box means you like the album. At the bottom of the page is a submit button. I want the submit button to initiate an AJAX request that sends tp my API endpoint a list of the ids (as in, the Djano model ids) of the albums that are liked by the user. @@ -36325,13 +36325,6 @@ Pyenv operates on a wider scale than virtualenv. It is used to install (build fr Using pyenv can be a convenient way of installing Python for subsequent virtualenv use.",0.9999999999999908,False,1,3707 2015-04-30 07:44:15.333,How to track anonymous users with Flask,"My app implements a shopping cart in which anonymous users can fill their cart with products. User Login is required only before payment. How can this be implemented? The main challenge is that flask must keep track of the user (even if anonymous) and their orders. My current approach is to leverage the AnonymousUserMixin object that is assigned to current_user. The assumption is that current_user will not change throughout the session. However, I noticed that a new AnonymousUserMixin object is assigned to current_user, for example, upon every browser page refresh. Notice that this does not happen if a user is authenticated. -Any suggestions on how to circumvent this?","There is no need for a custom AnonymousUserMixin, you can keep the shopping cart data in session: - -anonymous user adds something to hist cart -> update his session with the cart data -the user wants to check out -> redirect him to login page -logged in user is back at the check out -> take his cart data out of the session and do whatever you would do if he was logged in the whole time",0.9997532108480276,False,2,3708 -2015-04-30 07:44:15.333,How to track anonymous users with Flask,"My app implements a shopping cart in which anonymous users can fill their cart with products. User Login is required only before payment. How can this be implemented? -The main challenge is that flask must keep track of the user (even if anonymous) and their orders. My current approach is to leverage the AnonymousUserMixin object that is assigned to current_user. The assumption is that current_user will not change throughout the session. However, I noticed that a new AnonymousUserMixin object is assigned to current_user, for example, upon every browser page refresh. Notice that this does not happen if a user is authenticated. Any suggestions on how to circumvent this?","You can use a AnonymousUserMixin subclass if you like, but you need to add some logic to it so that you can associate each anonymous user with a cart stored in your database. This is what you can do: @@ -36341,6 +36334,13 @@ When the user is ready to pay you convert the anonymous user to a registered use If you have a cron job that routinely cleans up old/abandoned anonymous carts from the database, you may find that an old anonymous user connects and provides a user id that does not have a cart in the database (because the cart was deemed stale and deleted). You can handle this by creating a brand new cart for the same id, and you can even notify the user that the contents of the cart expired and were removed. Hope this helps!",0.6730655149877884,False,2,3708 +2015-04-30 07:44:15.333,How to track anonymous users with Flask,"My app implements a shopping cart in which anonymous users can fill their cart with products. User Login is required only before payment. How can this be implemented? +The main challenge is that flask must keep track of the user (even if anonymous) and their orders. My current approach is to leverage the AnonymousUserMixin object that is assigned to current_user. The assumption is that current_user will not change throughout the session. However, I noticed that a new AnonymousUserMixin object is assigned to current_user, for example, upon every browser page refresh. Notice that this does not happen if a user is authenticated. +Any suggestions on how to circumvent this?","There is no need for a custom AnonymousUserMixin, you can keep the shopping cart data in session: + +anonymous user adds something to hist cart -> update his session with the cart data +the user wants to check out -> redirect him to login page +logged in user is back at the check out -> take his cart data out of the session and do whatever you would do if he was logged in the whole time",0.9997532108480276,False,2,3708 2015-04-30 12:19:33.867,WebSockets best practice for connecting an external application to push data,"I am trying to understand how to use websockets correctly and seem to be missing some fundamental part of the puzzle. Say I have a website with 3 different pages: @@ -36550,10 +36550,10 @@ Worse comes to worse, I can ask for a row after skipping a predifined number of Edit: There could be some value using group by on timestamp and then somehow selecting a row from every group, but still not sure how to do this in a useful manner with sqlalchemy.","If I understand correctly your from_date and to_date are just dates. If you set them to python datetime objects with the date/times you want your results between, it should work.",0.0,False,1,3735 2015-05-14 23:22:26.500,Is it possible to see what a Python process is doing?,"I created a python script that grabs some info from various websites, is it possible to analyze how long does it take to download the data and how long does it take to write it on a file? +I am interested in knowing how much it could improve running it on a better PC (it is currently running on a crappy old laptop.","You can always store the system time in a variable before a block of code that you want to test, do it again after then compare them.",0.0,False,2,3736 +2015-05-14 23:22:26.500,Is it possible to see what a Python process is doing?,"I created a python script that grabs some info from various websites, is it possible to analyze how long does it take to download the data and how long does it take to write it on a file? I am interested in knowing how much it could improve running it on a better PC (it is currently running on a crappy old laptop.","If you just want to know how long a process takes to run the time command is pretty handy. Just run time and it will report how much time it took to run with it counted in a few categories, like wall clock time, system/kernel time and user space time. This won't tell you anything about which parts of the system are taking up the amount of time. You can always look at a profiler if you want/need that type of information. That said, as Barmar said, if you aren't doing much processing of the sites you are grabbing, the laptop is probably not going to be a limiting factor.",0.0,False,2,3736 -2015-05-14 23:22:26.500,Is it possible to see what a Python process is doing?,"I created a python script that grabs some info from various websites, is it possible to analyze how long does it take to download the data and how long does it take to write it on a file? -I am interested in knowing how much it could improve running it on a better PC (it is currently running on a crappy old laptop.","You can always store the system time in a variable before a block of code that you want to test, do it again after then compare them.",0.0,False,2,3736 2015-05-15 14:12:53.997,Calling python scripts from anywehre,"I have a collection of python scripts that import from each other. If I want to use these in a location where the scripts are not physically present, how can I do this. I tried adding the path of the dir with the scripts to my $PATH but got no joy. Any help appreciated, thanks.","Python doesn't share its own path with the general $PATH, so to be able to do what you're looking for, you must add your scripts in the $PYTHONPATH instead.",1.2,True,1,3737 2015-05-15 16:10:05.953,zipline error. No module named zipline,"I installed zipline package via Enthought Cantopy. Now I try to run a script using it in command prompt, but get error ImportError: No module named zipline. I also tried to run the same code using IPython, with the same output. @@ -36637,10 +36637,10 @@ set: to: ""UTF-8""",0.5457054096481145,False,1,3748 2015-05-21 08:22:17.117,Python / Django | How to store sent emails?,"I was wondering how can I store sent emails -I have a send_email() function in a pre_save() and now I want to store the emails that have been sent so that I can check when an email was sent and if it was sent at all.",I think the easiest way before messing up with middleware or whatever is to simply create a model for your logged emails and add a new record if send was successful.,1.2,True,2,3749 -2015-05-21 08:22:17.117,Python / Django | How to store sent emails?,"I was wondering how can I store sent emails I have a send_email() function in a pre_save() and now I want to store the emails that have been sent so that I can check when an email was sent and if it was sent at all.","Another way to look at it: send the mail to your backup email account ex: backup@yourdomain.com. So you can store the email, check if the email is sent or not. Other than that, having an extra model for logged emails is a way to go.",0.2655860252697744,False,2,3749 +2015-05-21 08:22:17.117,Python / Django | How to store sent emails?,"I was wondering how can I store sent emails +I have a send_email() function in a pre_save() and now I want to store the emails that have been sent so that I can check when an email was sent and if it was sent at all.",I think the easiest way before messing up with middleware or whatever is to simply create a model for your logged emails and add a new record if send was successful.,1.2,True,2,3749 2015-05-22 03:38:57.727,How to do django syncdb in version 1.4.2?,"How to do syncdb in django 1.4.2? i.e. having data in database, how to load the models again when the data schema is updated? Thanks in advance","Thanks Amyth for the hints. @@ -36699,15 +36699,15 @@ I ran %python inside an IPython Notebook and ran the cell, instead of returning Anyone know what has happen?",The kernel is busy. Go to the menu Kernel and click Interrupt. If this does not work click Restart. You need to go in a new cell and press Shift + Enter to see if it worked.,1.2,True,3,3752 2015-05-24 08:12:14.570,What does In [*] in IPython Notebook mean and how to turn it off?,"I use Windows 7, Python 2.7.9 plus latest version of IPython 3.1. I ran %python inside an IPython Notebook and ran the cell, instead of returning the Python version, it did not run and jumped to a new line and printed a In [*] instead of a line number. Now no line is running in ipython everything is ignored when I try to run a cell value. -Anyone know what has happen?","For me to resolve this issue, I had to stop my anti-virus program.",0.2655860252697744,False,3,3752 -2015-05-24 08:12:14.570,What does In [*] in IPython Notebook mean and how to turn it off?,"I use Windows 7, Python 2.7.9 plus latest version of IPython 3.1. -I ran %python inside an IPython Notebook and ran the cell, instead of returning the Python version, it did not run and jumped to a new line and printed a In [*] instead of a line number. Now no line is running in ipython everything is ignored when I try to run a cell value. Anyone know what has happen?","The issue causing your kernel to be busy can be a specific line of code. If that is the case, your computer may just need time to work through that line. To find out which line or lines are taking so long, as mentioned by Mike Muller you need to restart the program or interrupt the kernel. Then go through carefully running one line at a time until you reach the first one with the asterisk. If you do not restart or interrupt your busy program, you will not be able to tell which line is the problem line and which line is not, because it will just stay busy while it works on that problem line. It will continue to give you the asterisk on every line until it finishes running that one line of code even if you start back at the beginning. This is extremely confusing, because lines that have run and produced output suddenly lose their output when you run them on the second pass. Also confusing is the fact that you can make changes to your code while the kernel is busy, but you just can't get any new output until it is free again. Your code does not have to be wrong to cause this. You may just have included a time-consuming command. Bootstrapping has caused this for me. If your code is what it needs to be, it doesn't actually matter which line is the problem line, and you just need to give all of your code time to run. The main reasons to find out which is the problem line would be if some lines were expendable, or in case you were getting the asterisk for some other reason and needed to rule this one out. If you are writing code on an internet service that times out when you aren't giving it input, your code might not have enough time to finish running if you just wait on it. Scrolling every few minutes is usually enough to keep those pages from timing out.",0.7408590612005881,False,3,3752 +2015-05-24 08:12:14.570,What does In [*] in IPython Notebook mean and how to turn it off?,"I use Windows 7, Python 2.7.9 plus latest version of IPython 3.1. +I ran %python inside an IPython Notebook and ran the cell, instead of returning the Python version, it did not run and jumped to a new line and printed a In [*] instead of a line number. Now no line is running in ipython everything is ignored when I try to run a cell value. +Anyone know what has happen?","For me to resolve this issue, I had to stop my anti-virus program.",0.2655860252697744,False,3,3752 2015-05-24 19:12:21.647,Email API for connecting in a marketplace?,"I'm looking into what it would take to add a feature to my site so this is a pretty naive question. I'd like to be able to connect buyers and sellers via an email message once the buyer clicks ""buy"". I can see how I could do this in java script, querying the user database and sending an email with both parties involved. What I'm wondering is if there's a better way I can do this, playing monkey in the middle so they only receive an email from my site, and the it's automatically forwarded to the other party. That way they don't have to remember to hit reply-all, just reply. Also their email addresses remain anonymous. @@ -36836,6 +36836,8 @@ Is there a clever way around this issue? Or will I have to make do with a visite In graphs with cycles however, how do we avoid infinite recursion? In a procedural language I would mark nodes as I hit them, but let's say I can't do that. A list of visited nodes is possible, but will be slow because using one will result in a linear search of that list before recurring. A better data structure than a list here would obviously help, but that's not the aim of the game, because I'm coding in ML - lists are king, and anything else I will have to write myself. Is there a clever way around this issue? Or will I have to make do with a visited list or, god forbid, mutable state?","It is pretty OK to have a mutable state hidden inside the function. If it is not visible, then it doesn't exist. I usually use hash sets for this. But in general, you should stick to this if your profiling pinpointed that. Otherwise, just use set data structure. OCaml has an excellent Set based on eagerly balanced AVL trees.",0.296905446847765,False,2,3758 +2015-05-26 17:18:26.903,How to check all versions of python installed on osx and centos,I just started setting up a centos server today and noticed that the default version of python on centos is set to 2.6.6. I want to use python 2.7 instead. I googled around and found that 2.6.6 is used by system tools such as YUM so I should not tamper with it. Then I opened up a terminal on my mac and found that I had python 2.6.8 and 2.7.5 and 3.3.3 installed. Sorry for the long story. In short I just want to know how to lookup all the version of python installed on centos so I don't accidentally install it twice.,"we can directly use this to see all the pythons installed both by current user and the root by the following: + whereis python",0.5916962662253621,False,4,3759 2015-05-26 17:18:26.903,How to check all versions of python installed on osx and centos,I just started setting up a centos server today and noticed that the default version of python on centos is set to 2.6.6. I want to use python 2.7 instead. I googled around and found that 2.6.6 is used by system tools such as YUM so I should not tamper with it. Then I opened up a terminal on my mac and found that I had python 2.6.8 and 2.7.5 and 3.3.3 installed. Sorry for the long story. In short I just want to know how to lookup all the version of python installed on centos so I don't accidentally install it twice.,"COMMAND: python --version && python3 --version OUTPUT: @@ -36849,8 +36851,6 @@ Python 2.7.10 Python 3.7.1 You can make an alias like ""pyver"" in your .bashrc file or else using a text accelerator like AText maybe.",0.1352210990936997,False,4,3759 -2015-05-26 17:18:26.903,How to check all versions of python installed on osx and centos,I just started setting up a centos server today and noticed that the default version of python on centos is set to 2.6.6. I want to use python 2.7 instead. I googled around and found that 2.6.6 is used by system tools such as YUM so I should not tamper with it. Then I opened up a terminal on my mac and found that I had python 2.6.8 and 2.7.5 and 3.3.3 installed. Sorry for the long story. In short I just want to know how to lookup all the version of python installed on centos so I don't accidentally install it twice.,"we can directly use this to see all the pythons installed both by current user and the root by the following: - whereis python",0.5916962662253621,False,4,3759 2015-05-26 17:18:26.903,How to check all versions of python installed on osx and centos,I just started setting up a centos server today and noticed that the default version of python on centos is set to 2.6.6. I want to use python 2.7 instead. I googled around and found that 2.6.6 is used by system tools such as YUM so I should not tamper with it. Then I opened up a terminal on my mac and found that I had python 2.6.8 and 2.7.5 and 3.3.3 installed. Sorry for the long story. In short I just want to know how to lookup all the version of python installed on centos so I don't accidentally install it twice.,"As someone mentioned in a comment, you can use which python if it is supported by CentOS. Another command that could work is whereis python. In the event neither of these work, you can start the Python interpreter, and it will show you the version, or you could look in /usr/bin for the Python files (python, python3 etc).",0.1352210990936997,False,4,3759 2015-05-26 17:18:26.903,How to check all versions of python installed on osx and centos,I just started setting up a centos server today and noticed that the default version of python on centos is set to 2.6.6. I want to use python 2.7 instead. I googled around and found that 2.6.6 is used by system tools such as YUM so I should not tamper with it. Then I opened up a terminal on my mac and found that I had python 2.6.8 and 2.7.5 and 3.3.3 installed. Sorry for the long story. In short I just want to know how to lookup all the version of python installed on centos so I don't accidentally install it twice.,"Use, yum list installed command to find the packages you installed.",1.2,True,4,3759 2015-05-27 21:16:22.860,"Django 1.8, Using Admin app as the main site","I am about to begin work on a project that will use Django to create a system with three tiers of users. Each user will login into the dashboard type interface (each user will have different types of tools on the dashboard). There will be a few CRUD type interfaces for each user tier among other things. Only users with accounts will be able to interact with the system (anyone visiting is greeted with a login screen). @@ -37056,10 +37056,10 @@ netcdfvariable[:]=array1 Hope that helps anyone who finds this.",0.0,False,1,3786 2015-06-05 14:51:17.007,How to track Django model changes with git?,"Suppose you write a Django website and use git to manage the source code. Your website has various instances (one for each developer, at least). When you perform a change on the model in a commit, everybody needs to update its own database. In some cases it is enough to run python manage.py migrate, in some other cases you need to run a few custom SQL queries and/or run some Python code to update values at various places. -How to automate this? Is there a clean way to bundle these ""model updates"" (for instance small shell scripts that do the appropriate actions) in the associated commits? I have thought about using git hooks for that, but as the code to be run changes over time, it is not clear to me how to use them for that purpose.",You should track migrations. The only thing that you must keep an eye out for is at branch merge. If everyone uses a feature branch and develops on his branch then the changes are applied once the branch is integrated. At that point (pull request time or integration time) you need to make sure that the migrations make sense and if not fix them.,0.1016881243684853,False,2,3787 +How to automate this? Is there a clean way to bundle these ""model updates"" (for instance small shell scripts that do the appropriate actions) in the associated commits? I have thought about using git hooks for that, but as the code to be run changes over time, it is not clear to me how to use them for that purpose.","All changes to models should be in migrations. If you ""need to run a few custom SQL queries and/or run some Python code to update values"" then those are migrations too, and should be written in a migration file.",1.2,True,2,3787 2015-06-05 14:51:17.007,How to track Django model changes with git?,"Suppose you write a Django website and use git to manage the source code. Your website has various instances (one for each developer, at least). When you perform a change on the model in a commit, everybody needs to update its own database. In some cases it is enough to run python manage.py migrate, in some other cases you need to run a few custom SQL queries and/or run some Python code to update values at various places. -How to automate this? Is there a clean way to bundle these ""model updates"" (for instance small shell scripts that do the appropriate actions) in the associated commits? I have thought about using git hooks for that, but as the code to be run changes over time, it is not clear to me how to use them for that purpose.","All changes to models should be in migrations. If you ""need to run a few custom SQL queries and/or run some Python code to update values"" then those are migrations too, and should be written in a migration file.",1.2,True,2,3787 +How to automate this? Is there a clean way to bundle these ""model updates"" (for instance small shell scripts that do the appropriate actions) in the associated commits? I have thought about using git hooks for that, but as the code to be run changes over time, it is not clear to me how to use them for that purpose.",You should track migrations. The only thing that you must keep an eye out for is at branch merge. If everyone uses a feature branch and develops on his branch then the changes are applied once the branch is integrated. At that point (pull request time or integration time) you need to make sure that the migrations make sense and if not fix them.,0.1016881243684853,False,2,3787 2015-06-07 23:56:57.770,PYTHON py2exe makes too many files.. how do I execute only one .EXE file?,"After I make an exe file, there are many files such as .pyd that my exe depend on them.. I want to make a program with only one exe file which will be handie.. please help me","Py2exe is a tool provides an exe application which can be run without installing python interpreter, after packaging you find your exe and dlls of interpreter and all modules... In dist folder. It does nt provide all in one exe, use pyinstaller instead",0.0,False,1,3788 @@ -37146,17 +37146,17 @@ Could not find main GSSAPI shared library. Please try setting GSSAPI_MAIN_LIB yourself or setting ENABLE_SUPPORT_DETECTION to 'false' -I need this to work on Python 2.6 for LDAP3 authentication.","sudo apt install libkrb5-dev -actually installs /usr/bin/krb5-config and /usr/lib/libgssapi_krb5.so -so none of the symlinking was needed, just install libkrb5-dev and you should be good.",0.999823161659962,False,2,3802 +I need this to work on Python 2.6 for LDAP3 authentication.","For me, the issue got resolved after installing the package ""krb5-libs"" in Centos. +Basically we need to have libgssapi_krb5.so file for installing gssapi.",0.0,False,2,3802 2015-06-17 15:44:26.960,How to install GSSAPI Python module?,"I am trying to install the GSSAPI module through pip but I receive this error that I don't know how to resolve. Could not find main GSSAPI shared library. Please try setting GSSAPI_MAIN_LIB yourself or setting ENABLE_SUPPORT_DETECTION to 'false' -I need this to work on Python 2.6 for LDAP3 authentication.","For me, the issue got resolved after installing the package ""krb5-libs"" in Centos. -Basically we need to have libgssapi_krb5.so file for installing gssapi.",0.0,False,2,3802 +I need this to work on Python 2.6 for LDAP3 authentication.","sudo apt install libkrb5-dev +actually installs /usr/bin/krb5-config and /usr/lib/libgssapi_krb5.so +so none of the symlinking was needed, just install libkrb5-dev and you should be good.",0.999823161659962,False,2,3802 2015-06-19 12:01:52.220,NaiveBayes classifier handling different data types in python,"I am trying to implement Naive Bayes classifier in Python. My attributes are of different data types : Strings, Int, float, Boolean, Ordinal I could use Gaussian Naive Bayes classifier (Sklearn.naivebayes : Python package) , But I do not know how the different data types are to be handled. The classifier throws an error, stating cannot handle data types other than Int or float One way I could possibly think of is encoding the strings to numerical values. But I also doubt , how good the classifier would perform if I do this.","Yes, you will need to convert the strings to numerical values @@ -37221,14 +37221,6 @@ thanks in advance.","Definitely go for ""way #1"". Keeping an independent layer Stay away from singletons, they're just global variables with a new name. Use an appropriate life cycle for your interface objects. The obvious ""instantiate for each request"" is not the worst idea, and it's easier to optimize that if needed (by caching and/or memoization) than it's to unroll global vars everywhere. Keep in mind that web applications are supposed to be several processes on a ""shared nothing"" design; the only shared resources must be external to the app: database, queue managers, cache storage. Finally, try to avoid using this API directly from the view functions/CBV. Either use them from your models, or write a layer conceptually similar to the way models are used from the views. No need of an ORM-like api, but keep any 'business process' away from the views, which should be concerned only with the presentation and high level operations. Think ""thick model, thin views"" with your APIs as a new kind of models.",0.0,False,1,3807 -2015-06-22 19:17:57.343,Move .ipynb using the IPython Notebook Web Interface,"After creating a .ipynb file in the root directory /, how can you move that .pynb file into a deeper directory ie: /subdirectory using the web UI?","If some stumbles here as of 2020, it's now possible to move .ipynb or other kind of files by simply checking it and clicking move. -Nevertheless, for .ipynb files you must be sure that the notebook isn't running (gray icon). If it's running it should be green and you must shut it down before moving.",0.1016881243684853,False,4,3808 -2015-06-22 19:17:57.343,Move .ipynb using the IPython Notebook Web Interface,"After creating a .ipynb file in the root directory /, how can you move that .pynb file into a deeper directory ie: /subdirectory using the web UI?","Ipython 5.1: -1. Make new folder -- with IPython running, New, Folder, select 'Untitled folder' just created, rename (and remember the name!) -2. Go to the file you want to move, Move, write new directory name at prompt -Note: If the folder exists, skip 1. -Note: If you want to leave a copy in the original directory, Duplicate and then move.",0.0509761841073563,False,4,3808 -2015-06-22 19:17:57.343,Move .ipynb using the IPython Notebook Web Interface,"After creating a .ipynb file in the root directory /, how can you move that .pynb file into a deeper directory ie: /subdirectory using the web UI?","Duplicate the notebook and delete the original, was my workaround.",0.0,False,4,3808 2015-06-22 19:17:57.343,Move .ipynb using the IPython Notebook Web Interface,"After creating a .ipynb file in the root directory /, how can you move that .pynb file into a deeper directory ie: /subdirectory using the web UI?","Ran into this issue and solved it by : Create a new folder in jupyter notebooks. @@ -37236,6 +37228,14 @@ Go to the folder/directory and click the ""Upload ""button which is next to the Once you click ""Upload"", your pc file explorer window will pop-up, now simply find where you have your jupyter notebooks saved on your local machine and upload them to that desired file/directory. Although this doesn't technically move your python files to your desired directory, it does however make a copy in that directory. So next time you can be more organized and just click on a certain directory that you want and create/edit/view the files you chose to be in there instead of looking for them through your home directory.",0.0,False,4,3808 +2015-06-22 19:17:57.343,Move .ipynb using the IPython Notebook Web Interface,"After creating a .ipynb file in the root directory /, how can you move that .pynb file into a deeper directory ie: /subdirectory using the web UI?","Duplicate the notebook and delete the original, was my workaround.",0.0,False,4,3808 +2015-06-22 19:17:57.343,Move .ipynb using the IPython Notebook Web Interface,"After creating a .ipynb file in the root directory /, how can you move that .pynb file into a deeper directory ie: /subdirectory using the web UI?","Ipython 5.1: +1. Make new folder -- with IPython running, New, Folder, select 'Untitled folder' just created, rename (and remember the name!) +2. Go to the file you want to move, Move, write new directory name at prompt +Note: If the folder exists, skip 1. +Note: If you want to leave a copy in the original directory, Duplicate and then move.",0.0509761841073563,False,4,3808 +2015-06-22 19:17:57.343,Move .ipynb using the IPython Notebook Web Interface,"After creating a .ipynb file in the root directory /, how can you move that .pynb file into a deeper directory ie: /subdirectory using the web UI?","If some stumbles here as of 2020, it's now possible to move .ipynb or other kind of files by simply checking it and clicking move. +Nevertheless, for .ipynb files you must be sure that the notebook isn't running (gray icon). If it's running it should be green and you must shut it down before moving.",0.1016881243684853,False,4,3808 2015-06-23 13:02:21.470,move cursor in matplotlib window with keyboard stroke,"I would like to move the cursor in a Python matplotlib window by a (data) pixel at a time (I'm displaying a 2D image), using the keyboard arrow keys. I can trap the keyboard keypress events, but how do I reposition the cursor based on these events?","One solution is to make MatPlotLib react to key events immediately. Another solution is print a 'Cursor' or marker line on the plot, and change its coordinates with the mouse events. Eg. draw a vertical line, and update its X coordinates with the left and right keys. You can then add a label with the X coordinate along the line, and other nice tricks.",0.0,False,1,3809 2015-06-23 17:30:35.820,Django Functional Test for Time Delayed Procedure,"I am learning TDD and am using Django and Selenium to do some functional testing. I wanted to make it so that a user selects a checkbox that essentially says ""add 1 to this number nightly"". Then, for all of the users that have this setting on, a nightly process will automatically increment the number on these accounts. @@ -37256,12 +37256,12 @@ Let's say for example you have historical data, instead of having a single file I made a bash script that adds a host in my zabbix monitoring server. it works perfectly when I run .sh the idea is that I want to automate this configuration through salt. I am when I do a highstate my state that contains the script runs in the master before minion because there's my login authentication in my bash script. Is there's a special configuration for its? is what you have ideas how to do like this kind of setup? according to my research I found that to be used as the salt-runner but I do not know if this is good or not; -In anticipation of your return, I wish you a good weekend.","Run a minion on the same box as your master, then you can run the script on your master's minion and then on the other server.",0.0,False,2,3815 +In anticipation of your return, I wish you a good weekend.",If you need the highstate on the minion to cause something to occur on the master than you are going to want too look into using salt's Reactor (which is designed to do exactly this kind of multi-machine stuff).,1.2,True,2,3815 2015-06-26 13:07:10.673,Run script bash on saltstack master before minion,"I allow myself to write to you, due to a block on my part at Salt. I made a bash script that adds a host in my zabbix monitoring server. it works perfectly when I run .sh the idea is that I want to automate this configuration through salt. I am when I do a highstate my state that contains the script runs in the master before minion because there's my login authentication in my bash script. Is there's a special configuration for its? is what you have ideas how to do like this kind of setup? according to my research I found that to be used as the salt-runner but I do not know if this is good or not; -In anticipation of your return, I wish you a good weekend.",If you need the highstate on the minion to cause something to occur on the master than you are going to want too look into using salt's Reactor (which is designed to do exactly this kind of multi-machine stuff).,1.2,True,2,3815 +In anticipation of your return, I wish you a good weekend.","Run a minion on the same box as your master, then you can run the script on your master's minion and then on the other server.",0.0,False,2,3815 2015-06-26 21:12:34.690,how to determine point anomalies given window anomalies?,"I've been trying to determine how to detect point-anomalies given window-anomalies. In more detail, I know for each 30-day window whether it contains an anomaly. For example, window 1 starts at 1/1/2009, window 2 at 1/2/2009, and so on. Now I'm trying to use this knowledge to determine which dates these anomalies lie. If I have an anomaly on dates 1/5/2009 to 1/8/2009, my window will raise a signal for windows from a window with a last day of 1/8/2009 to a window starting on 1/5/2009. @@ -37412,11 +37412,11 @@ So far I'm grabbing server certificate with ssl.get_server_certificate(addr), bu 2015-07-12 17:25:41.693,Social login in using django-allauth without leaving the page,"I'm using django 1.8.3 and django-allauth 0.21.0 and I'd like the user to be able to log in using e.g. their Google account without leaving the page. The reason is that there's some valuable data from the page they're logging in from that needs to be posted after they've logged in. I've already got this working fine using local account creation, but I'm having trouble with social because many of the social networks direct the user away to a separate page to ask for permissions, etc. Ideally, I'd have all this happening in a modal on my page, which gets closed once authentication is successful. The only possible (though not ideal) solution I can think of at the moment is to force the authentication page to open up in another tab (e.g. using target=""_blank"" in the link), then prompting the user to click on something back in the original window once the authentication is completed in the other tab. However, the problem here is that I can't think of a way for the original page to know which account was just created by the previously-anonymous user without having them refresh the page, which would cause the important data that needs to be posted to be lost. -Does anyone have any ideas about how I could accomplish either of the two solutions I've outlined above?","I ended up resolving this by using Django's session framework. It turns out that the session ID is automatically passed through the oauth procedure by django-allauth, so anything that's stored in request.session is accessible on the other side after login is complete.",1.2,True,2,3834 +Does anyone have any ideas about how I could accomplish either of the two solutions I've outlined above?","One option is that the primary form pops up social auth in a new window then uses AJAX to poll for whether the social auth has completed. As long as you are fine with the performance characteristics of this (it hammers your server slightly), then this is probably the simplest solution.",0.0,False,2,3834 2015-07-12 17:25:41.693,Social login in using django-allauth without leaving the page,"I'm using django 1.8.3 and django-allauth 0.21.0 and I'd like the user to be able to log in using e.g. their Google account without leaving the page. The reason is that there's some valuable data from the page they're logging in from that needs to be posted after they've logged in. I've already got this working fine using local account creation, but I'm having trouble with social because many of the social networks direct the user away to a separate page to ask for permissions, etc. Ideally, I'd have all this happening in a modal on my page, which gets closed once authentication is successful. The only possible (though not ideal) solution I can think of at the moment is to force the authentication page to open up in another tab (e.g. using target=""_blank"" in the link), then prompting the user to click on something back in the original window once the authentication is completed in the other tab. However, the problem here is that I can't think of a way for the original page to know which account was just created by the previously-anonymous user without having them refresh the page, which would cause the important data that needs to be posted to be lost. -Does anyone have any ideas about how I could accomplish either of the two solutions I've outlined above?","One option is that the primary form pops up social auth in a new window then uses AJAX to poll for whether the social auth has completed. As long as you are fine with the performance characteristics of this (it hammers your server slightly), then this is probably the simplest solution.",0.0,False,2,3834 +Does anyone have any ideas about how I could accomplish either of the two solutions I've outlined above?","I ended up resolving this by using Django's session framework. It turns out that the session ID is automatically passed through the oauth procedure by django-allauth, so anything that's stored in request.session is accessible on the other side after login is complete.",1.2,True,2,3834 2015-07-13 07:01:48.093,Customize frappe framework html layout,"ERPNext + frappe need to change layout(footer & header) front-end. I tried to change base.html(frappe/templates/base.html) but nothing happened. Probably this is due to the fact that the html files need to somehow compile. Maybe someone have info how to do it? UPDATE: No such command ""clear-cache"". @@ -37533,9 +37533,9 @@ If you succeeded to use PGU, it wouldn't be so hard. If not, well, I wish you luck, and put your solution online for others. There is an Eclipse plug-in for Python. I think that Android studio does not support PGS4A. Never needed it. Console is the queen.",0.0,False,1,3840 2015-07-16 00:51:51.340,Python Modules Only Installing For Python 2,"I'm fairly new to python and want to start doing some more advanced programming in python 3. I installed some modules using pip on the terminal (I'm using a mac) only to find out that the modules only installed for python 2. I think that it's because I only installed it to the python 2 path, which I think is because my system is running python 2 by default. -But I have no idea how to get around this. Any ideas?",You need to use pip3. OS X will default to Python 2 otherwise.,1.2,True,2,3841 -2015-07-16 00:51:51.340,Python Modules Only Installing For Python 2,"I'm fairly new to python and want to start doing some more advanced programming in python 3. I installed some modules using pip on the terminal (I'm using a mac) only to find out that the modules only installed for python 2. I think that it's because I only installed it to the python 2 path, which I think is because my system is running python 2 by default. But I have no idea how to get around this. Any ideas?","When creating your virtual environment (you are using a virtual environment, right?) use pyvenv instead of virtualenv , and that will create a Python 3 virtual environment, free of Python 2. Then you are free to use pip and it will install the modules into that venv.",-0.2012947653214861,False,2,3841 +2015-07-16 00:51:51.340,Python Modules Only Installing For Python 2,"I'm fairly new to python and want to start doing some more advanced programming in python 3. I installed some modules using pip on the terminal (I'm using a mac) only to find out that the modules only installed for python 2. I think that it's because I only installed it to the python 2 path, which I think is because my system is running python 2 by default. +But I have no idea how to get around this. Any ideas?",You need to use pip3. OS X will default to Python 2 otherwise.,1.2,True,2,3841 2015-07-16 07:30:55.310,Where to run python file on Remote Debian Sever,"I have written a python script that is designed to run forever. I load the script into a folder that I made on my remote server which is running debian wheezy 7.0. The code runs , but it will only run for 3 to 4 hours then it just stops, I do not have any log information on it stopping.I come back and check the running process and its not there. Is this a problem in where I am running the python file from? The script simply has a while loop and writes to an external csv file. The file runs from /var/pythonscript. The folder is a custom folder that I made. There is not error that I receive and the only way I know how long the code runs is by the time stamp on the csv file. I run the .py file by ssh to the server and sudo python scriptname.I also would like to know the best place in the linux debian directory to run python files from and limitations concerning that. Any help would be much appreciated.","Basically you're stuffed. Your problem is: @@ -37565,12 +37565,12 @@ E.g. If I am told about a method called strip(), but told nothing about how it w 2015-07-17 22:30:01.683,"Pygame, user input on a GUI?","I need a user input for my pygame program, but I need it on my GUI(pygame.display.set_mode etc.), not just like: var = input(""input something""). Does anybody have suggestions how to do this?","There are some answers already here. Anyway, use PGU (Pygame GUI Utilities), it's available on pygame's site. It turns pygame into GUI toolkit. There is an explanation on how to combine it and your game. Otherwise, program it yourself using key events. It's not hard but time consuming and boring.",0.0,False,1,3845 2015-07-18 20:39:21.773,Installing Packages in Python - Pip/cmd vs Putting File in Lib/site-packages,"Whenever I google 'importing X package/module' I always see a bunch of tutorials about using pip or the shell commands. But I've always just taken the downloaded file and put it in the site-packages folder, and when I just use 'import' in PyCharm it has worked just fine. The reason I was wondering was because I was downloading NumPy today, and when I just copied the file the same way I'd been doing, PyCharm didn't show any errors. I was just wondering if I'm misunderstanding this whole concept of installing packages. -EDIT: Thank you for your answers! I am off to learn how to use pip now.","Package manager solves things like dependencies and uninstalling. -Additionally, when using pip to install packages, packages are usually being built with setup.py script. While it might not be an issue for pure Python modules, if package contains any extension modules or some other custom stuff, copying files to site-packages just won't work (I'm actually not sure why it worked in your case with numpy, since it does contain C extensions modules).",0.3869120172231254,False,2,3846 -2015-07-18 20:39:21.773,Installing Packages in Python - Pip/cmd vs Putting File in Lib/site-packages,"Whenever I google 'importing X package/module' I always see a bunch of tutorials about using pip or the shell commands. But I've always just taken the downloaded file and put it in the site-packages folder, and when I just use 'import' in PyCharm it has worked just fine. -The reason I was wondering was because I was downloading NumPy today, and when I just copied the file the same way I'd been doing, PyCharm didn't show any errors. I was just wondering if I'm misunderstanding this whole concept of installing packages. EDIT: Thank you for your answers! I am off to learn how to use pip now.","One of the points of using a package manager (pip) is portability. With pip, you just include a requirements.txt in your project and you can work on it on any machine, be it Windows, Linux, or Mac. When moving to a new environment/OS, pip will take care of installing the packages properly for you; note that packages can have OS-specific steps so your copy-pasted Windows set-up might now work when you move to another OS. Moreover, with your copy-paste method, you carry the bulk of your dependencies everywhere. I imagine that if you want to switch machines (not necessarily OS), you copy everything from project code to dependencies. With pip, you can keep your working directories leaner, all at the cost of a single requirements.txt.",0.3869120172231254,False,2,3846 +2015-07-18 20:39:21.773,Installing Packages in Python - Pip/cmd vs Putting File in Lib/site-packages,"Whenever I google 'importing X package/module' I always see a bunch of tutorials about using pip or the shell commands. But I've always just taken the downloaded file and put it in the site-packages folder, and when I just use 'import' in PyCharm it has worked just fine. +The reason I was wondering was because I was downloading NumPy today, and when I just copied the file the same way I'd been doing, PyCharm didn't show any errors. I was just wondering if I'm misunderstanding this whole concept of installing packages. +EDIT: Thank you for your answers! I am off to learn how to use pip now.","Package manager solves things like dependencies and uninstalling. +Additionally, when using pip to install packages, packages are usually being built with setup.py script. While it might not be an issue for pure Python modules, if package contains any extension modules or some other custom stuff, copying files to site-packages just won't work (I'm actually not sure why it worked in your case with numpy, since it does contain C extensions modules).",0.3869120172231254,False,2,3846 2015-07-19 22:06:56.717,Django app initialization process,"There is a set of functions that I need to carry out during the start of my server. Regardless of path whether that be ""/"", ""/blog/, ""/blog/post"". For developments purposes I'd love for this script to run every time I run python manage.py runserver and for production purposes I would love this script to run during deployment. Anyone know how this can be done? My script is scraping data off and making a call to Facebook's Graph API with python and some of its libraries.",Sounds like the quickest (if not most elegant) solution would be to call 'python manage.py runserver' at the end of your script.,0.0,False,1,3847 2015-07-20 03:54:51.290,PIP install unable to find ffi.h even though it recognizes libffi,"I have installed libffi on my Linux server as well as correctly set the PKG_CONFIG_PATH environment variable to the correct directory, as pip recognizes that it is installed; however, when trying to install pyOpenSSL, pip states that it cannot find file 'ffi.h'. I know both thatffi.h exists as well as its directory, so how do I go about closing this gap between ffi.h and pip?","You need to install the development package for libffi. @@ -37687,7 +37687,14 @@ Another question: I accidently created another profile in IPython, how can I rem The input in this specific case for the http request was 269KB in size. So my python program fails with ""Argument list too long"" (I verified that there was no other arguments passed, just the request and one more argument as expected by the option parser. When I throw away some of the request and reduce its size, things work fine. So I have a strong reason to believe the size of the request is causing my problems here.) Is it possible for a HTTP request to be that big ? -If so how do I fix the OptionParser to handle this input?","Typical limit is 8KB, but it can vary (like, be even less).",1.2,True,3,3863 +If so how do I fix the OptionParser to handle this input?","Is it possible for a HTTP request to be that big ? + +Yes it's possible but it's not recommended and you could have compatibility issues depending on your web server configuration. If you need to pass large amounts of data you shouldn't use GET. + +If so how do I fix the OptionParser to handle this input? + +It appears that OptionParser has set its own limit well above what is considered a practical implementation. I think the only way to 'fix' this is to get the Python source code and modify it to meet your requirements. Alternatively write your own parser. +UPDATE: I possibly mis-interpreted the question and the comment from Padraic below may well be correct. If you have hit an OS limit for command line argument size then it is not an OptionParser issue but something much more fundamental to your system design that means you may have to rethink your solution. This also possibly explains why you are attempting to use GET in your application (so you can pass it on the command line?)",0.3869120172231254,False,3,3863 2015-07-25 20:09:30.433,Is a HTTP Get request of size 269KB allowed?,"I am debugging a test case. I use Python's OptionParser (from optparse) to do some testing and one of the options is a HTTP request. The input in this specific case for the http request was 269KB in size. So my python program fails with ""Argument list too long"" (I verified that there was no other arguments passed, just the request and one more argument as expected by the option parser. When I throw away some of the request and reduce its size, things work fine. So I have a strong reason to believe the size of the request is causing my problems here.) @@ -37699,14 +37706,7 @@ But still, for 269KB, use POST (or PUT if that is semantically more correct), wh The input in this specific case for the http request was 269KB in size. So my python program fails with ""Argument list too long"" (I verified that there was no other arguments passed, just the request and one more argument as expected by the option parser. When I throw away some of the request and reduce its size, things work fine. So I have a strong reason to believe the size of the request is causing my problems here.) Is it possible for a HTTP request to be that big ? -If so how do I fix the OptionParser to handle this input?","Is it possible for a HTTP request to be that big ? - -Yes it's possible but it's not recommended and you could have compatibility issues depending on your web server configuration. If you need to pass large amounts of data you shouldn't use GET. - -If so how do I fix the OptionParser to handle this input? - -It appears that OptionParser has set its own limit well above what is considered a practical implementation. I think the only way to 'fix' this is to get the Python source code and modify it to meet your requirements. Alternatively write your own parser. -UPDATE: I possibly mis-interpreted the question and the comment from Padraic below may well be correct. If you have hit an OS limit for command line argument size then it is not an OptionParser issue but something much more fundamental to your system design that means you may have to rethink your solution. This also possibly explains why you are attempting to use GET in your application (so you can pass it on the command line?)",0.3869120172231254,False,3,3863 +If so how do I fix the OptionParser to handle this input?","Typical limit is 8KB, but it can vary (like, be even less).",1.2,True,3,3863 2015-07-26 11:30:18.177,Collecting results from celery worker with asyncio,"I am having a Python application which offloads a number of processing work to a set of celery workers. The main application has to then wait for results from these workers. As and when result is available from a worker, the main application will process the results and will schedule more workers to be executed. I would like the main application to run in a non-blocking fashion. As of now, I am having a polling function to see whether results are available from any of the workers. I am looking at the possibility of using asyncio get notification about result availability so that I can avoid the polling. But, I could not find any information on how to do this. @@ -37719,8 +37719,8 @@ If it was just content, I could move the scrapy items over once the work was don Basically one string is correct and other one is a mis-spelling of it. All my strings are names of people. Any suggestions on how to achieve this. Solution does not have to be 100 percent effective.",You could split the string and check to see if it contains at least one first/last name that is correct.,0.0679224682270276,False,1,3866 -2015-07-27 04:08:06.323,Importing a python module I have created,"I know how to import a module I have created if the script I am working on is in the same directory. I would like to know how to set it up so I can import this module from anywhere. For example, I would like to open up Python in the command line and type ""import my_module"" and have it work regardless of which directory I am in.","To make this work consistently, you can put the module into the lib folder inside the python folder, then you can import it regardless of what directory you are in",0.0,False,2,3867 2015-07-27 04:08:06.323,Importing a python module I have created,"I know how to import a module I have created if the script I am working on is in the same directory. I would like to know how to set it up so I can import this module from anywhere. For example, I would like to open up Python in the command line and type ""import my_module"" and have it work regardless of which directory I am in.",You could create pth file with path to your module and put it into your Python site-packages directory.,0.0,False,2,3867 +2015-07-27 04:08:06.323,Importing a python module I have created,"I know how to import a module I have created if the script I am working on is in the same directory. I would like to know how to set it up so I can import this module from anywhere. For example, I would like to open up Python in the command line and type ""import my_module"" and have it work regardless of which directory I am in.","To make this work consistently, you can put the module into the lib folder inside the python folder, then you can import it regardless of what directory you are in",0.0,False,2,3867 2015-07-27 09:21:11.480,How to create empty wordpress permalink and redirect it into django website?,"I need to do such thing, but I don't even know if it is possible to accomplish and if so, how to do this. I wrote an Django application which I would like to 'attach' to my wordpress blog. However, I need a permalink (but no page in wordpress pages section) which would point to Django application on the same server. Is that possible?","There are many ways to do this. You will have to provide more info about what you are trying to accomplish to give the right advise. @@ -37866,10 +37866,10 @@ Change GUI Style to GTK+. Edited.",0.0,False,1,3884 2015-08-09 17:32:41.707,"in qpython, how do I enter a ""return"" character",Very basic question. Im trying to use qpython. I can type things in the console but no obvious way to enter a return (or enter),The console works just like a normally python console. You can use a function if you want to write a script in the console.,0.0,False,3,3885 +2015-08-09 17:32:41.707,"in qpython, how do I enter a ""return"" character",Very basic question. Im trying to use qpython. I can type things in the console but no obvious way to enter a return (or enter),go to settings->input method select word-based,0.2012947653214861,False,3,3885 2015-08-09 17:32:41.707,"in qpython, how do I enter a ""return"" character",Very basic question. Im trying to use qpython. I can type things in the console but no obvious way to enter a return (or enter),"There is no way of doing it. The console will automatically input a break line when the line of code ends so you can continue inputting in the screen without any scroll bars. For complex code, you should use the editor.",0.0,False,3,3885 -2015-08-09 17:32:41.707,"in qpython, how do I enter a ""return"" character",Very basic question. Im trying to use qpython. I can type things in the console but no obvious way to enter a return (or enter),go to settings->input method select word-based,0.2012947653214861,False,3,3885 2015-08-09 17:43:04.457,"python, data structures, algorithm: how to rank top 10 most visited pages in latest 60 minutes?","If there a data structures likes container/queue, based on time , I could use it this way: add item(may duplicate) into it one by one, pop out those added time ealier then 60 minutes; count the queue; then I got top 10 most added items, in a dymatice period, said, 60min. How to implement this time based container ?","You can do something like this: @@ -37910,16 +37910,16 @@ was the answer, but i had to use this for building both python2.7.10 and mod_wsg in order for me to get this data, i need to give the IP address of where the requests are going to come from (my heroku app) how do i get the ip address in which my heroku application will request at",To my knowledge you can not get an ip for a heroku application. You could create a proxy with a known ip that serves as a middleman for the application. Otherwise you might want to look at whether heroku is still the correct solution for you,0.5457054096481145,False,1,3890 2015-08-11 10:48:04.477,Django-admin creates wrong django version inside virtualenv,"I've created a n new directory, a virtualenv and installed a django-toolbelt inside it. The django-version should be 1.8 but when I call 'django-admin.py version' it says 1.6. So when I start a new project it creates a 1.6. I thought virtualenv was supposed to prevent this. What am I doing wrong? +Edit: I think it has to do with the PATH (?). Like it's calling the wrong django-admin version. I'm on Windows 7. Still don't know how to fix it.","I had the same problem. Could be related to your zsh/bash settings. +I realized that using zsh (my default) I would get django-admin version 1.11 despite the Django version was 2.1! When I tried the same thing with bash I would get django-admin version 2.1 (the correct version). Certainly a misconfiguration. +So, I strongly suggest you check your zsh or bash settings to check for paths you might have.",0.0,False,2,3891 +2015-08-11 10:48:04.477,Django-admin creates wrong django version inside virtualenv,"I've created a n new directory, a virtualenv and installed a django-toolbelt inside it. The django-version should be 1.8 but when I call 'django-admin.py version' it says 1.6. So when I start a new project it creates a 1.6. I thought virtualenv was supposed to prevent this. What am I doing wrong? Edit: I think it has to do with the PATH (?). Like it's calling the wrong django-admin version. I'm on Windows 7. Still don't know how to fix it.","I came across this problem too. In the official document, I found that, in a virtual environment, if you use the command 'django-admin', it would search from PATH usually in '/usr/local/bin'(Linux) to find 'django-admin.py' which is a symlink to another version of django. This is the reason of what happened finally. So there are two methods to solve this problem: re-symlink your current version django-admin(site-packages/django/bin/django-admin.py) to 'usr/local/bin/django-admin' or 'usr/local/bin/django-admin.py' REMIND: This is a kind of global way so that it will effects your other django projects, so I recommend the second method cd to your_virtual_env/lib/python3.x/site-packages/django/bin/(of course you should activate your virtual environment), and then use 'python django-admin.py startproject project_name project_full_path' to create django project",0.296905446847765,False,2,3891 -2015-08-11 10:48:04.477,Django-admin creates wrong django version inside virtualenv,"I've created a n new directory, a virtualenv and installed a django-toolbelt inside it. The django-version should be 1.8 but when I call 'django-admin.py version' it says 1.6. So when I start a new project it creates a 1.6. I thought virtualenv was supposed to prevent this. What am I doing wrong? -Edit: I think it has to do with the PATH (?). Like it's calling the wrong django-admin version. I'm on Windows 7. Still don't know how to fix it.","I had the same problem. Could be related to your zsh/bash settings. -I realized that using zsh (my default) I would get django-admin version 1.11 despite the Django version was 2.1! When I tried the same thing with bash I would get django-admin version 2.1 (the correct version). Certainly a misconfiguration. -So, I strongly suggest you check your zsh or bash settings to check for paths you might have.",0.0,False,2,3891 2015-08-11 13:18:53.960,How to show star rating on ckan for datasets,"I have used ckanext-qa but its seems its not as per my requirement I am looking for extension by which Logged in user can be able to rate form 1 to 5 for each dataset over ckan. Anybody have an idea how to do like that","I'm not aware of any extensions that do this. You could write one to add this info in a dataset extra field. You may wish to store it as JSON and record the ratings given by each user. @@ -37981,12 +37981,12 @@ In future lets suppose that you want to add events to another model, like User, 2015-08-25 16:41:23.073,How to make Python 3 my default Python at command prompt?,"I have uninstalled Python 2.7 and installed Python 3. But, when I type Python on my command prompt I get this : ""Enthought Canopy Python 2.7.9 ........."" How can I run Python 3 from command line or how can I make it default on my computer? I asked Enthought Canopy help and I was told that I can ""have Canopy be your default Python only in a ""Canopy Command Prompt"". Not sure what it means. -edit : Thanks everyone. As suggested, I had to uninstall everything and install Python again.","After editing each path and creating a new variable for each python version, be sure to rename the python.exe to a unique one. i.e. ""python3x"" . then you can call it in the command line as ""python3x"". I am assuming that the original python installed (2X) retains the python.exe of which when you call ""python"" in the command line, it will show the 2x version",0.0,False,2,3902 +edit : Thanks everyone. As suggested, I had to uninstall everything and install Python again.","You can copy python.exe to python3.exe. +If you are using Anaconda, then you will find it in the sub directory of your environment, for intance, c:\Anaconda\envs\myenvironment.",0.0,False,2,3902 2015-08-25 16:41:23.073,How to make Python 3 my default Python at command prompt?,"I have uninstalled Python 2.7 and installed Python 3. But, when I type Python on my command prompt I get this : ""Enthought Canopy Python 2.7.9 ........."" How can I run Python 3 from command line or how can I make it default on my computer? I asked Enthought Canopy help and I was told that I can ""have Canopy be your default Python only in a ""Canopy Command Prompt"". Not sure what it means. -edit : Thanks everyone. As suggested, I had to uninstall everything and install Python again.","You can copy python.exe to python3.exe. -If you are using Anaconda, then you will find it in the sub directory of your environment, for intance, c:\Anaconda\envs\myenvironment.",0.0,False,2,3902 +edit : Thanks everyone. As suggested, I had to uninstall everything and install Python again.","After editing each path and creating a new variable for each python version, be sure to rename the python.exe to a unique one. i.e. ""python3x"" . then you can call it in the command line as ""python3x"". I am assuming that the original python installed (2X) retains the python.exe of which when you call ""python"" in the command line, it will show the 2x version",0.0,False,2,3902 2015-08-26 15:07:51.750,Call python script from Jira while creating an issue,"Let say I'm creating an issue in Jira and write the summary and the description. Is it possible to call a python script after these are written that sets the value for another field, depending on the values of the summary and the description? I know how to create an issue and change fields from a python script using the jira-python module. But I have not find a solution for using a python script while editing/creating the issue manually in Jira. Does anyone have an idea of how I manage that?",Take a look at JIRA webhooks calling a small python based web server?,0.2012947653214861,False,1,3903 2015-08-27 09:13:53.417,Tornado websocket pings,"I'm running a Python Tornado server with a WebSocket handler. @@ -38010,6 +38010,9 @@ how do I what page or service or ajax call is being made when i hit the submit b or is there any better way to solve this","The developers console ( F12 in Chrome and Firefox) is a wonderful thing. Check the Network or Net tab. There you can see all the requests between your browser and your server.",0.0,False,1,3906 2015-08-29 10:15:26.453,How to properly install wxPython?,"So I was looking around at different things to do on Python, like code for flashing text or a timer, but when I copied them into my window, there were constant syntax errors. Now, maybe you're not meant to copy them straight in, but one error I got was 'no module named wx'. I learned that I could get that module by installing wxPython. Problem is, I've tried all 4 options and none of them have worked for me. Which one do I download and how do I set it up using Windows? +Thanks","Check the version of wxpython and the version of python you have in your machine. +For python 2.7 use wxPython3.0-win32-3.0.2.0-py27 package",0.0,False,2,3907 +2015-08-29 10:15:26.453,How to properly install wxPython?,"So I was looking around at different things to do on Python, like code for flashing text or a timer, but when I copied them into my window, there were constant syntax errors. Now, maybe you're not meant to copy them straight in, but one error I got was 'no module named wx'. I learned that I could get that module by installing wxPython. Problem is, I've tried all 4 options and none of them have worked for me. Which one do I download and how do I set it up using Windows? Thanks","3 steps to install wx-widgets and pygame in python IDLE Install python 3xxx in your system opting (Add 3xxx to your path). @@ -38025,9 +38028,6 @@ To install wxpython enter command : pip install -U wxPython Thats all !!",0.2781854903257024,False,2,3907 -2015-08-29 10:15:26.453,How to properly install wxPython?,"So I was looking around at different things to do on Python, like code for flashing text or a timer, but when I copied them into my window, there were constant syntax errors. Now, maybe you're not meant to copy them straight in, but one error I got was 'no module named wx'. I learned that I could get that module by installing wxPython. Problem is, I've tried all 4 options and none of them have worked for me. Which one do I download and how do I set it up using Windows? -Thanks","Check the version of wxpython and the version of python you have in your machine. -For python 2.7 use wxPython3.0-win32-3.0.2.0-py27 package",0.0,False,2,3907 2015-08-29 10:32:24.120,Install a custom Python 2.7.10 module on Mac,"I don't know how many duplicates of this are out there but none of those I looked at solved my problem. To practice writing and installing custom modules I've written a simple factorial module. I have made a factorial folder in my site-packages folder containing factorial.py and an empty __init__.py file. But typing import factorial does not work. How can I solve this? I also tried pip install factorial but that didn't work either. @@ -38102,21 +38102,6 @@ C:\WINDOWS\system32>python Python 2.7.10 (default, May 23 2015, -easy_install twilio File """", line 1 - easy_install twilio - ^ SyntaxError: invalid syntax","You should not type python first, then it becomes python command line. -Open a new command prompt and directly type: -easy_install twilio",0.3869120172231254,False,2,3913 -2015-09-02 00:53:41.593,"getting ""SyntaxError"" when installing twilio in the Windows command line interface","I'm new here and also a new Python learner. I was trying to install twilio package through the Windows command line interface, but I got a syntax error(please see below). I know there're related posts, however, I was still unable to make it work after trying those solutions. Perhaps I need to set the path in the command line, but I really have no idea how to do that...(I can see the easy_install and pip files in the Scripts folder under Python) Can anyone please help? Thanks in advance! - -Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. - All rights reserved. -C:\WINDOWS\system32>python Python 2.7.10 (default, May 23 2015, - 09:44:00) [MSC v.1500 64 bit (AMD64)] on wi n32 Type ""help"", - ""copyright"", ""credits"" or ""license"" for more information. - - - easy_install twilio File """", line 1 easy_install twilio ^ SyntaxError: invalid syntax","go to the command prompt @@ -38132,6 +38117,21 @@ type cd scripts it will say C:\python27/scripts> type easy_install twilio then wait for it to run the procceses and then you will have twilio installed to python.",0.1352210990936997,False,2,3913 +2015-09-02 00:53:41.593,"getting ""SyntaxError"" when installing twilio in the Windows command line interface","I'm new here and also a new Python learner. I was trying to install twilio package through the Windows command line interface, but I got a syntax error(please see below). I know there're related posts, however, I was still unable to make it work after trying those solutions. Perhaps I need to set the path in the command line, but I really have no idea how to do that...(I can see the easy_install and pip files in the Scripts folder under Python) Can anyone please help? Thanks in advance! + +Microsoft Windows [Version 6.3.9600] (c) 2013 Microsoft Corporation. + All rights reserved. +C:\WINDOWS\system32>python Python 2.7.10 (default, May 23 2015, + 09:44:00) [MSC v.1500 64 bit (AMD64)] on wi n32 Type ""help"", + ""copyright"", ""credits"" or ""license"" for more information. + + + +easy_install twilio File """", line 1 + easy_install twilio + ^ SyntaxError: invalid syntax","You should not type python first, then it becomes python command line. +Open a new command prompt and directly type: +easy_install twilio",0.3869120172231254,False,2,3913 2015-09-02 01:10:08.887,Multiple authentication app support,"When developing a Django project, many third party authentication packages are available, for example: Django OAuth Toolkit, OAuth 2.0 support. @@ -38161,19 +38161,19 @@ So if you are writing data with a TTL of 10 seconds, then you need to write the I think in Django, views.py is similar to Controller and In django ,in views.py i have a long line of code of more than 300 lines and i want to make my code clean by making seperate views.py for userRegistration,Contact,ArticleControl etc. My question is how can i achieve this ie:making many views.py like controller","Instead of multiple views.py, You can divide your application into individual applications within your project. Like separate applications for userRegistration, Contact, ArticleControl. this way your code will look much cleaner. And in case of any bug you will be able to debug that specific application easily.",0.999329299739067,False,1,3918 2015-09-04 04:49:32.933,Pip freeze for only project requirements,"When I run pip freeze > requirements.txt it seems to include all installed packages. This appears to be the documented behavior. I have, however, done something wrong as this now includes things like Django in projects that have no business with Django. -How do I get requirements for just this project? or in the future how do I install a package with pip to be used for this project. I think I missed something about a virtualenv.","I have tried both pipreqs and pigar and found pigar is better because it also generates information about where it is used, it also has more options.",0.7153027079198643,False,3,3919 -2015-09-04 04:49:32.933,Pip freeze for only project requirements,"When I run pip freeze > requirements.txt it seems to include all installed packages. This appears to be the documented behavior. -I have, however, done something wrong as this now includes things like Django in projects that have no business with Django. -How do I get requirements for just this project? or in the future how do I install a package with pip to be used for this project. I think I missed something about a virtualenv.","if you are using linux then do it with sed -pip freeze | sed 's/==.*$/''/' > requirements.txt",0.0407936753323291,False,3,3919 -2015-09-04 04:49:32.933,Pip freeze for only project requirements,"When I run pip freeze > requirements.txt it seems to include all installed packages. This appears to be the documented behavior. -I have, however, done something wrong as this now includes things like Django in projects that have no business with Django. How do I get requirements for just this project? or in the future how do I install a package with pip to be used for this project. I think I missed something about a virtualenv.","I just had the same issue, here's what I've found to solve the problem. First create the venv in the directory of your project, then activate it. For Linux/MacOS : python3 -m venv ./venv source myvenv/bin/activate For Windows : python3 -m venv .\venv env\Scripts\activate.bat Now pip freeze > requirements.txt should only takes the library used in the project. NB: If you have already begin your project you will have to reinstall all the library to have them in pip freeze.",0.0,False,3,3919 +2015-09-04 04:49:32.933,Pip freeze for only project requirements,"When I run pip freeze > requirements.txt it seems to include all installed packages. This appears to be the documented behavior. +I have, however, done something wrong as this now includes things like Django in projects that have no business with Django. +How do I get requirements for just this project? or in the future how do I install a package with pip to be used for this project. I think I missed something about a virtualenv.","if you are using linux then do it with sed +pip freeze | sed 's/==.*$/''/' > requirements.txt",0.0407936753323291,False,3,3919 +2015-09-04 04:49:32.933,Pip freeze for only project requirements,"When I run pip freeze > requirements.txt it seems to include all installed packages. This appears to be the documented behavior. +I have, however, done something wrong as this now includes things like Django in projects that have no business with Django. +How do I get requirements for just this project? or in the future how do I install a package with pip to be used for this project. I think I missed something about a virtualenv.","I have tried both pipreqs and pigar and found pigar is better because it also generates information about where it is used, it also has more options.",0.7153027079198643,False,3,3919 2015-09-04 11:33:51.320,Keeping python sockets alive in event of connection loss,"I'm trying to make a socket connection that will stay alive so that in event of connection loss. So basically I want to keep the server always open (also the client preferably) and restart the client after the connection is lost. But if one end shuts down both ends shut down. I simulated this by having both ends on the same computer ""localhost"" and just clicking the X button. Could this be the source of my problems? Anyway my connection code m.connect((""localhost"", 5000)) @@ -38188,17 +38188,7 @@ while True: except socket.error: init = False tryconnection = True -And at the end of my code I just a m.send(""example"") when I press a button and if that returns an error the code of trying to connect to ""localhost"" starts again. And the server is a pretty generic server setup with a while loop around the x.accept(). So how do keep them both alive when the connection closes so they can reconnect when it opens again. Or is my code alright and its just by simulating on the same computer is messing with it?","I'm assuming we're dealing with TCP here since you use the word ""connection"". -It all depend by what you mean by ""connection loss"". -If by connection loss you mean that the data exchanges between the server and the client may be suspended/irresponsive (important: I did not say ""closed"" here) for a long among of time, seconds or minutes, then there's not much you can do about it and it's fine like that because the TCP protocol have been carefully designed to handle such situations gracefully. The timeout before deciding one or the other side is definitely down, give up, and close the connection is veeeery long (minutes). Example of such situation: the client is your smartphone, connected to some server on the web, and you enter a long tunnel. -But when you say: ""But if one end shuts down both ends shut down. I simulated this by having both ends on the same computer localhost and just clicking the X button"", what you are doing is actually closing the connections. - -If you abruptly terminate the server: the TCP/IP implementation of your operating system will know that there's not any more a process listening on port 5000, and will cleanly close all connections to that port. In doing so a few TCP segments exchange will occur with the client(s) side (it's a TCP 4-way tear down or a reset), and all clients will be disconected. It is important to understand that this is done at the TCP/IP implementation level, that's to say your operating system. -If you abruptly terminate a client, accordingly, the TCP/IP implementation of your operating system will cleanly close the connection from it's port Y to your server port 5000. -In both cases/side, at the network level, that would be the same as if you explicitly (not abruptly) closed the connection in your code. - -...and once closed, there's no way you can possibly re-establish those connections as they were before. You have to establish new connections. -If you want to establish these new connections and get the application logic to the state it was before, now that's another topic. TCP alone can't help you here. You need a higher level protocol, maybe your own, to implement stateful client/server application.",1.2,True,2,3920 +And at the end of my code I just a m.send(""example"") when I press a button and if that returns an error the code of trying to connect to ""localhost"" starts again. And the server is a pretty generic server setup with a while loop around the x.accept(). So how do keep them both alive when the connection closes so they can reconnect when it opens again. Or is my code alright and its just by simulating on the same computer is messing with it?","The issue is not related to the programming language, in this case python. The oeprating system (Windows or linux), has the final word regarding the resilience degree of the socket.",0.0,False,2,3920 2015-09-04 11:33:51.320,Keeping python sockets alive in event of connection loss,"I'm trying to make a socket connection that will stay alive so that in event of connection loss. So basically I want to keep the server always open (also the client preferably) and restart the client after the connection is lost. But if one end shuts down both ends shut down. I simulated this by having both ends on the same computer ""localhost"" and just clicking the X button. Could this be the source of my problems? Anyway my connection code m.connect((""localhost"", 5000)) @@ -38213,21 +38203,38 @@ while True: except socket.error: init = False tryconnection = True -And at the end of my code I just a m.send(""example"") when I press a button and if that returns an error the code of trying to connect to ""localhost"" starts again. And the server is a pretty generic server setup with a while loop around the x.accept(). So how do keep them both alive when the connection closes so they can reconnect when it opens again. Or is my code alright and its just by simulating on the same computer is messing with it?","The issue is not related to the programming language, in this case python. The oeprating system (Windows or linux), has the final word regarding the resilience degree of the socket.",0.0,False,2,3920 +And at the end of my code I just a m.send(""example"") when I press a button and if that returns an error the code of trying to connect to ""localhost"" starts again. And the server is a pretty generic server setup with a while loop around the x.accept(). So how do keep them both alive when the connection closes so they can reconnect when it opens again. Or is my code alright and its just by simulating on the same computer is messing with it?","I'm assuming we're dealing with TCP here since you use the word ""connection"". +It all depend by what you mean by ""connection loss"". +If by connection loss you mean that the data exchanges between the server and the client may be suspended/irresponsive (important: I did not say ""closed"" here) for a long among of time, seconds or minutes, then there's not much you can do about it and it's fine like that because the TCP protocol have been carefully designed to handle such situations gracefully. The timeout before deciding one or the other side is definitely down, give up, and close the connection is veeeery long (minutes). Example of such situation: the client is your smartphone, connected to some server on the web, and you enter a long tunnel. +But when you say: ""But if one end shuts down both ends shut down. I simulated this by having both ends on the same computer localhost and just clicking the X button"", what you are doing is actually closing the connections. + +If you abruptly terminate the server: the TCP/IP implementation of your operating system will know that there's not any more a process listening on port 5000, and will cleanly close all connections to that port. In doing so a few TCP segments exchange will occur with the client(s) side (it's a TCP 4-way tear down or a reset), and all clients will be disconected. It is important to understand that this is done at the TCP/IP implementation level, that's to say your operating system. +If you abruptly terminate a client, accordingly, the TCP/IP implementation of your operating system will cleanly close the connection from it's port Y to your server port 5000. +In both cases/side, at the network level, that would be the same as if you explicitly (not abruptly) closed the connection in your code. + +...and once closed, there's no way you can possibly re-establish those connections as they were before. You have to establish new connections. +If you want to establish these new connections and get the application logic to the state it was before, now that's another topic. TCP alone can't help you here. You need a higher level protocol, maybe your own, to implement stateful client/server application.",1.2,True,2,3920 2015-09-04 21:21:21.633,Using SCM to synchronize PyDev eclipse projects between different computer,"I use eclipse to write python codes using pydev. So far I have been using dropbox to synchronize my workspace. However, this is far from ideal. I would like to use github (or another SCM platform) to upload my code so I can work with it from different places. However, I have found many tutorials kind of daunting... Maybe because they are ready for projects shared between many programers Would anyone please share with me their experience on how to do this? Or any basic tutorial to do this effectively? -Thanks","I use mercurial. I picked it because it seemed easier. But is is only easiER. -There is mercurial eclipse plugin. -Save a copy of your workspace and maybe your eclipse folder too before daring it :)",1.2,True,2,3921 +Thanks","I use bitbucket coupled with mercurial. That is my repository is on bitbucket and i pull and psuh to it from mercurial within eclipse +For my backup i have an independent carbonite process going to net back all hard disk files. But I imagine there is a clever free programatic way to do so. If one knew how to write the appropriate scripts. +Glad the first suggestion was helpful .you are wise to bite the bullet and get this in place now. ;)",0.0,False,2,3921 2015-09-04 21:21:21.633,Using SCM to synchronize PyDev eclipse projects between different computer,"I use eclipse to write python codes using pydev. So far I have been using dropbox to synchronize my workspace. However, this is far from ideal. I would like to use github (or another SCM platform) to upload my code so I can work with it from different places. However, I have found many tutorials kind of daunting... Maybe because they are ready for projects shared between many programers Would anyone please share with me their experience on how to do this? Or any basic tutorial to do this effectively? -Thanks","I use bitbucket coupled with mercurial. That is my repository is on bitbucket and i pull and psuh to it from mercurial within eclipse -For my backup i have an independent carbonite process going to net back all hard disk files. But I imagine there is a clever free programatic way to do so. If one knew how to write the appropriate scripts. -Glad the first suggestion was helpful .you are wise to bite the bullet and get this in place now. ;)",0.0,False,2,3921 +Thanks","I use mercurial. I picked it because it seemed easier. But is is only easiER. +There is mercurial eclipse plugin. +Save a copy of your workspace and maybe your eclipse folder too before daring it :)",1.2,True,2,3921 +2015-09-06 06:50:58.783,Homebrew installation of OpenCV 3.0 not linking to Python,"When I install OpenCV 3.0 with Homebrew, it gives me the following directions to link it to Python 2.7: + +If you need Python to find bindings for this keg-only formula, run: + echo /usr/local/opt/opencv3/lib/python2.7/site-packages >> + /usr/local/lib/python2.7/site-packages/opencv3.pth + +While I can find the python2.7 site packages in opencv3, no python34 site packages were generated. Does anyone know how I can link my OpenCV 3.0 install to Python 3?",You need to install opencv like brew install opencv3 --with-python3. You can see a list of options for a package by running brew info opencv3.,0.6730655149877884,False,2,3922 2015-09-06 06:50:58.783,Homebrew installation of OpenCV 3.0 not linking to Python,"When I install OpenCV 3.0 with Homebrew, it gives me the following directions to link it to Python 2.7: If you need Python to find bindings for this keg-only formula, run: @@ -38246,13 +38253,6 @@ Now you can find the site-packages folder created in Step 2. Just run the follow echo /usr/local/opt/opencv3/lib/python3.5/site-packages >> /usr/local/lib/python3.5/site-packages/opencv3.pth You may have to change the above command correpondingly to your installed Homebrew Python version (e.g. 3.4).",0.9981778976111988,False,2,3922 -2015-09-06 06:50:58.783,Homebrew installation of OpenCV 3.0 not linking to Python,"When I install OpenCV 3.0 with Homebrew, it gives me the following directions to link it to Python 2.7: - -If you need Python to find bindings for this keg-only formula, run: - echo /usr/local/opt/opencv3/lib/python2.7/site-packages >> - /usr/local/lib/python2.7/site-packages/opencv3.pth - -While I can find the python2.7 site packages in opencv3, no python34 site packages were generated. Does anyone know how I can link my OpenCV 3.0 install to Python 3?",You need to install opencv like brew install opencv3 --with-python3. You can see a list of options for a package by running brew info opencv3.,0.6730655149877884,False,2,3922 2015-09-06 12:23:38.097,Configuring an aiohttp app hosted by gunicorn,"I implemented my first aiohttp based RESTlike service, which works quite fine as a toy example. Now I want to run it using gunicorn. All examples I found, specify some prepared application in some module, which is then hosted by gunicorn. This requires me to setup the application at import time, which I don't like. I would like to specify some config file (development.ini, production.ini) as I'm used from Pyramid and setup the application based on that ini file. This is common to more or less all python web frameworks, but I don't get how to do it with aiohttp + gunicorn. What is the smartest way to switch between development and production settings using those tools?","At least for now aiohttp is a library without reading configuration from .ini or .yaml file. But you can write code for reading config and setting up aiohttp server by hands easy.",0.3869120172231254,False,1,3923 @@ -38269,21 +38269,21 @@ There is no other way than iterating over them line by line.",0.0,False,1,3925 2015-09-07 19:16:24.353,jupyter - how to comment out cells?,"Is it possible to comment out whole cells in jupyter? I need it for this case: I have a lot of cells, and I want to run all of them, except for a few of them. I like it that my code is organized in different cells, but I don't want to go to each cell and comment out its lines. I prefer to somehow choose the cells I want to comment out, then comment them out in one go (so I could later easily uncomment them) -Thanks",You can switch the cell from 'Code to 'Raw NBConvert',0.2012947653214861,False,4,3926 +Thanks","If you switch the cell to 'raw NBConvert' the code retains its formatting, while all text remains in a single font (important if you have any commented sections), so it remains readable. 'Markdown' will interpret the commented sections as headers and change the size and colour accordingly, making the cell rather messy. +On a side note I use this to interrupt the process if I want to stop it - it seems much more effective than 'Kernel --> Interrupt'.",0.999329299739067,False,4,3926 2015-09-07 19:16:24.353,jupyter - how to comment out cells?,"Is it possible to comment out whole cells in jupyter? I need it for this case: I have a lot of cells, and I want to run all of them, except for a few of them. I like it that my code is organized in different cells, but I don't want to go to each cell and comment out its lines. I prefer to somehow choose the cells I want to comment out, then comment them out in one go (so I could later easily uncomment them) -Thanks",Mark the content of the cell and press Ctrl+ /. It will comment out all lines in that cell. Repeat the same steps to uncomment the lines of your cell.,0.9999999932034644,False,4,3926 +Thanks","I think the easiest thing will be to change the cell type to 'Markdown' with M when you don't want to run it and change back to 'Code' with Y when you do. In a short test I did, I did not lose my formatting when switching back and forth. +I don't think you can select multiple cells at once.",0.9999797400180382,False,4,3926 2015-09-07 19:16:24.353,jupyter - how to comment out cells?,"Is it possible to comment out whole cells in jupyter? I need it for this case: I have a lot of cells, and I want to run all of them, except for a few of them. I like it that my code is organized in different cells, but I don't want to go to each cell and comment out its lines. I prefer to somehow choose the cells I want to comment out, then comment them out in one go (so I could later easily uncomment them) -Thanks","I think the easiest thing will be to change the cell type to 'Markdown' with M when you don't want to run it and change back to 'Code' with Y when you do. In a short test I did, I did not lose my formatting when switching back and forth. -I don't think you can select multiple cells at once.",0.9999797400180382,False,4,3926 +Thanks",Mark the content of the cell and press Ctrl+ /. It will comment out all lines in that cell. Repeat the same steps to uncomment the lines of your cell.,0.9999999932034644,False,4,3926 2015-09-07 19:16:24.353,jupyter - how to comment out cells?,"Is it possible to comment out whole cells in jupyter? I need it for this case: I have a lot of cells, and I want to run all of them, except for a few of them. I like it that my code is organized in different cells, but I don't want to go to each cell and comment out its lines. I prefer to somehow choose the cells I want to comment out, then comment them out in one go (so I could later easily uncomment them) -Thanks","If you switch the cell to 'raw NBConvert' the code retains its formatting, while all text remains in a single font (important if you have any commented sections), so it remains readable. 'Markdown' will interpret the commented sections as headers and change the size and colour accordingly, making the cell rather messy. -On a side note I use this to interrupt the process if I want to stop it - it seems much more effective than 'Kernel --> Interrupt'.",0.999329299739067,False,4,3926 +Thanks",You can switch the cell from 'Code to 'Raw NBConvert',0.2012947653214861,False,4,3926 2015-09-08 12:42:05.337,pycharm python console autocompletion,"if I start ipython in a terminal, when I type 'im' and press TAB, the terminal will auto-complete it with 'import', but when I click python console button in the bottom of pycharm IDE, when the ipython environment shows, type 'im', press TAB, it will not give autocompletion. In PyCharm, it use pydevconsole.py to create the ipython environment, but I do not know how to change it to enable the autocompletion.","ctrl+space confuse with input language switching of Windows. need change setting of Keymap File -> Setting -> Keymap -> Main menu -> Code -> Complete -> Basic",0.2012947653214861,False,1,3927 @@ -38326,13 +38326,13 @@ Incidentally have you seen SymPy",0.0,False,1,3932 In the past, I've used TF-IDF feature vectors to build naive Bayes classifiers, but in these situations, my training set X consisted of documents of many classes, and my objective was to classify each document in Y as one of the classes seen in X. This seems like a different situation. Here, my entire training set has the same class (I have no documents that I know are not of class A), and I'm only interested in determining if documents in Y are or are not of that class. A classifier seems like the wrong route, but I'm not sure what the best next step is. Is there a different algorithm that can use that TF-IDF matrix to determine the likelihood that a document is of the same class? -FYI, I'm using scikit-learn in Python 2.7, which obviously made computing the TF-IDF matrix of X (and Y) simple.","What I think you have is an unsupervised learning application. Clustering. Using the combined X & Y dataset, generate clusters. Then overlay the X boundary; the boundary that contains all X samples. All items from Y in the X boundary can be considered X. And the X-ness of a given sample from Y is the distance from the X cluster centroid. Something like that.",1.2,True,2,3933 +FYI, I'm using scikit-learn in Python 2.7, which obviously made computing the TF-IDF matrix of X (and Y) simple.","The easiest thing to do is what was already proposed - clustering. More specifically, you extract a single feature vector from set X and then apply K-means clustering to the whole X & Y set. +ps: Be careful not to confuse k-means with kNN (k-nearest neighbors). You are able to apply only unsupervised learning methods.",0.2012947653214861,False,2,3933 2015-09-13 19:39:43.760,"If my entire training set of documents is class A, how can I use TF-IDF to find other documents of class A?","I have a collection X of documents, all of which are of class A (the only class in which I'm interested or know anything about). I also have a much larger collection Y of documents that I know nothing about. The documents in X and Y come from the same source and have similar formats and somewhat similar subject matters. I'd like to use the TF-IDF feature vectors of the documents in X to find the documents in Y that are most likely to be of class A. In the past, I've used TF-IDF feature vectors to build naive Bayes classifiers, but in these situations, my training set X consisted of documents of many classes, and my objective was to classify each document in Y as one of the classes seen in X. This seems like a different situation. Here, my entire training set has the same class (I have no documents that I know are not of class A), and I'm only interested in determining if documents in Y are or are not of that class. A classifier seems like the wrong route, but I'm not sure what the best next step is. Is there a different algorithm that can use that TF-IDF matrix to determine the likelihood that a document is of the same class? -FYI, I'm using scikit-learn in Python 2.7, which obviously made computing the TF-IDF matrix of X (and Y) simple.","The easiest thing to do is what was already proposed - clustering. More specifically, you extract a single feature vector from set X and then apply K-means clustering to the whole X & Y set. -ps: Be careful not to confuse k-means with kNN (k-nearest neighbors). You are able to apply only unsupervised learning methods.",0.2012947653214861,False,2,3933 +FYI, I'm using scikit-learn in Python 2.7, which obviously made computing the TF-IDF matrix of X (and Y) simple.","What I think you have is an unsupervised learning application. Clustering. Using the combined X & Y dataset, generate clusters. Then overlay the X boundary; the boundary that contains all X samples. All items from Y in the X boundary can be considered X. And the X-ness of a given sample from Y is the distance from the X cluster centroid. Something like that.",1.2,True,2,3933 2015-09-14 19:07:36.940,SWIG: wchar_t support for Java,"I use %include wchar.i in C# and it seems to work correctly for all wchar_t values and arrays mapping to C#'s string. Swig's library for Python also contains the typemaps for wchar_t in wchar.i file. Java's library doesn't have wchar.i. What's the reason for that? And also how I can achieve type mapping from wchar_t types in C++ to String in Java?","As you are using c++, than you can try with std::wstring as it has typemaps for all: C#, Python and Java. It is in std_wstring.i",0.0,False,1,3934 2015-09-14 21:09:58.320,How can I reference libraries for ApacheSpark using IPython Notebook only?,"I'm currently playing around with the Apache Spark Service in IBM Bluemix. There is a quick start composite application (Boilerplate) consisting of the Spark Service itself, an OpenStack Swift service for the data and an IPython/Jupyter Notebook. @@ -38358,10 +38358,10 @@ Could I get some feedback/suggestions on how to implement this?","What I usually So the fullpath for the uploaded file will be something like this: site_media/media/04042018/550e8400-e29b-41d4-a716-446655440000.jpg Personally I think is best this way than having something with site_media/media/username/file.jpg because will be easier to figure out what images belong to who.",1.2,True,1,3938 +2015-09-16 14:47:13.760,How can I switch using pip between system and anaconda,"I am now using anaconda pip after I installed pip by ""conda install pip"", if I want to use system pip again, how can I make it? Or how can I switch system pip to anaconda pip?",You don't need to change your path. Just use the full path to the system pip (generally /usr/bin/pip or /usr/local/bin/pip) to use the system pip.,0.2012947653214861,False,2,3939 2015-09-16 14:47:13.760,How can I switch using pip between system and anaconda,"I am now using anaconda pip after I installed pip by ""conda install pip"", if I want to use system pip again, how can I make it? Or how can I switch system pip to anaconda pip?","Odds are that anaconda automatically edited your .bashrc so that anaconda/bin is in front of your /usr/bin folder in your $PATH variable. To check this, type echo $PATH, and the command line will return a list of directory paths. Your computer checks each of these places for pip when you type pip in the command line. It executes the first one it finds in your PATH. You can open /home/username/.bashrc with whatever text editor you choose. Wherever it adds anaconda/bin to the path, with something like export PATH=/anaconda/bin:$PATH , just replace it with export PATH=$PATH:/anaconda/bin Note though, this will change your OS to use your system python as well. Instead of all of this, you can always just use the direct path to pip when calling it. Or you can alias it using alias pip=/path/to/system/pip. And you can put that line in your .bashrc file in order to apply it whenever you login to the pc.",0.9866142981514304,False,2,3939 -2015-09-16 14:47:13.760,How can I switch using pip between system and anaconda,"I am now using anaconda pip after I installed pip by ""conda install pip"", if I want to use system pip again, how can I make it? Or how can I switch system pip to anaconda pip?",You don't need to change your path. Just use the full path to the system pip (generally /usr/bin/pip or /usr/local/bin/pip) to use the system pip.,0.2012947653214861,False,2,3939 2015-09-18 12:55:55.673,"Save multiple figures in one pdf page, matplotlib","I'm trying to get my figures in just one pdf page, but I don't know how to do this. I found out that it's possible to save multiple figures in a pdf file with 'matplotlib.backends.backend_pdf', but it doesn't work for just one page. Has anyone any ideas ? Convert the figures to just one figure ?",The PDF backend makes one page per figure. Use subplots to get multiple plots into one figure and they'll all show up together on one page of the PDF.,0.0,False,1,3940 2015-09-18 18:45:29.490,Copy database from one server to another server + trigger python script on a database event,"I've a read-only access to a database server dbserver1. I need to store the result set generated from my query running on dbserver1 into another server of mine dbserver2. How should I go about doing that? @@ -38388,25 +38388,25 @@ If issue not resolved please check you PyCharm Interpreter path. Sometimes your I’m trying to use sklearn in pycharm. When importing sklearn I get an error that reads “Import error: No module named sklearn” The project interpreter in pycharm is set to 2.7.10 (/anaconda/bin/python.app), which should be the right one. Under default preferenes, project interpreter, I see all of anacondas packages. I've double clicked and installed the packages scikit learn and sklearn. I still receive the “Import error: No module named sklearn” -Does anyone know how to solve this problem?","For Mac OS: -PyCharm --> Preferences --> Project Interpreter --> Double Click on pip (a new window will open with search option) --> mention 'Scikit-learn' on the search bar --> Install Packages --> Once installed, close that new window --> OK on the existing window -and you are done.",0.0,False,4,3944 +Does anyone know how to solve this problem?","SOLVED: + +reinstalled Python 3.7.9 (not the latet) +installed numpy 1.17.5 (not the latest) +installed scikit-learn (latest) + +sklearn works now!",0.0509761841073563,False,4,3944 2015-09-20 02:07:57.813,Getting PyCharm to import sklearn,"Beginner here. I’m trying to use sklearn in pycharm. When importing sklearn I get an error that reads “Import error: No module named sklearn” The project interpreter in pycharm is set to 2.7.10 (/anaconda/bin/python.app), which should be the right one. Under default preferenes, project interpreter, I see all of anacondas packages. I've double clicked and installed the packages scikit learn and sklearn. I still receive the “Import error: No module named sklearn” -Does anyone know how to solve this problem?","please notice that, in the packages search 'Scikit-learn', instead 'sklearn'",0.3869120172231254,False,4,3944 +Does anyone know how to solve this problem?","For Mac OS: +PyCharm --> Preferences --> Project Interpreter --> Double Click on pip (a new window will open with search option) --> mention 'Scikit-learn' on the search bar --> Install Packages --> Once installed, close that new window --> OK on the existing window +and you are done.",0.0,False,4,3944 2015-09-20 02:07:57.813,Getting PyCharm to import sklearn,"Beginner here. I’m trying to use sklearn in pycharm. When importing sklearn I get an error that reads “Import error: No module named sklearn” The project interpreter in pycharm is set to 2.7.10 (/anaconda/bin/python.app), which should be the right one. Under default preferenes, project interpreter, I see all of anacondas packages. I've double clicked and installed the packages scikit learn and sklearn. I still receive the “Import error: No module named sklearn” -Does anyone know how to solve this problem?","SOLVED: - -reinstalled Python 3.7.9 (not the latet) -installed numpy 1.17.5 (not the latest) -installed scikit-learn (latest) - -sklearn works now!",0.0509761841073563,False,4,3944 +Does anyone know how to solve this problem?","please notice that, in the packages search 'Scikit-learn', instead 'sklearn'",0.3869120172231254,False,4,3944 2015-09-20 13:45:10.417,ImportError after successful pip installation,"I have successfully installed a library with pip install . But when I try to import it, python raises ImportError: No module named . Why do I get this error and how can I use the installed library?","A couple more points: Check to see if you're installing the library into the virtualenv that you want to use. @@ -38509,11 +38509,11 @@ I can not find any remaining files connected to any sort of Python in my PC. My 2015-09-29 02:28:48.730,spyder python how to re-open Variable Explorer,"I accidentally closed the variable explorer on my Pythone(Spyder)... Does anyone know how I can reopen it? If I must reinstall the program, then I will but I just want to see if there is a way. -Thank you!",Go to View/Panes and select Variable Explorer.,1.2,True,4,3959 +Thank you!",Just use combination of shift+ctrl+v,0.5457054096481145,False,4,3959 2015-09-29 02:28:48.730,spyder python how to re-open Variable Explorer,"I accidentally closed the variable explorer on my Pythone(Spyder)... Does anyone know how I can reopen it? If I must reinstall the program, then I will but I just want to see if there is a way. -Thank you!",Just use combination of shift+ctrl+v,0.5457054096481145,False,4,3959 +Thank you!",Go to View/Panes and select Variable Explorer.,1.2,True,4,3959 2015-09-29 02:28:48.730,spyder python how to re-open Variable Explorer,"I accidentally closed the variable explorer on my Pythone(Spyder)... Does anyone know how I can reopen it? If I must reinstall the program, then I will but I just want to see if there is a way. @@ -38611,13 +38611,13 @@ Thanks","If there is no limit to the length of the string argument for launching Maybe it's not exactly what you're looking for but on the other hand you should not rely on a predefined sleep time.",0.0,False,1,3972 2015-10-09 17:06:01.240,How to load big datasets like million song dataset into BigData HDFS or Hbase or Hive?,"I have downloaded a subset of million song data set which is about 2GB. However, the data is broken down into folders and sub folders. In the sub-folder they are all in several 'H5 file' format. I understand it can be read using Python. But I do not know how to extract and load then into HDFS so I can run some data analysis in Pig. -Do I extract them as CSV and load to Hbase or Hive ? It would help if someone can point me to right resource.","If it's already in the CSV or any format on the linux file system, that PIG can understand, just do a hadoop fs -copyFromLocal to -If you want to read/process the raw H5 File format using Python on HDFS, look at hadoop-streaming (map/reduce) -Python can handle 2GB on a decent linux system- not sure if you need hadoop for it.",0.2012947653214861,False,2,3973 -2015-10-09 17:06:01.240,How to load big datasets like million song dataset into BigData HDFS or Hbase or Hive?,"I have downloaded a subset of million song data set which is about 2GB. However, the data is broken down into folders and sub folders. In the sub-folder they are all in several 'H5 file' format. I understand it can be read using Python. But I do not know how to extract and load then into HDFS so I can run some data analysis in Pig. Do I extract them as CSV and load to Hbase or Hive ? It would help if someone can point me to right resource.","Don't load such amount of small files into HDFS. Hadoop doesn't handle well lots of small files. Each small file will incur in overhead because the block size (usually 64MB) is much bigger. I want to do it myself, so I'm thinking of solutions. The million song dataset files don't have more than 1MB. My approach will be to aggregate data somehow before importing into HDFS. The blog post ""The Small Files Problem"" from Cloudera may shed some light.",0.0,False,2,3973 +2015-10-09 17:06:01.240,How to load big datasets like million song dataset into BigData HDFS or Hbase or Hive?,"I have downloaded a subset of million song data set which is about 2GB. However, the data is broken down into folders and sub folders. In the sub-folder they are all in several 'H5 file' format. I understand it can be read using Python. But I do not know how to extract and load then into HDFS so I can run some data analysis in Pig. +Do I extract them as CSV and load to Hbase or Hive ? It would help if someone can point me to right resource.","If it's already in the CSV or any format on the linux file system, that PIG can understand, just do a hadoop fs -copyFromLocal to +If you want to read/process the raw H5 File format using Python on HDFS, look at hadoop-streaming (map/reduce) +Python can handle 2GB on a decent linux system- not sure if you need hadoop for it.",0.2012947653214861,False,2,3973 2015-10-10 17:42:52.037,PYGTK Resizing permissions,"I want to set a window's size, and then be able to resize it while the program is running. I've been able to make the window large, but I can't resize it smaller than the original set size. For a different project, I would also like to know how to make it so the window is not resizable at all.","For the first question: Gtk.Window.resize(width, height) should work. If you use set_size_request(width, height), you cannot resize your window smaller than these values. For the second question: Gtk.Window.set_resizable(False)",1.2,True,1,3974 2015-10-11 18:15:23.837,Run Code In Atom Code Editor,"I have read numerous articles about running code in the Atom code editor, however, I cannot seem to understand how this can be done. Could anyone explain it in simpler terms? @@ -38642,9 +38642,9 @@ Usually, it's used in TLS (SSL), SSH, signing updates, etc. 3. Hashing (it's not really encryption) It's the simplest. With hashing, you produce some spring that can't be reverted, but with a rule that same data will produce the same hash. So you could just pick the most suitable method and try to find appropriate package in the language you use.",-0.3869120172231254,False,1,3976 +2015-10-12 20:02:58.837,Missing 'Notebooks' tab,"I have installed iPython Notebook as a component of my Anaconda installation. To become familiar with using iPython Notebook I started through an introductory tutorial and immediately ran into a discrepancy. When I open the notebook the tutorial shows I should have three tabs across the top labelled 'Notebooks', 'Running' and 'Clusters'. Instead I have 'Files', 'Running' and 'Clusters'. I cannot figure out how to switch the Files tab to the Notebooks tab...or is the Files tab correct and is the tutorial out-of-date? I would much prefer to just have the Notebooks view as listing all the file folders just gets in the way. Can someone tell me how to swap out the Files tab for the Notebooks tab?","To start the notebook in notebook server 4.2.1, go to file tab and on the top right side, you will see new drop down menu. Click on the python[root] and it should start the new notebook.",0.0,False,2,3977 2015-10-12 20:02:58.837,Missing 'Notebooks' tab,"I have installed iPython Notebook as a component of my Anaconda installation. To become familiar with using iPython Notebook I started through an introductory tutorial and immediately ran into a discrepancy. When I open the notebook the tutorial shows I should have three tabs across the top labelled 'Notebooks', 'Running' and 'Clusters'. Instead I have 'Files', 'Running' and 'Clusters'. I cannot figure out how to switch the Files tab to the Notebooks tab...or is the Files tab correct and is the tutorial out-of-date? I would much prefer to just have the Notebooks view as listing all the file folders just gets in the way. Can someone tell me how to swap out the Files tab for the Notebooks tab?","The three tabs ""Files"", ""Running"" and ""Clusters"" should be correct. The ""Running"" tab has the active notebooks listed. Yes, perhaps it was an older tutorial. Do you have a link?",0.0,False,2,3977 -2015-10-12 20:02:58.837,Missing 'Notebooks' tab,"I have installed iPython Notebook as a component of my Anaconda installation. To become familiar with using iPython Notebook I started through an introductory tutorial and immediately ran into a discrepancy. When I open the notebook the tutorial shows I should have three tabs across the top labelled 'Notebooks', 'Running' and 'Clusters'. Instead I have 'Files', 'Running' and 'Clusters'. I cannot figure out how to switch the Files tab to the Notebooks tab...or is the Files tab correct and is the tutorial out-of-date? I would much prefer to just have the Notebooks view as listing all the file folders just gets in the way. Can someone tell me how to swap out the Files tab for the Notebooks tab?","To start the notebook in notebook server 4.2.1, go to file tab and on the top right side, you will see new drop down menu. Click on the python[root] and it should start the new notebook.",0.0,False,2,3977 2015-10-14 13:37:37.730,SocketRocket (iOS) : How to identify whom user are chatting with another?,"I would like to create multiple sockets between all users. So how can i pass key and ID such as the server is divided in seprated windows. Thank You.","You do exactly that: you [can] pass around keys and make them show up in separate windows. @@ -38690,11 +38690,11 @@ If no, is there any solution to the problem I am trying to solve? I tried kick- 2015-10-17 14:11:08.787,"Making an alias for an attribute field, to be used in a django queryset","In Django, how does one give an attribute field name an alias that can be used to manipulate a queryset? Background: I have a queryset where the underlying model has an auto-generating time field called ""submitted_on"". I want to use an alias for this time field (i.e. ""date""). Why? Because I will concatenate this queryset with another one (with the same underlying model), and then order_by('-date'). Needless to say, this latter qset already has a 'date' attribute (attached via annotate()). How do I make a 'date' alias for the former queryset? Currently, I'm doing something I feel is an inefficient hack: qset1 = qset1.annotate(date=Max('submitted_on')) -I'm using Django 1.5 and Python 2.7.","Even if you could do this, it wouldn't help solve your ultimate problem. You can't use order_by on concatenated querysets from different models; that can't possibly work, since it is a request for the database to do an ORDER BY on the query.",0.0,False,2,3984 +I'm using Django 1.5 and Python 2.7.","It seems qset1 = qset1.annotate(date=Max('submitted_on')) is the closest I have right now. This, or using exclude(). I'll update if I get a better solution. Of course other experts from SO are welcome to chime in with their own answers.",1.2,True,2,3984 2015-10-17 14:11:08.787,"Making an alias for an attribute field, to be used in a django queryset","In Django, how does one give an attribute field name an alias that can be used to manipulate a queryset? Background: I have a queryset where the underlying model has an auto-generating time field called ""submitted_on"". I want to use an alias for this time field (i.e. ""date""). Why? Because I will concatenate this queryset with another one (with the same underlying model), and then order_by('-date'). Needless to say, this latter qset already has a 'date' attribute (attached via annotate()). How do I make a 'date' alias for the former queryset? Currently, I'm doing something I feel is an inefficient hack: qset1 = qset1.annotate(date=Max('submitted_on')) -I'm using Django 1.5 and Python 2.7.","It seems qset1 = qset1.annotate(date=Max('submitted_on')) is the closest I have right now. This, or using exclude(). I'll update if I get a better solution. Of course other experts from SO are welcome to chime in with their own answers.",1.2,True,2,3984 +I'm using Django 1.5 and Python 2.7.","Even if you could do this, it wouldn't help solve your ultimate problem. You can't use order_by on concatenated querysets from different models; that can't possibly work, since it is a request for the database to do an ORDER BY on the query.",0.0,False,2,3984 2015-10-20 08:01:24.123,Selenium on server,"I'm quite new to whole Selenim thing and I have a simple question. When I run tests (Django application) on my local machine, everything works great. But how this should be done on server? There is no X, so how can I start up webdriver there? What's the common way? Thanks",I suggest you use a continuous integration solution like Jenkins to run your tests periodically.,0.0,False,1,3985 @@ -38704,11 +38704,11 @@ I have the contour boundary coordinates, but I don't know how to retrieve the pi Thanks!","Answer from @rayryeng is excellent! One small thing from my implementation is: The np.where() returns a tuple, which contains an array of row indices and an array of column indices. So, pts[0] includes a list of row indices, which correspond to height of the image, pts[1] includes a list of column indices, which correspond to the width of the image. The img.shape returns (rows, cols, channels). So I think it should be img[pts[0], pts[1]] to slice the ndarray behind the img.",0.3869120172231254,False,1,3986 -2015-10-20 11:58:18.313,How to verify that we have logged in correctly to a website using requests in python?,I used requests to login to a website using the correct credentials initially. Then I tried the same with some invalid username and password. I was still getting response status of 200. I then understood that the response status tells if the corresponding webpage has been hit or not. So now my doubt is how to verify if I have really logged in to the website using correct credentials,"What status code the site responds with depends entirely on their implementation; you're more likely to get a non-200 response if you're attempting to log in to a web service. If a login attempt yielded a non-200 response on a normal website, it'd require a special handler on their end, as opposed to a 200 response with a normal page prompting you (presumably a human user, not a script) with a visual cue indicating login failure. -If the site you're logging into returns a 200 regardless of success or failure, you may need to use something like lxml or BeautifulSoup to look for indications of success or failure (which presumably you'll be using already to process whatever it is you're logging in to access).",0.0,False,2,3987 2015-10-20 11:58:18.313,How to verify that we have logged in correctly to a website using requests in python?,I used requests to login to a website using the correct credentials initially. Then I tried the same with some invalid username and password. I was still getting response status of 200. I then understood that the response status tells if the corresponding webpage has been hit or not. So now my doubt is how to verify if I have really logged in to the website using correct credentials,"HTTP status codes are usually meant for the browsers, or in case of APIs for the client talking to the server. For normal web sites, using status codes for semantical error information is not really useful. Overusing the status codes there could even cause the browser to not render responses correctly. So for normal HTML responses, you would usually expect a code 200 for almost everything. In order to check for errors, you will then have to check the—application specific—error output from the HTML response. A good way to find out about these signs is to just try logging in from the browser with invalid credentials and then check what output is rendered. Or as many sites also show some kind of user menu once you’re logged in, check for its existence to figure out if you’re logged in. And when it’s not there, the login probably failed.",1.2,True,2,3987 +2015-10-20 11:58:18.313,How to verify that we have logged in correctly to a website using requests in python?,I used requests to login to a website using the correct credentials initially. Then I tried the same with some invalid username and password. I was still getting response status of 200. I then understood that the response status tells if the corresponding webpage has been hit or not. So now my doubt is how to verify if I have really logged in to the website using correct credentials,"What status code the site responds with depends entirely on their implementation; you're more likely to get a non-200 response if you're attempting to log in to a web service. If a login attempt yielded a non-200 response on a normal website, it'd require a special handler on their end, as opposed to a 200 response with a normal page prompting you (presumably a human user, not a script) with a visual cue indicating login failure. +If the site you're logging into returns a 200 regardless of success or failure, you may need to use something like lxml or BeautifulSoup to look for indications of success or failure (which presumably you'll be using already to process whatever it is you're logging in to access).",0.0,False,2,3987 2015-10-20 15:52:07.307,Handling a literal space in a filename,"I have problem with os.access(filename, os.R_OK) when file is an absolute path on a Linux system with space in the filename. I have tried many ways of quoting the space, from ""'"" + filename + ""'"" to filename.replace(' ', '\\ ') but it doesn't work. How can I escape the filename so my shell knows how to access it? In terminal I would address it as '/home/abc/LC\ 1.a'","You don't need to (and shouldn't) escape the space in the file name. When you are working with a command line shell, you need to escape the space because that's how the shell tokenizes the command and its arguments. Python, however, is expecting a file name, so if the file name has a space, you just include the space.",1.2,True,1,3988 2015-10-22 05:22:08.870,how to list all users who tweeted a given keyword using twitter api and tweepy,"How to list name of users who tweeted with given keyword along with count of tweets from them ? @@ -38722,10 +38722,10 @@ I'm using PhoneGap (JavaScript/JQuery) to make the phone app if that helps. I ca First Attempt: I was thinking that maybe I POST to the server and get some kind of Authentication Token or something. Maybe there is some Javascript code that hashes my password using the same algorithm so that I can compare it to the database. Thanks","You would need to either expose the django token in the settings file so that it can be accessed via jquery, or that decorator wont be accessible via mobile. Alternatively, you can start using something like oauth",0.0,False,1,3990 +2015-10-24 17:19:58.503,How to get token value while sending post requests,"I am trying to extract the data from webpage after log in. To log in website, i can see the token (authenticity_token) in Form Data section. It seems, token generating automatically.I am trying to get token values but no luck.Please anyone help me on this,how to get the token value while sending the post requests.",You need to get the response from the page then regex match for token.,0.0,False,2,3991 2015-10-24 17:19:58.503,How to get token value while sending post requests,"I am trying to extract the data from webpage after log in. To log in website, i can see the token (authenticity_token) in Form Data section. It seems, token generating automatically.I am trying to get token values but no luck.Please anyone help me on this,how to get the token value while sending the post requests.","token value is stored in the cookie file..check the cookie file and extract the value from it.. for example,a cookie file after login contain jsession ID=A01~xxxxxxx where 'xxxxxxx' is the token value..extract this value..and post this value",0.0,False,2,3991 -2015-10-24 17:19:58.503,How to get token value while sending post requests,"I am trying to extract the data from webpage after log in. To log in website, i can see the token (authenticity_token) in Form Data section. It seems, token generating automatically.I am trying to get token values but no luck.Please anyone help me on this,how to get the token value while sending the post requests.",You need to get the response from the page then regex match for token.,0.0,False,2,3991 2015-10-25 10:41:05.717,How to organize groups in Django?,"I am currently learning how to use Django. I want to make a web app where you as a user can join groups. These groups have content that just members of this group should be able to see. I learned about users, groups and a bit of authentication. My first impression is, that this is more about the administration of the website itself and I cannot really believe that I can solve my idea with it. I just want to know if thats the way to go in Django. I probably have to create groups in Django that have the right to see the content of the group on the website. But that means that everytime a group is created, I have to create a django group. Is that an overkill or the right way?","Groups in django (django.contrib.auth) are used to specify certain rights of viewing content mainly in the admin to certain users. I think your group functionality might be more custom than this and that you're better of creating your own group models, and making your own user and group management structure that suits the way your website is used better.",0.0,False,1,3992 @@ -38743,14 +38743,14 @@ Both layers do not know anything about each other (only protocol like list of kn I've copied the Python code on the MS Azure Machine Learning Batch patch for the ML web-service into an Anaconda Notebook. I've replaced all the place holders in the script with actual values as noted in the scripts comments. When I run the script I get the error: ""NameError: global name 'BlobService' is not defined"" at the script line ""blob_service = BlobService(account_name=storage_account_name, account_key=storage_account_key)"". -Since the ""from azure.storage import *"" line at the beginning of the script does not generate an error I'm unclear as to what the problem is and don't know how to fix it. Can anyone point me to what I should correct?","It's been a long time since I did any Python, but BlobStorage is in the azure.storage.blob namespace I believe. -So I don't think your from azure.storage import * is pulling it in. -If you've got a code sample in a book which shows otherwise it may just be out of date.",0.0,False,3,3994 +Since the ""from azure.storage import *"" line at the beginning of the script does not generate an error I'm unclear as to what the problem is and don't know how to fix it. Can anyone point me to what I should correct?","James, I figured it out. I just changed from azure.storage import * to azure.storage.blob import * and it seems to be working.",0.1016881243684853,False,3,3994 2015-10-26 19:25:00.217,How do I fix the 'BlobService' is not defined' error,"I've installed the azure SDK for Python (pip install azure). I've copied the Python code on the MS Azure Machine Learning Batch patch for the ML web-service into an Anaconda Notebook. I've replaced all the place holders in the script with actual values as noted in the scripts comments. When I run the script I get the error: ""NameError: global name 'BlobService' is not defined"" at the script line ""blob_service = BlobService(account_name=storage_account_name, account_key=storage_account_key)"". -Since the ""from azure.storage import *"" line at the beginning of the script does not generate an error I'm unclear as to what the problem is and don't know how to fix it. Can anyone point me to what I should correct?","James, I figured it out. I just changed from azure.storage import * to azure.storage.blob import * and it seems to be working.",0.1016881243684853,False,3,3994 +Since the ""from azure.storage import *"" line at the beginning of the script does not generate an error I'm unclear as to what the problem is and don't know how to fix it. Can anyone point me to what I should correct?","It's been a long time since I did any Python, but BlobStorage is in the azure.storage.blob namespace I believe. +So I don't think your from azure.storage import * is pulling it in. +If you've got a code sample in a book which shows otherwise it may just be out of date.",0.0,False,3,3994 2015-10-26 19:25:00.217,How do I fix the 'BlobService' is not defined' error,"I've installed the azure SDK for Python (pip install azure). I've copied the Python code on the MS Azure Machine Learning Batch patch for the ML web-service into an Anaconda Notebook. I've replaced all the place holders in the script with actual values as noted in the scripts comments. @@ -38768,20 +38768,13 @@ Once you have configured your interpreter in PyDev then you can change the inter Right click on your project>Properties On the left pan click PyDev-Interpreter.In that select the name of the PythonInterpreter(Py3.5) which you previously configured and you can also select the grammar version.",1.2,True,1,3995 2015-10-29 15:26:38.267,removing an element from a linked list in python,"I was wondering if any of you could give me a walk through on how to remove an element from a linked list in python, I'm not asking for code but just kinda a pseudo algorithm in english. for example I have the linked list of -1 -> 2 -> 2 -> 3 -> 4 and I want to remove one of the 2's how would i do that? I thought of traversing through the linked list, checking to see if the data of one of the nodes is equal to the data of the node after it, if it is remove it. But I'm having trouble on the removing part. Thanks!","You don't need to ""delete"" the node, just ""skip"" it. That is, change Node1's next member to the second Node2. -Edit your question if you would like specific code examples (which are the norm for this site).",0.0,False,2,3996 -2015-10-29 15:26:38.267,removing an element from a linked list in python,"I was wondering if any of you could give me a walk through on how to remove an element from a linked list in python, I'm not asking for code but just kinda a pseudo algorithm in english. for example I have the linked list of 1 -> 2 -> 2 -> 3 -> 4 and I want to remove one of the 2's how would i do that? I thought of traversing through the linked list, checking to see if the data of one of the nodes is equal to the data of the node after it, if it is remove it. But I'm having trouble on the removing part. Thanks!","You can do something like: if element.next.value == element.value: element.next = element.next.next Just be carefull to free the memory if you are programing this in C/C++ or other language that does not have GC",0.0,False,2,3996 -2015-10-29 15:41:06.030,tkinter opencv and numpy in windows with python2.7,"I want to use ""tkinter"", ""opencv"" (cv2) and ""numpy"" in windows(8 - 64 bit and x64) with python2.7 - the same as I have running perfectly well in Linux (Elementary and DistroAstro) on other machines. I've downloaded the up to date Visual Studio and C++ compiler and installed these, as well as the latest version of PIP following error messages with the first attempts with PIP and numpy - -first I tried winpython, which already has numpy present but this comes without tkinter, although openCV would install. I don't want to use qt. -so I tried vanilla Python, which installs to Python27. Numpy won't install with PIP or EasyInstall (unless it takes over an hour -same for SciPy), and the -.exe installation route for Numpy bombs becausee its looking for Python2.7 (not Python27). openCV won't install with PIP (""no suitable version"") -extensive searches haven't turned up an answer as to how to get a windows Python 2.7.x environment with all three of numpy, tkinter and cv2 working. - -Any help would be appreciated!","small remark: WinPython has tkinter, as it's included by Python Interpreter itself",0.0,False,2,3997 +2015-10-29 15:26:38.267,removing an element from a linked list in python,"I was wondering if any of you could give me a walk through on how to remove an element from a linked list in python, I'm not asking for code but just kinda a pseudo algorithm in english. for example I have the linked list of +1 -> 2 -> 2 -> 3 -> 4 and I want to remove one of the 2's how would i do that? I thought of traversing through the linked list, checking to see if the data of one of the nodes is equal to the data of the node after it, if it is remove it. But I'm having trouble on the removing part. Thanks!","You don't need to ""delete"" the node, just ""skip"" it. That is, change Node1's next member to the second Node2. +Edit your question if you would like specific code examples (which are the norm for this site).",0.0,False,2,3996 2015-10-29 15:41:06.030,tkinter opencv and numpy in windows with python2.7,"I want to use ""tkinter"", ""opencv"" (cv2) and ""numpy"" in windows(8 - 64 bit and x64) with python2.7 - the same as I have running perfectly well in Linux (Elementary and DistroAstro) on other machines. I've downloaded the up to date Visual Studio and C++ compiler and installed these, as well as the latest version of PIP following error messages with the first attempts with PIP and numpy first I tried winpython, which already has numpy present but this comes without tkinter, although openCV would install. I don't want to use qt. @@ -38795,6 +38788,13 @@ In IDLE I then get: import numpy numpy.version '1.10.1'",0.0,False,2,3997 +2015-10-29 15:41:06.030,tkinter opencv and numpy in windows with python2.7,"I want to use ""tkinter"", ""opencv"" (cv2) and ""numpy"" in windows(8 - 64 bit and x64) with python2.7 - the same as I have running perfectly well in Linux (Elementary and DistroAstro) on other machines. I've downloaded the up to date Visual Studio and C++ compiler and installed these, as well as the latest version of PIP following error messages with the first attempts with PIP and numpy + +first I tried winpython, which already has numpy present but this comes without tkinter, although openCV would install. I don't want to use qt. +so I tried vanilla Python, which installs to Python27. Numpy won't install with PIP or EasyInstall (unless it takes over an hour -same for SciPy), and the -.exe installation route for Numpy bombs becausee its looking for Python2.7 (not Python27). openCV won't install with PIP (""no suitable version"") +extensive searches haven't turned up an answer as to how to get a windows Python 2.7.x environment with all three of numpy, tkinter and cv2 working. + +Any help would be appreciated!","small remark: WinPython has tkinter, as it's included by Python Interpreter itself",0.0,False,2,3997 2015-10-29 17:14:21.793,Padding python pivot tables with 0,"I have a pivot table which has an index of dates ranging from 01-01-2014 to 12-31-2015. I would like the index to range from 01-01-2013 to 12-31-2016 and do not know how without modifying the underlying dataset by inserting a row in my pandas dataframe with those dates in the column I want to use as my index for the pivot table. Is there a way to accomplish this wihtout modifying the underlying dataset?","I'm going to be general here, since there was no sample code or data provided. Let's say your original dataframe is called df and has columns Date and Sales. I would try creating a list that has all dates from 01-01-2014 to 12-31-2015. Let's call this list dates. I would also create an empty list called sales (i.e. sales = []). At the end of this workflow, sales should include data from dt['Sales'] AND placeholders for dates that are not within the data frame. In your case, these placeholders will be 0. In my answer, the names of the columns in the dataframe are capitalized; names of lists start with a lower case. @@ -38976,9 +38976,9 @@ pot2po -t af template af update_store --project=myproject --language=af You can automate that in a script to iterate through all languages. Use list_languages --project=myproject to get a list of all the active languages for that project.",1.2,True,1,4019 -2015-11-10 19:29:02.980,Visual Studio 2015 IronPython,"So recently I've thought about trying IronPython. I've got my GUI configured, I got my .py file. I click Start in Visual Studio, and that thing pops up: The environment ""Unknown Python 2.7 [...]"". I have the environment in Solution Explorer set to the Unknown Python 2.7 and I have no idea how to change it. Installed 2.7, 3.5, IronPyhon 2.7 and refreshed them in Python Environments tab","Generally the best approach to handle this is to right click ""Python Environments"" in Solution Explorer, then select ""Add/remove environments"" and change what you have added in there.",0.296905446847765,False,2,4020 2015-11-10 19:29:02.980,Visual Studio 2015 IronPython,"So recently I've thought about trying IronPython. I've got my GUI configured, I got my .py file. I click Start in Visual Studio, and that thing pops up: The environment ""Unknown Python 2.7 [...]"". I have the environment in Solution Explorer set to the Unknown Python 2.7 and I have no idea how to change it. Installed 2.7, 3.5, IronPyhon 2.7 and refreshed them in Python Environments tab","Go to Project -> Properties -> General -> Interpreter Set the Interpreter to IronPython 2.7 (you may need to install it).",0.1016881243684853,False,2,4020 +2015-11-10 19:29:02.980,Visual Studio 2015 IronPython,"So recently I've thought about trying IronPython. I've got my GUI configured, I got my .py file. I click Start in Visual Studio, and that thing pops up: The environment ""Unknown Python 2.7 [...]"". I have the environment in Solution Explorer set to the Unknown Python 2.7 and I have no idea how to change it. Installed 2.7, 3.5, IronPyhon 2.7 and refreshed them in Python Environments tab","Generally the best approach to handle this is to right click ""Python Environments"" in Solution Explorer, then select ""Add/remove environments"" and change what you have added in there.",0.296905446847765,False,2,4020 2015-11-11 07:23:05.910,"Python, Django - how to store http requests in the middleware?","It might be that this question sounds pretty silly but I can not figure out how to do this I believe the simplest issue (because just start learning Django). What I know is I should create a middleware file and connect it to the settings. Than create a view and a *.html page that will show these requests and write it to the urls. @@ -39253,12 +39253,12 @@ It would be nice if both columns are sorted as shown in the desired output, how I am trying to step over a line with list comprehension, but instead of moving me to the next line, pycharm is incrementing the loop in 1 iteration. any ideas how to move to the next line without pushing F8 3000 times? -thanks!",Set a breakpoint at the next line of code after the comprehension and then hit play again.,0.0,False,2,4057 +thanks!",PyCharm has 'Run to Cursor' option - just move your cursor one line down and hit it.,0.3869120172231254,False,2,4057 2015-12-07 14:14:53.070,how to step over list comprehension in pycharm?,"I am new to Python and Pycharm, I am trying to step over a line with list comprehension, but instead of moving me to the next line, pycharm is incrementing the loop in 1 iteration. any ideas how to move to the next line without pushing F8 3000 times? -thanks!",PyCharm has 'Run to Cursor' option - just move your cursor one line down and hit it.,0.3869120172231254,False,2,4057 +thanks!",Set a breakpoint at the next line of code after the comprehension and then hit play again.,0.0,False,2,4057 2015-12-07 14:30:14.380,Can't retrive data from webpage for onchange fields in odoo?,"I have used xml-rpc in my Odoo ERP so whenever some user inputs data in external website that will come to my ERP. Everything working fine i.e. getting data which user inputs from website like personal details, But the problem is i've some onchange selection fields in custom model.for that data is not getting updated over here. Got my point?? I would like to know how to resolve this issue. At least i need to know someone's approach. Thanks in advance","Chandu, Well you can call on_change method on through xml-rpc which will give you desire data and you can pass those data back to the server to store correct values. @@ -39280,6 +39280,10 @@ Isn't a generator a kind of iterator? If not, how do I make an iterator from it? Looking at the library code, it seems to simply iterate over sentences like for x in enumerate(sentences), which works just fine with my generator. What is causing the error then?","It seems gensim throws a misleading error message. Gensim wants to iterate over your data multiple times. Most libraries just build a list from the input, so the user doesn't have to care about supplying a multiple iterable sequence. Of course, generating an in-memory list can be very resource-consuming, while iterating over a file for example, can be done without storing the whole file in memory. In your case, just changing the generator to a list comprehesion should solve the problem.",0.296905446847765,False,1,4062 +2015-12-08 23:23:56.967,How to use 3to2,"I have to convert some of my python 3 files to 2 for class, but I can't figure out how to use 3to2. I did pip install 3to2 and it said it was successful. It install 2 folders 3to2-1.1.1.dist-info and lib3to2. I have tried doing python 3to2 file_name, `python lib3to2 file_name' I also tried changing the folder to 3to2.py like I saw on an answer on someone else question still didn't work. What is the correct way to use this?","In MacOS, I have anaconda package manager installed, so after pip install 3to2 I found executable at /Users//anaconda3/bin/3to2 +Run ./3to2 to convert stdin (-), files or directories given as arguments. By default, the tool outputs a unified diff-formatted patch on standard output and a “what was changed” summary on standard error, but the -w option can be given to write back converted files, creating .bak-named backup files. +In Windows its in C:\Python27\Scripts\ as a file 3to2 +Run by invoking python python 3to2 to display the diff on console or with -w option to write back the converted to same file.",0.0,False,2,4063 2015-12-08 23:23:56.967,How to use 3to2,"I have to convert some of my python 3 files to 2 for class, but I can't figure out how to use 3to2. I did pip install 3to2 and it said it was successful. It install 2 folders 3to2-1.1.1.dist-info and lib3to2. I have tried doing python 3to2 file_name, `python lib3to2 file_name' I also tried changing the folder to 3to2.py like I saw on an answer on someone else question still didn't work. What is the correct way to use this?","Had the same question and here's how I solved it: pip install 3to2 @@ -39287,10 +39291,6 @@ rename 3to2 to 3to2.py (found in the Scripts folder of the Python directory) Open a terminal window and run 3to2.py -w [file] NB: You will either have to be in the same folder as 3to2.py or provide the full path to it when you try to run it. Same goes for the path to the file you want to convert. The easy way around this is to copy 3to2.py into the folder your py file is in and just run the command inside that folder. Use 3to2.py --help for info on how the script works.",0.9918597245682076,False,2,4063 -2015-12-08 23:23:56.967,How to use 3to2,"I have to convert some of my python 3 files to 2 for class, but I can't figure out how to use 3to2. I did pip install 3to2 and it said it was successful. It install 2 folders 3to2-1.1.1.dist-info and lib3to2. I have tried doing python 3to2 file_name, `python lib3to2 file_name' I also tried changing the folder to 3to2.py like I saw on an answer on someone else question still didn't work. What is the correct way to use this?","In MacOS, I have anaconda package manager installed, so after pip install 3to2 I found executable at /Users//anaconda3/bin/3to2 -Run ./3to2 to convert stdin (-), files or directories given as arguments. By default, the tool outputs a unified diff-formatted patch on standard output and a “what was changed” summary on standard error, but the -w option can be given to write back converted files, creating .bak-named backup files. -In Windows its in C:\Python27\Scripts\ as a file 3to2 -Run by invoking python python 3to2 to display the diff on console or with -w option to write back the converted to same file.",0.0,False,2,4063 2015-12-09 01:16:05.610,How could I find TCP retransmission and packet loss from pcap file?,"The data was captured from LTE network. I don't know how to recognize count TCP retransmission of a single TCP flow, using @@ -39308,9 +39308,12 @@ try to change your default python version instead removing it. you can do this t 2015-12-10 10:04:59.947,"Ubuntu, how do you remove all Python 3 but not 2","I have recently get hold of a RackSpace Ubuntu server and it has pythons all over the place: iPython in 3.5, Pandas in 3.4 &2.7, modules I need like pyodbc etc. are only in 2,7 Therefore, I am keen to clean up the box and, as a 2.7 users, keep everything in 2.7. -So the key question is, is there a way to remove both 3.4 and 3.5 efficiently at the same time while keeping Python 2.7?","Its simple -just try: -sudo apt-get remove python3.7 or the versions that you want to remove",-0.2012947653214861,False,4,4065 +So the key question is, is there a way to remove both 3.4 and 3.5 efficiently at the same time while keeping Python 2.7?","EDIT: As pointed out in recent comments, this solution may BREAK your system. +You most likely don't want to remove python3. +Please refer to the other answers for possible solutions. +Outdated answer (not recommended) + + sudo apt-get remove 'python3.*'",0.5457054096481145,False,4,4065 2015-12-10 10:04:59.947,"Ubuntu, how do you remove all Python 3 but not 2","I have recently get hold of a RackSpace Ubuntu server and it has pythons all over the place: iPython in 3.5, Pandas in 3.4 &2.7, modules I need like pyodbc etc. are only in 2,7 Therefore, I am keen to clean up the box and, as a 2.7 users, keep everything in 2.7. @@ -39320,12 +39323,9 @@ Arguably, I can install virtualenv but me and my colleagues are only using 2.7. 2015-12-10 10:04:59.947,"Ubuntu, how do you remove all Python 3 but not 2","I have recently get hold of a RackSpace Ubuntu server and it has pythons all over the place: iPython in 3.5, Pandas in 3.4 &2.7, modules I need like pyodbc etc. are only in 2,7 Therefore, I am keen to clean up the box and, as a 2.7 users, keep everything in 2.7. -So the key question is, is there a way to remove both 3.4 and 3.5 efficiently at the same time while keeping Python 2.7?","EDIT: As pointed out in recent comments, this solution may BREAK your system. -You most likely don't want to remove python3. -Please refer to the other answers for possible solutions. -Outdated answer (not recommended) - - sudo apt-get remove 'python3.*'",0.5457054096481145,False,4,4065 +So the key question is, is there a way to remove both 3.4 and 3.5 efficiently at the same time while keeping Python 2.7?","Its simple +just try: +sudo apt-get remove python3.7 or the versions that you want to remove",-0.2012947653214861,False,4,4065 2015-12-10 23:32:40.847,Python Twistd MySQL - Get Updated Row id (not inserting),"Python, Twistd and SO newbie. I am writing a program that organises seating across multiple rooms. I have only included related columns from the tables below. Basic Mysql tables @@ -39508,12 +39508,14 @@ Each commit is a synchronous/blocking transaction so one request will get in bef Doesn't this break the purpose of the Etag? The only fool-proof solution I can think of is to also make the database perform the check, in the update query for example. Am I missing something? -P.S Tagged as Python due to the frameworks used but this should be a language/framework agnostic problem.","This is really a question about how to use ORMs to do updates, not about ETags. -Imagine 2 processes transferring money into a bank account at the same time -- they both read the old balance, add some, then write the new balance. One of the transfers is lost. -When you're writing with a relational DB, the solution to these problems is to put the read + write in the same transaction, and then use SELECT FOR UPDATE to read the data and/or ensure you have an appropriate isolation level set. -The various ORM implementations all support transactions, so getting the read, check and write into the same transaction will be easy. If you set the SERIALIZABLE isolation level, then that will be enough to fix race conditions, but you may have to deal with deadlocks. -ORMs also generally support SELECT FOR UPDATE in some way. This will let you write safe code with the default READ COMMITTED isolation level. If you google SELECT FOR UPDATE and your ORM, it will probably tell you how to do it. -In both cases (serializable isolation level or select for update), the database will fix the problem by getting a lock on the row for the entity when you read it. If another request comes in and tries to read the entity before your transaction commits, it will be forced to wait.",0.2655860252697744,False,3,4081 +P.S Tagged as Python due to the frameworks used but this should be a language/framework agnostic problem.","You are right that you can still get race conditions if the 'check last etag' and 'make the change' aren't in one atomic operation. +In essence, if your server itself has a race condition, sending etags to the client won't help with that. +You already mentioned a good way to achieve this atomicity: + +The only fool-proof solution I can think of is to also make the database perform the check, in the update query for example. + +You could do something else, like using a mutex lock. Or using an architecture where two threads cannot deal with the same data. +But the database check seems good to me. What you describe about ORM checks might be an addition for better error messages, but is not by itself sufficient as you found.",0.1352210990936997,False,3,4081 2015-12-23 03:13:18.127,Etags used in RESTful APIs are still susceptible to race conditions,"Maybe I'm overlooking something simple and obvious here, but here goes: So one of the features of the Etag header in a HTTP request/response it to enforce concurrency, namely so that multiple clients cannot override each other's edits of a resource (normally when doing a PUT request). I think that part is fairly well known. The bit I'm not so sure about is how the backend/API implementation can actually implement this without having a race condition; for example: @@ -39531,14 +39533,12 @@ Each commit is a synchronous/blocking transaction so one request will get in bef Doesn't this break the purpose of the Etag? The only fool-proof solution I can think of is to also make the database perform the check, in the update query for example. Am I missing something? -P.S Tagged as Python due to the frameworks used but this should be a language/framework agnostic problem.","You are right that you can still get race conditions if the 'check last etag' and 'make the change' aren't in one atomic operation. -In essence, if your server itself has a race condition, sending etags to the client won't help with that. -You already mentioned a good way to achieve this atomicity: - -The only fool-proof solution I can think of is to also make the database perform the check, in the update query for example. - -You could do something else, like using a mutex lock. Or using an architecture where two threads cannot deal with the same data. -But the database check seems good to me. What you describe about ORM checks might be an addition for better error messages, but is not by itself sufficient as you found.",0.1352210990936997,False,3,4081 +P.S Tagged as Python due to the frameworks used but this should be a language/framework agnostic problem.","This is really a question about how to use ORMs to do updates, not about ETags. +Imagine 2 processes transferring money into a bank account at the same time -- they both read the old balance, add some, then write the new balance. One of the transfers is lost. +When you're writing with a relational DB, the solution to these problems is to put the read + write in the same transaction, and then use SELECT FOR UPDATE to read the data and/or ensure you have an appropriate isolation level set. +The various ORM implementations all support transactions, so getting the read, check and write into the same transaction will be easy. If you set the SERIALIZABLE isolation level, then that will be enough to fix race conditions, but you may have to deal with deadlocks. +ORMs also generally support SELECT FOR UPDATE in some way. This will let you write safe code with the default READ COMMITTED isolation level. If you google SELECT FOR UPDATE and your ORM, it will probably tell you how to do it. +In both cases (serializable isolation level or select for update), the database will fix the problem by getting a lock on the row for the entity when you read it. If another request comes in and tries to read the entity before your transaction commits, it will be forced to wait.",0.2655860252697744,False,3,4081 2015-12-23 17:54:32.183,Simulate shell behavior (force eval of last command to be displayed),"In a python shell, if I type a = 2 nothing is printed. If I type a 2 gets printed automatically. Whereas, this doesn't happen if I run a script from idle. I'd like to emulate this shell-like behavior using the python C api, how is it done? For instance, executing this code PyRun_String(""a=2 \na"", Py_file_input, dic, dic); from C, will not print anything as the output. @@ -39581,12 +39581,12 @@ I'm thinking that sort is not the best way to go about this. I checked out group Thanks in advance.","To sort by name: df.fruit.value_counts().sort_index() To sort by counts: df.fruit.value_counts().sort_values()",0.3869120172231254,False,1,4087 2015-12-29 08:59:26.637,"How to install beautifulsoup into python3, when default dir is python2.7?","I have both Python 2.7 and Python 3.5 installed. When I type pip install beautifulsoup4 it tells me that it is already installed in python2.7/site-package directory. +But how do I install it into the python3 dir?","If you are on windows, this works for Python3 as well +py -m pip install bs4",0.0,False,2,4088 +2015-12-29 08:59:26.637,"How to install beautifulsoup into python3, when default dir is python2.7?","I have both Python 2.7 and Python 3.5 installed. When I type pip install beautifulsoup4 it tells me that it is already installed in python2.7/site-package directory. But how do I install it into the python3 dir?","I had some mismatch between Python version and Beautifulsoup. I was installing this project Th3Jock3R/LinuxGSM-Arma3-Mod-Update to a linux centos8 dedicated Arma3 server. Python3 and Beautifulsoup4 seem to match.So I updated Python3, removed manually Beautifulsoup files and re-installed it with: sudo yum install python3-beautifulsoup4 (note the number 3). Works. Then pointing directories in Th3Jock3R:s script A3_SERVER_FOLDER = """" and A3_SERVER_DIR = ""/home/arma3server{}"".format(A3_SERVER_FOLDER) placing and running the script in same folder /home/arma3server with python3 update.py. In this folder is also located new folder called 'modlists' Now the lightness of mod loading blows my mind. -Bob-",0.0679224682270276,False,2,4088 -2015-12-29 08:59:26.637,"How to install beautifulsoup into python3, when default dir is python2.7?","I have both Python 2.7 and Python 3.5 installed. When I type pip install beautifulsoup4 it tells me that it is already installed in python2.7/site-package directory. -But how do I install it into the python3 dir?","If you are on windows, this works for Python3 as well -py -m pip install bs4",0.0,False,2,4088 2015-12-29 15:34:47.500,How to get the index of a tab in AuiNotebook after a right click on a non-active tab?,"I create a menu that popups after a right on a tab. The menu contains three options: close, close other and close all. Right clicking on a tabs does not display its content (it not already displayed), it just show the menu that control the clicked tab. The issue is that right clicking on another tab popups the menu but the program does not know which tab was clicked. Is there any built-in methods to get the index of a tabs in AuiNotebook after a right click event?",Use EVT_AUINOTEBOOK_TAB_RIGHT_DOWN to catch the event. The event.page will give you the clicked page.,0.0,False,1,4089 2015-12-29 22:40:26.793,Completing Spotify Authorization Code Flow via desktop application without using browser,"Working on a small app that takes a Spotify track URL submitted by a user in a messaging application and adds it to a public Spotify playlist. The app is running with the help of spotipy python on a Heroku site (so I have a valid /callback) and listens for the user posting a track URL. @@ -39596,10 +39596,10 @@ Any advice on how to handle this? Can I auth once via terminal, capture the cod P.S. can't add the tag ""spotipy"" yet but surprised it was not already available","I once ran into a similar issue with Google's Calendar API. The app was pretty low-importance so I botched a solution together by running through the auth locally in my browser, finding the response token, and manually copying it over into an environment variable on Heroku. The downside of course was that tokens are set to auto-expire (I believe Google Calendar's was set to 30 days), so periodically the app stopped working and I had to run through the auth flow and copy the key over again. There might be a way to automate that. Good luck!",0.3869120172231254,False,1,4090 2015-12-31 14:30:13.710,Macports caffe wrong python,"I installed caffe using Macports sudo port install caffe. However, Macports didn't use my anaconda python, which I would like to use for development. I can only import caffe in Macports' python2.7. -Is there a way to show anaconda python where to look or do I have to reinstall for anaconda python? Either way, I would be grateful for a hint how to do it.",Install pyvenv ... it is easy to do on a Mac - then you can use whatever you want to.,0.0,False,2,4091 -2015-12-31 14:30:13.710,Macports caffe wrong python,"I installed caffe using Macports sudo port install caffe. However, Macports didn't use my anaconda python, which I would like to use for development. I can only import caffe in Macports' python2.7. Is there a way to show anaconda python where to look or do I have to reinstall for anaconda python? Either way, I would be grateful for a hint how to do it.","MacPorts never installs modules for use with other Python versions than MacPorts' own version. As a consequence, there is no switch to select the Python version to build against. You'll have to install caffe for your Anaconda Python yourself, e.g. in a virtualenv, or use MacPorts Python.",1.2,True,2,4091 +2015-12-31 14:30:13.710,Macports caffe wrong python,"I installed caffe using Macports sudo port install caffe. However, Macports didn't use my anaconda python, which I would like to use for development. I can only import caffe in Macports' python2.7. +Is there a way to show anaconda python where to look or do I have to reinstall for anaconda python? Either way, I would be grateful for a hint how to do it.",Install pyvenv ... it is easy to do on a Mac - then you can use whatever you want to.,0.0,False,2,4091 2016-01-02 21:38:15.827,Getting parent of AST node in Python,"I'm working with Abstract Syntax Trees in Python 3. The ast library gives many ways to get children of the node (you can use iter_child_nodes() or walk()) but no ways to get parent of one. Also, every node has links to its children, but it hasn't links to its parent. How I can get the parent of AST node if I don't want to write some plugin to ast library? What is the most correct way to do this?",You might create some hash table associating AST nodes to AST nodes and scan (recursively) your topmost AST tree to register in that hash table the parent of each node.,1.2,True,2,4092 @@ -39625,8 +39625,8 @@ unless of course if you are doing this download manually?",1.2,True,1,4095 2016-01-04 18:45:08.353,Create 3D- polynomial via numpy etc. from given coordinates,"Given some coordinates in 3D (x-, y- and z-axes), what I would like to do is to get a polynomial (fifth order). I know how to do it in 2D (for example just in x- and y-direction) via numpy. So my question is: Is it possible to do it also with the third (z-) axes? Sorry if I missed a question somewhere. Thank you.","Numpy has functions for multi-variable polynomial evaluation in the polynomial package -- polyval2d, polyval3d -- the problem is getting the coefficients. For fitting, you need the polyvander2d, polyvander3d functions that create the design matrices for the least squares fit. The multi-variable polynomial coefficients thus determined can then be reshaped and used in the corresponding evaluation functions. See the documentation for those functions for more details.",0.0,False,1,4097 -2016-01-06 09:43:45.240,Non-default IPython profile in Spyder console,"I use two installations of Spyder, one using my default python 2.7 and the other running in a python 3.4 virtualenv. However, the history of the IPython console is shared between the two. The cleanest way to have separate histories would be to define a new IPython profile for the python 3.4 installation. My question is: how to convince Spyder to run IPython with a non-default profile? I could not find any way to supply command line options.",(Spyder dev here) There is no way to start an IPython console inside Spyder with a different profile. We use the default profile to create all our consoles.,0.5457054096481145,False,2,4098 2016-01-06 09:43:45.240,Non-default IPython profile in Spyder console,"I use two installations of Spyder, one using my default python 2.7 and the other running in a python 3.4 virtualenv. However, the history of the IPython console is shared between the two. The cleanest way to have separate histories would be to define a new IPython profile for the python 3.4 installation. My question is: how to convince Spyder to run IPython with a non-default profile? I could not find any way to supply command line options.","As mentioned by Carlos' answer, there is no way to start an IPython console inside Spyder with a different profile. A workaround is to duplicate the ~/.ipython directory (I named mine ~/.ipython3) and set the environment variable IPYTHONDIR to the new location before running the python 3 version of Spyder. It will then use the profile_default in the new directory.",1.2,True,2,4098 +2016-01-06 09:43:45.240,Non-default IPython profile in Spyder console,"I use two installations of Spyder, one using my default python 2.7 and the other running in a python 3.4 virtualenv. However, the history of the IPython console is shared between the two. The cleanest way to have separate histories would be to define a new IPython profile for the python 3.4 installation. My question is: how to convince Spyder to run IPython with a non-default profile? I could not find any way to supply command line options.",(Spyder dev here) There is no way to start an IPython console inside Spyder with a different profile. We use the default profile to create all our consoles.,0.5457054096481145,False,2,4098 2016-01-07 07:41:01.563,What the function apply() in scikit-learn can do?,"In scikit-learn new version ,there is a new function called apply() in Gradient boosting. I'm really confused about it . Does it like the method:GBDT + LR that facebook has used? If dose, how can we make it work like GBDT + LR?","From the Sci-Kit Documentation @@ -39711,6 +39711,15 @@ Remember not to upgrade pip with pip (env/scripts/pip) else it will uninstall gl 2016-01-10 19:50:47.283,how to write an Android app in Java which needs to use a Python library?,"I want to develop an app to track people's Whatsapp last seen and other stuff, and found out that there are APIs out there to deal with it, but the thing is they are writen in python and are normally run in Linux I think I have Java and Android knowledge but not python, and wonder if there's a way to develop the most of the app in Java and get the info I want via calls using these python APIs, but without having to install a python interpreter or similar on the device, so the final user just has to download and run the Android app as he would do with any other I want to know if it would be very hard for someone inexperienced as me (this is the 2nd and final year of my developing grade), for it's what I have in mind for the final project, thx in advance","Instead of running it as one app, what about running the python script as separate from the original script? I believe it would bee possible, as android is in fact a UNIX based OS. Any readers could give their input on this idea an if it would work.",0.0,False,1,4104 +2016-01-11 16:23:37.373,how to insert integers in list/array separated by space in python,"I want to insert 5 integers by simply typing 3 4 6 8 9 and hitting enter. I know how to insert strings in a list by using list=raw_input().split("" "",99), but how can I insert integers using space?","The above answer is perfect if you are looking to parse strings into a list. +Else you can parse them into Integer List using the given way +integers = '22 33 11' +integers_list = [] +try: + integers_list = [int(i) for i in integers.split(' ')] +except: + print ""Error Parsing Integer"" +print integers_list",0.0,False,2,4105 2016-01-11 16:23:37.373,how to insert integers in list/array separated by space in python,"I want to insert 5 integers by simply typing 3 4 6 8 9 and hitting enter. I know how to insert strings in a list by using list=raw_input().split("" "",99), but how can I insert integers using space?","map(int, ""1 2 3 4 5"".split()) @@ -39721,15 +39730,6 @@ For raw_input(), you can do: map(int, raw_input().split())",0.0,False,2,4105 -2016-01-11 16:23:37.373,how to insert integers in list/array separated by space in python,"I want to insert 5 integers by simply typing 3 4 6 8 9 and hitting enter. I know how to insert strings in a list by using list=raw_input().split("" "",99), but how can I insert integers using space?","The above answer is perfect if you are looking to parse strings into a list. -Else you can parse them into Integer List using the given way -integers = '22 33 11' -integers_list = [] -try: - integers_list = [int(i) for i in integers.split(' ')] -except: - print ""Error Parsing Integer"" -print integers_list",0.0,False,2,4105 2016-01-11 19:07:37.250,who creates the media folder in django and how to change permission rights?,"I set up django using nginx and gunicorn. I am looking at the permission in my project folder and I see that the permission for the media folder is set to root (all others are set to debian): -rw-r--r-- 1 root root 55K Dec 2 13:33 media I am executing all app relevant commands like makemigrations, migrate, collectstatic, from debian, therefore everything else is debian. @@ -39964,15 +39964,8 @@ Eg. how do I (i) get it back to 'cleanskin' so that I can start up a Django project and get the proper folders in the project space. (ii) get it working with virtualenv, and ensure that the interpreter doesn't have a number suffix, such as python3.4(6) Many thanks in advance, -Chris","You can clean out old PyCharm interpreters that are no longer associated with a project via Settings -> Project Interpreter, click on the gear in the top right, then click ""More"". This gives you a listing where you can get rid of old virtualenvs that PyCharm thinks are still around. This will prevent the ""(1)"", ""(2)"" part. -You don't want to make the virtualenv into the content root. Your project's code is the content root. -As a suggestion: - -Clear out all the registered virtual envs -Make a virtualenv, outside of PyCharm -Create a new project using PyCharm's Django template - -You should then have a working example.",1.2,True,3,4130 +Chris","In addition to the answer above, which removed the Venv from the Pycharm list, I also had to go into my ~/venvs directory and delete the associated directory folder in there. +That did the trick.",0.0,False,3,4130 2016-01-24 17:42:38.750,PyCharm & VirtualEnvs - How To Remove Legacy,"How do I remove all traces of legacy projects from PyCharm? Background: I upgraded from PyCharm Community Edition to PyCharm Pro Edition today. Reason was so I could work on Django projects, and in particular, a fledgling legacy project called 'deals'. @@ -40018,8 +40011,7 @@ Eg. how do I (i) get it back to 'cleanskin' so that I can start up a Django project and get the proper folders in the project space. (ii) get it working with virtualenv, and ensure that the interpreter doesn't have a number suffix, such as python3.4(6) Many thanks in advance, -Chris","In addition to the answer above, which removed the Venv from the Pycharm list, I also had to go into my ~/venvs directory and delete the associated directory folder in there. -That did the trick.",0.0,False,3,4130 +Chris","When virtual env is enabled, there will be a 'V' symbol active in the bottom part of pycharm in the same line with terminal and TODO. When you click on the 'V' , the first one will be enabled with a tick mark. Just click on it again. Then it will get disabled. As simple as that.",0.0,False,3,4130 2016-01-24 17:42:38.750,PyCharm & VirtualEnvs - How To Remove Legacy,"How do I remove all traces of legacy projects from PyCharm? Background: I upgraded from PyCharm Community Edition to PyCharm Pro Edition today. Reason was so I could work on Django projects, and in particular, a fledgling legacy project called 'deals'. @@ -40065,7 +40057,15 @@ Eg. how do I (i) get it back to 'cleanskin' so that I can start up a Django project and get the proper folders in the project space. (ii) get it working with virtualenv, and ensure that the interpreter doesn't have a number suffix, such as python3.4(6) Many thanks in advance, -Chris","When virtual env is enabled, there will be a 'V' symbol active in the bottom part of pycharm in the same line with terminal and TODO. When you click on the 'V' , the first one will be enabled with a tick mark. Just click on it again. Then it will get disabled. As simple as that.",0.0,False,3,4130 +Chris","You can clean out old PyCharm interpreters that are no longer associated with a project via Settings -> Project Interpreter, click on the gear in the top right, then click ""More"". This gives you a listing where you can get rid of old virtualenvs that PyCharm thinks are still around. This will prevent the ""(1)"", ""(2)"" part. +You don't want to make the virtualenv into the content root. Your project's code is the content root. +As a suggestion: + +Clear out all the registered virtual envs +Make a virtualenv, outside of PyCharm +Create a new project using PyCharm's Django template + +You should then have a working example.",1.2,True,3,4130 2016-01-25 09:08:16.810,How to get a socket FD according to the port occupied in Python?,"In my program, A serve-forever daemon is restarted in a subprocess. The program itself is a web service, using port 5000 by default. I don't know the detail of the start script of that daemon, but it seems to inherit the socket listening on port 5000. @@ -40133,17 +40133,17 @@ On my laptop i have both python 2.7 and python 3.4. Python 2.7 is default versio when i want run this program in terminal it gives some module errors because of it used the wrong version. how can i force an name.py file to open in an (non) default version of python. I have tried so search on google but this without any result because of lack of search tags. -also just trying things like ./name.py python3 but with same result(error)","When you type ""python"", your path is searched to run this version. But, if you specify the absolute path of the other python, you run it the way you want it. -Here, in my laptop, I have /home/user/python3_4 and /home/user/python2_7. If I type python, the 3.4 version is executed, because this directory is set in my path variable. When I want to test some scripts from the 2.7 version, I type in the command line: /home/user/python2_7/bin/python script.py. (Both directory were chosen by me. It's not the default for python, of course). -I hope it can help you.",0.0,False,2,4139 +also just trying things like ./name.py python3 but with same result(error)","The Method of @Tom Dalton and @n1c9 work for me! +python3 name.py",1.2,True,2,4139 2016-01-27 22:06:11.487,Run python program from terminal,"I have downloaded a python program from git. This program is python 3. On my laptop i have both python 2.7 and python 3.4. Python 2.7 is default version. when i want run this program in terminal it gives some module errors because of it used the wrong version. how can i force an name.py file to open in an (non) default version of python. I have tried so search on google but this without any result because of lack of search tags. -also just trying things like ./name.py python3 but with same result(error)","The Method of @Tom Dalton and @n1c9 work for me! -python3 name.py",1.2,True,2,4139 +also just trying things like ./name.py python3 but with same result(error)","When you type ""python"", your path is searched to run this version. But, if you specify the absolute path of the other python, you run it the way you want it. +Here, in my laptop, I have /home/user/python3_4 and /home/user/python2_7. If I type python, the 3.4 version is executed, because this directory is set in my path variable. When I want to test some scripts from the 2.7 version, I type in the command line: /home/user/python2_7/bin/python script.py. (Both directory were chosen by me. It's not the default for python, of course). +I hope it can help you.",0.0,False,2,4139 2016-01-28 14:17:33.047,reading the last index from a csv file using pandas in python2.7,"I have a .csv file on disk, formatted so that I can read it into a pandas DataFrame easily, to which I periodically write rows. I need this database to have a row index, so every time I write a new row to it I need to know the index of the last row written. There are plenty of ways to do this: @@ -40157,11 +40157,11 @@ Another way would be to reserve some (fixed amount of) bytes at the beginning of 2016-01-28 23:33:19.740,How to copy/paste a dataframe from iPython into Google Sheets or Excel?,"I've been using iPython (aka Jupyter) quite a bit lately for data analysis and some machine learning. But one big headache is copying results from the notebook app (browser) into either Excel or Google Sheets so I can manipulate results or share them with people who don't use iPython. I know how to convert results to csv and save. But then I have to dig through my computer, open the results and paste them into Excel or Google Sheets. That takes too much time. And just highlighting a resulting dataframe and copy/pasting usually completely messes up the formatting, with columns overflowing. (Not to mention the issue of long resulting dataframes being truncated when printed in iPython.) -How can I easily copy/paste an iPython result into a spreadsheet?","Try using the to_clipboard() method. E.g., for a dataframe, df: df.to_clipboard() will copy said dataframe to your clipboard. You can then paste it into Excel or Google Docs.",1.2,True,2,4141 +How can I easily copy/paste an iPython result into a spreadsheet?",Paste the output to an IDE like Atom and then paste in Google Sheets/Excel,0.0679224682270276,False,2,4141 2016-01-28 23:33:19.740,How to copy/paste a dataframe from iPython into Google Sheets or Excel?,"I've been using iPython (aka Jupyter) quite a bit lately for data analysis and some machine learning. But one big headache is copying results from the notebook app (browser) into either Excel or Google Sheets so I can manipulate results or share them with people who don't use iPython. I know how to convert results to csv and save. But then I have to dig through my computer, open the results and paste them into Excel or Google Sheets. That takes too much time. And just highlighting a resulting dataframe and copy/pasting usually completely messes up the formatting, with columns overflowing. (Not to mention the issue of long resulting dataframes being truncated when printed in iPython.) -How can I easily copy/paste an iPython result into a spreadsheet?",Paste the output to an IDE like Atom and then paste in Google Sheets/Excel,0.0679224682270276,False,2,4141 +How can I easily copy/paste an iPython result into a spreadsheet?","Try using the to_clipboard() method. E.g., for a dataframe, df: df.to_clipboard() will copy said dataframe to your clipboard. You can then paste it into Excel or Google Docs.",1.2,True,2,4141 2016-01-29 08:10:53.933,"Different versions of python when running cmd as admin, how do I alter admin version?","I'm having some trouble tracking down where my pip modules are going, and I finally found what seems to be the root of the issue when I did a ""pip list"" command in two separate cmd windows. One window was running as admin, and the other not. They showed two completely different lists of modules installed. When I ran ""python"" in each window, one started python 3.4.3, and the other python 3.5.0a2. The reason I'm doing this in two separate types of windows is because I'm running into ""access is denied"" errors when trying to install modules with pip. (For example, requests.) @@ -40190,37 +40190,37 @@ there are auto-complete suggestions in some cases but I'd like to know if it's p import urllib when I type urlib. and press (ctrl+tab) would like to see a list with the possible functions/methods to use. Is that possible? -Thanks","I found the solution for my own question. -Actually I had the wrong plugin installed! -So, in the IDE, edit->preferences, and in the packages section just typed autocomplete-python and press install button. -After restart Atom, it should start work :)",0.999823161659962,False,2,4145 -2016-02-02 10:19:57.753,python - atom IDE how to enable auto-complete code to see all functions from a module,"I am using atom IDE for my python projects. -there are auto-complete suggestions in some cases but I'd like to know if it's possible to have a list of all possible functions that a imported module has, for instance if i import -import urllib -when I type urlib. and press (ctrl+tab) would like to see a list with the possible functions/methods to use. -Is that possible? Thanks","Atom is getting various modifications. Autocomplete-python package is a handy package which helps code faster. The way to install it has changed. In all new Atom editor go to File->Settings->install search for autocomplete-python and click on install. Voila its done, restart Atom is not required and you will see the difference with next time you edit python code. Deb",0.5916962662253621,False,2,4145 +2016-02-02 10:19:57.753,python - atom IDE how to enable auto-complete code to see all functions from a module,"I am using atom IDE for my python projects. +there are auto-complete suggestions in some cases but I'd like to know if it's possible to have a list of all possible functions that a imported module has, for instance if i import +import urllib +when I type urlib. and press (ctrl+tab) would like to see a list with the possible functions/methods to use. +Is that possible? +Thanks","I found the solution for my own question. +Actually I had the wrong plugin installed! +So, in the IDE, edit->preferences, and in the packages section just typed autocomplete-python and press install button. +After restart Atom, it should start work :)",0.999823161659962,False,2,4145 2016-02-02 16:31:22.527,How to assign a directory to PyCharm,"New to python and PyCharm, but trying to use if for an online course. After opening an assignment .py document (attached image), I get an error message if I open the python console: Error:Cannot start process, the working directory '\c:...\python_lab.py' is not a directory. Obviously, it is not - it is a python file, but I don't know how to address the problem. -How can I assign a working directory that is functional from within PyCharm, or in general, what is the meaning of the error message?","Create new project -Create new py file in your project or copy your file to under the project directory - -Second option would be import existing project by selecting a directory where you have your python file.",1.2,True,2,4146 +How can I assign a working directory that is functional from within PyCharm, or in general, what is the meaning of the error message?","Looks like your default working directory is a .tmp folder. Best way to fix this is to create a new project, just make sure it's not pointing to a .tmp directory.",0.2012947653214861,False,2,4146 2016-02-02 16:31:22.527,How to assign a directory to PyCharm,"New to python and PyCharm, but trying to use if for an online course. After opening an assignment .py document (attached image), I get an error message if I open the python console: Error:Cannot start process, the working directory '\c:...\python_lab.py' is not a directory. Obviously, it is not - it is a python file, but I don't know how to address the problem. -How can I assign a working directory that is functional from within PyCharm, or in general, what is the meaning of the error message?","Looks like your default working directory is a .tmp folder. Best way to fix this is to create a new project, just make sure it's not pointing to a .tmp directory.",0.2012947653214861,False,2,4146 +How can I assign a working directory that is functional from within PyCharm, or in general, what is the meaning of the error message?","Create new project +Create new py file in your project or copy your file to under the project directory + +Second option would be import existing project by selecting a directory where you have your python file.",1.2,True,2,4146 2016-02-02 20:47:41.207,How to remove code from external release,"I want to release a subset of my code for external use. Only certain functions or methods should be used (or even seen) by the external customer. Is there a way to do this in Python? I thought about wrapping the code I want removed in an if __debug__: and then creating a .pyc file with py_compile or compileall and then recreate source code from the new byte-code using uncompyle2. The __debug__ simply creates an if False condition which gets stripped out by the ""compiler"". I couldn't figure out how to use those ""compiler modules"" with the -O option.","I don't know if there are any standard tools for doing this, but it shouldn't be too difficult to mark the sections with appropriately coded remarks and then run all your files through a script that outputs a new set of files omitting the lines between those remarks.",1.2,True,1,4147 2016-02-02 21:04:51.817,Theano Dimshuffle equivalent in Google's TensorFlow?,"I have seen that transpose and reshape together can help but I don't know how to use. @@ -40296,19 +40296,19 @@ I typed in the command: jupyter notebook --browser=firefox The firefox browser opens, but it is empty and with the following error: ""IPython Notebook requires JavaScript. Please enable it to proceed."" -I searched the web on how to enable JavaScript on Ipython NoteBook but didn't find an answer. I would appreciate a lot any help. Thanks!","javascript has to be enabled in firefox browser it is turned off. to turn it on do this - -To enable JavaScript for Mozilla Firefox: Click the Tools drop-down menu and select Options. Check the boxes next to Block pop-up windows, Load images automatically, and Enable JavaScript. Refresh your browser by right-clicking anywhere on the page and selecting Reload, or by using the Reload button in the toolbar.",0.2012947653214861,False,2,4158 -2016-02-08 09:40:17.807,ipython notebook requires javascript - on firefox web browser,"I'm trying to run jupyter notebook from a terminal on Xfce Ubuntu machine. -I typed in the command: -jupyter notebook --browser=firefox -The firefox browser opens, but it is empty and with the following error: -""IPython Notebook requires JavaScript. Please enable it to proceed."" I searched the web on how to enable JavaScript on Ipython NoteBook but didn't find an answer. I would appreciate a lot any help. Thanks!","In the address bar, type ""about:config"" (with no quotes), and press Enter. Click ""I'll be careful, I promise"". In the search bar, search for ""javascript.enabled"" (with no quotes). Right click the result named ""javascript.enabled"" and click ""Toggle"". JavaScript is now enabled. To Re-disable JavaScript, repeat these steps.",0.2012947653214861,False,2,4158 +2016-02-08 09:40:17.807,ipython notebook requires javascript - on firefox web browser,"I'm trying to run jupyter notebook from a terminal on Xfce Ubuntu machine. +I typed in the command: +jupyter notebook --browser=firefox +The firefox browser opens, but it is empty and with the following error: +""IPython Notebook requires JavaScript. Please enable it to proceed."" +I searched the web on how to enable JavaScript on Ipython NoteBook but didn't find an answer. I would appreciate a lot any help. Thanks!","javascript has to be enabled in firefox browser it is turned off. to turn it on do this + +To enable JavaScript for Mozilla Firefox: Click the Tools drop-down menu and select Options. Check the boxes next to Block pop-up windows, Load images automatically, and Enable JavaScript. Refresh your browser by right-clicking anywhere on the page and selecting Reload, or by using the Reload button in the toolbar.",0.2012947653214861,False,2,4158 2016-02-08 18:36:57.107,When/how does Python use PYTHONPATH,"I'm having some trouble understanding how Python uses the PYTHONPATH environment variable. According to the documentation, the import search path (sys.path) is ""Initialized from the environment variable PYTHONPATH, plus an installation-dependent default."" In a Windows command box, I started Python (v.2.7.6) and printed the value of sys.path. I got a list of pathnames, the ""installation-dependent default."" Then I quit Python, set PYTHONPATH to .;./lib;, restarted Python, and printed os.environ['PYTHONPATH']. I got .;./lib; as expected. Then I printed sys.path. I think it should have been the installation-dependent default with .;./lib; added to the start or the end. Instead it was the installation-dependent default alone, as if PYTHONPATH were empty. What am I missing here?","It always uses PYTHONPATH. What happened is probably that you quit python, but didn't quit your console/command shell. For that shell, the environment that was set when the shell was started still applies, and hence, there's no PYTHONPATH set.",0.0,False,1,4159 @@ -40535,8 +40535,6 @@ PyInstaller works with the default Python 2.7 provided with current It means to say ""install later versions of Python as well as python packages with Homebrew"", and not to say ""install pyinstaller itself with homebrew"". In that respect you are correct, there is no formula for pyinstaller on homebrew. You can install pyinstaller with pip though: pip install pyinstaller or pip3 install pyinstaller. Then confirm the install with pyinstaller --version.",1.2,True,1,4186 -2016-02-26 20:46:16.790,How to detect objects in a video opencv with Python?,"I have a video consisting of different objects such as square, rectangle , triangle. I somehow need to detect and show only square objects. So in each frame, if there is a square, it is fine but if there is a triangle or rectangle then it should display it. I am using background subtraction and I am able to detect all the three objects and create a bounding box around them. But I am not able to figure out how to display only square object.","How are your objects filled or just an outline? -In either case the approach I would take is to detect the vertices by finding the maximum gradient or just by the bounding box. The vertices will be on the bounding box. Once you have the vertices, you can say whether the object is a square or a rectangle just by finding the distances between the consecutive vertices.",0.2012947653214861,False,2,4187 2016-02-26 20:46:16.790,How to detect objects in a video opencv with Python?,"I have a video consisting of different objects such as square, rectangle , triangle. I somehow need to detect and show only square objects. So in each frame, if there is a square, it is fine but if there is a triangle or rectangle then it should display it. I am using background subtraction and I am able to detect all the three objects and create a bounding box around them. But I am not able to figure out how to display only square object.","You can use the following algorithm: -Perform Background subtraction, as you're doing currently -enclose foreground in contours (using findContours(,,,) then drawContours(,,,) function) @@ -40544,6 +40542,8 @@ In either case the approach I would take is to detect the vertices by finding th -if area of bounding box is approximately equal to that of enclosed contour, then the shape is a square or rectangle, not a triangle. (A large part of the box enclosing a triangle will lie outside the triangle) -if boundingBox height is approximately equal to its width, then it is a square. (access height and width by Rect.height and Rect.width)",1.2,True,2,4187 +2016-02-26 20:46:16.790,How to detect objects in a video opencv with Python?,"I have a video consisting of different objects such as square, rectangle , triangle. I somehow need to detect and show only square objects. So in each frame, if there is a square, it is fine but if there is a triangle or rectangle then it should display it. I am using background subtraction and I am able to detect all the three objects and create a bounding box around them. But I am not able to figure out how to display only square object.","How are your objects filled or just an outline? +In either case the approach I would take is to detect the vertices by finding the maximum gradient or just by the bounding box. The vertices will be on the bounding box. Once you have the vertices, you can say whether the object is a square or a rectangle just by finding the distances between the consecutive vertices.",0.2012947653214861,False,2,4187 2016-02-27 13:24:23.287,python pandas ... alternatives to iterrows in pandas to get next rows value (NEW),"I have a df in pandas import pandas as pd import pandas as pd @@ -40729,10 +40729,10 @@ sh data/data/com.hipipal.qpyplus/files/bin/qpython-android5.sh $1 so is possible to call python /sdcard/myScript.py arg1 and in myScript.py as usual fetch with sys.argv -thanks","I don't have experience in Android programming, so I can only give a general recommendation: -Of course the naive solution would be to explicitly pass the arguments from script to script, but I guess you can't or don't want to modify the scripts in between, otherwise you would not have asked. -Another approach, which I sometimes use, is to define an environment variable in the outermost scripts, stuff all my parameters into it, and parse it from Python. -Finally, you could write a ""configuration file"" from the outermost script, and read it from your Python program. If you create this file in Python syntax, you even spare yourself from parsing the code.",1.2,True,2,4210 +thanks","I have similar problem. Runing my script from Python console +/storage/emulator/0/Download/.last_tmp.py -s && exit + I am getting ""Permission denied"". No matter if i am calling last_tmp or edited script itself. +Is there perhaps any way to pass the params in editor?",0.0,False,2,4210 2016-03-10 21:58:57.150,Pass parameter through shell to python,"I run python in my Android Terminal and want to run a .py file with: python /sdcard/myScript.py The problem is that python is called in my Android enviroment indirect with a shell in my /system/bin/ path (to get it direct accessable via Terminal emulator). @@ -40746,10 +40746,10 @@ sh data/data/com.hipipal.qpyplus/files/bin/qpython-android5.sh $1 so is possible to call python /sdcard/myScript.py arg1 and in myScript.py as usual fetch with sys.argv -thanks","I have similar problem. Runing my script from Python console -/storage/emulator/0/Download/.last_tmp.py -s && exit - I am getting ""Permission denied"". No matter if i am calling last_tmp or edited script itself. -Is there perhaps any way to pass the params in editor?",0.0,False,2,4210 +thanks","I don't have experience in Android programming, so I can only give a general recommendation: +Of course the naive solution would be to explicitly pass the arguments from script to script, but I guess you can't or don't want to modify the scripts in between, otherwise you would not have asked. +Another approach, which I sometimes use, is to define an environment variable in the outermost scripts, stuff all my parameters into it, and parse it from Python. +Finally, you could write a ""configuration file"" from the outermost script, and read it from your Python program. If you create this file in Python syntax, you even spare yourself from parsing the code.",1.2,True,2,4210 2016-03-10 22:07:57.520,idle keyboard shortcuts have changed after installing enthought,"I'm taking an online MIT programming course that suggested I use the enthought programming environment. I installed it and now my idle keyboard shortcuts have all changed. It seems to be directly caused by the installation of enthought, as my other computer (without enthought) still retained the old keyboard shortcuts. Anyone know how to get my old keyboard shortcuts back?","if i were you, try to continue and use your old shortcuts but if they still dont work, try to use ""control"" for ""option"" shortcuts and vice-versa. thanks to the the websites online for everything!",-0.9640275800758168,False,1,4211 2016-03-11 11:18:44.820,matplotlib & seaborn: how to get rid of lines?,"I'm using the whitegrid style and it's fine except for the vertical lines in the background. I just want to retain the horizontal lines.",Passing arguments into ax.yaxis.grid() and ax.xaxis.grid() will include or omit grids in the graphs,1.2,True,1,4212 @@ -40817,12 +40817,12 @@ pygame.error: SavePNG: could not open for writing I'm not sure why this would happen and saving works fine usually. Perhaps when the computer goes to sleep something stops working? But more importantly does anyone know how to fix this?","Are you on windows or on mac? If you're on windows look if you wrote the location like this ""\folder\thing.png"", that's an error because you put the starting ""\"". Remove that and try again.",0.0,False,1,4220 2016-03-13 09:35:37.283,How to obtain how much time is spent in f2py wrappers,"I am currently writing a time consuming python program and decided to rewrite part of the program in fortran. However, the performance is still not good. For profiling purpose, I want to know how much time is spent in f2py wrappers and how much time is actual spent in fortran subroutines. Is there a convenient way to achieve this?",At last I found out -DF2PY_REPORT_ATEXIT option can report wrapper performance.,1.2,True,1,4221 -2016-03-14 22:30:07.003,How to determine what version of python3 tkinter is installed on my linux machine?,Hi have been scavenging the web for answers on how to do this but there was no direct answer. Does anyone know how I can find the version number of tkinter?,"Run Tkinter.TclVersion or Tkinter.TkVersion and if both are not working, try Tkinter.__version__",0.2655860252697744,False,2,4222 2016-03-14 22:30:07.003,How to determine what version of python3 tkinter is installed on my linux machine?,Hi have been scavenging the web for answers on how to do this but there was no direct answer. Does anyone know how I can find the version number of tkinter?,"Type this command on the Terminal and run it. python -m tkinter A small window will appear with the heading tk and two buttons: Click Me! and QUIT. There will be a text that goes like This is Tcl/Tk version ___. The version number will be displayed in the place of the underscores.",0.3275988531455109,False,2,4222 +2016-03-14 22:30:07.003,How to determine what version of python3 tkinter is installed on my linux machine?,Hi have been scavenging the web for answers on how to do this but there was no direct answer. Does anyone know how I can find the version number of tkinter?,"Run Tkinter.TclVersion or Tkinter.TkVersion and if both are not working, try Tkinter.__version__",0.2655860252697744,False,2,4222 2016-03-15 09:51:09.270,Install module in Python 2.7 and not in Python 3.3,"I'm working on mac OS X and I have both Python 2.7 and 3.3 on it. I want to install pykml module and i successfully installed it on python 3.3, but how do I do the same for Python 2.7?","You can do this if pip version >=1.5 $ pip2.6 install package $ pip3.3 install package @@ -41097,8 +41097,8 @@ like I have figured out how to do this with methods (using inspect.getmro(meth.im_class)) but I am unable to find a way for variables","To my knowledge, there's no ""cheap trick"" you'll have to have all your class elements and compare their variable values with what you have . (Couldn't comment, sry) At least from what I understand you're trying to achieve, the question isn't very well constructed.",0.0,False,1,4255 2016-04-04 19:00:43.177,Can the model object for a learner be exported with joblib?,I'm evaluating orange as a potential solution to helping new entrants into data science to get started. I would like to have them save out model objects created from different algorithms as pkl files similar to how it is done in scikit-learn with joblib or pickle.,"I don't understand what ""exported with joblib"" refers to, but you can save trained Orange models by pickling them, or with Save Classifier widget if you are using the GUI.",0.0,False,1,4256 -2016-04-06 08:42:42.097,using os.system() to run a command without root,"I have a python 2 script that is run as root. I want to use os.system(""some bash command"") without root privileges, how do I go about this?",I have test on my PC. If you run the python script like 'sudo test.py' and the question is resolved.,-0.2012947653214861,False,2,4257 2016-04-06 08:42:42.097,using os.system() to run a command without root,"I have a python 2 script that is run as root. I want to use os.system(""some bash command"") without root privileges, how do I go about this?","Try to use os.seteuid(some_user_id) before os.system(""some bash command"").",1.2,True,2,4257 +2016-04-06 08:42:42.097,using os.system() to run a command without root,"I have a python 2 script that is run as root. I want to use os.system(""some bash command"") without root privileges, how do I go about this?",I have test on my PC. If you run the python script like 'sudo test.py' and the question is resolved.,-0.2012947653214861,False,2,4257 2016-04-06 16:10:40.700,How to download pygame for non default version of python,"I am running El Capitan, when I type python --version the terminal prints Python 2.7.10, I have successfully downloaded pygame for Python 2.7.10 but I want to develop in python 3.5.1, I know I can do this by entering python3 in the terminal, but how do I properly set up pygame for this version of python?",Use python3.5 -mpip install pygame.,0.3869120172231254,False,1,4258 2016-04-06 21:41:33.940,how to use --patterns for tests in django,"I have a test file with tests in it which will not be called with the regular manage.py test @@ -41185,12 +41185,12 @@ You could try using Django 1.8, which is a long term support release and does st Or you could switch to a different host that supports deploying Django 1.9 with wsgi.",0.0,False,2,4267 2016-04-16 20:42:54.060,Streaming values in a python script to a wep app,"I have a python script that runs continuously as a WebJob (using Microsoft Azure), it generates some values (heart beat rate) continuously, and I want to display those values in my Web App. I don't know how to proceed to link the WebJob to the web app. -Any ideas ?",You would need to provide some more information about what kind of interface your web app exposes. Does it only handle normal HTTP1 requests or does it have a web socket or HTTP2 type interface? If it has only HTTP1 requests that it can handle then you just need to make multiple requests or try and do long polling. Otherwise you need to connect with a web socket and stream the data over a normal socket connection.,0.0,False,2,4268 -2016-04-16 20:42:54.060,Streaming values in a python script to a wep app,"I have a python script that runs continuously as a WebJob (using Microsoft Azure), it generates some values (heart beat rate) continuously, and I want to display those values in my Web App. -I don't know how to proceed to link the WebJob to the web app. Any ideas ?","You have two main options: You can have the WebJobs write the values to a database or to Azure Storage (e.g. a queue), and have the Web App read them from there. Or if the WebJob and App are in the same Web App, you can use the file system. e.g. have the WebJob write things into %home%\data\SomeFolderYouChoose, and have the Web App read from the same place.",1.2,True,2,4268 +2016-04-16 20:42:54.060,Streaming values in a python script to a wep app,"I have a python script that runs continuously as a WebJob (using Microsoft Azure), it generates some values (heart beat rate) continuously, and I want to display those values in my Web App. +I don't know how to proceed to link the WebJob to the web app. +Any ideas ?",You would need to provide some more information about what kind of interface your web app exposes. Does it only handle normal HTTP1 requests or does it have a web socket or HTTP2 type interface? If it has only HTTP1 requests that it can handle then you just need to make multiple requests or try and do long polling. Otherwise you need to connect with a web socket and stream the data over a normal socket connection.,0.0,False,2,4268 2016-04-18 07:35:32.550,similarity measure scikit-learn document classification,"I am doing some work in document classification with scikit-learn. For this purpose, I represent my documents in a tf-idf matrix and feed a Random Forest classifier with this information, works perfectly well. I was just wondering which similarity measure is used by the classifier (cosine, euclidean, etc.) and how I can change it. Haven't found any parameters or informatin in the documentation. Thanks in advance!","As with most supervised learning algorithms, Random Forest Classifiers do not use a similarity measure, they work directly on the feature supplied to them. So decision trees are built based on the terms in your tf-idf vectors. If you want to use similarity then you will have to compute a similarity matrix for your documents and use this as your features.",1.2,True,1,4269 @@ -41198,25 +41198,9 @@ If you want to use similarity then you will have to compute a similarity matrix They're both also pretty ancient, so if you have an opportunity to use something else, I'd highly recommend it. If not, then you're going to have to find a Burlap lib for Python. Since it seems that a Burlap lib for Python simply doesn't exist (at least anymore), your best choice is probably to make a small Java proxy that communicates with a more recent protocol with the Python side and in Burlap with the Java server.",1.2,True,1,4270 2016-04-19 11:56:38.960,Passing an image from Lambda to API Gateway,"I have a lambdas function that resizes and image, stores it back into S3. However I want to pass this image to my API to be returned to the client. -Is there a way to return a png image to the API gateway, and if so how can this be done?",API Gateway does not currently support passing through binary data either as part of a request nor as part of a response. This feature request is on our backlog and is prioritized fairly high.,0.0,False,2,4271 -2016-04-19 11:56:38.960,Passing an image from Lambda to API Gateway,"I have a lambdas function that resizes and image, stores it back into S3. However I want to pass this image to my API to be returned to the client. Is there a way to return a png image to the API gateway, and if so how can this be done?",You could return it base64-encoded...,0.0,False,2,4271 -2016-04-19 15:31:31.727,theano g++ not detected,"I installed theano but when I try to use it I got this error: - -WARNING (theano.configdefaults): g++ not detected! Theano will be unable to execute - optimized C-implementations (for both CPU and GPU) and will default to Python - implementations. Performance will be severely degraded. - -I installed g++, and put the correct path in the environment variables, so it is like theano does not detect it. -Does anyone know how to solve the problem or which may be the cause?","On Windows, you need to install mingw to support g++. Usually, it is advisable to use Anaconda distribution to install Python. Theano works with Python3.4 or older versions. You can use conda install command to install mingw.",0.3869120172231254,False,3,4272 -2016-04-19 15:31:31.727,theano g++ not detected,"I installed theano but when I try to use it I got this error: - -WARNING (theano.configdefaults): g++ not detected! Theano will be unable to execute - optimized C-implementations (for both CPU and GPU) and will default to Python - implementations. Performance will be severely degraded. - -I installed g++, and put the correct path in the environment variables, so it is like theano does not detect it. -Does anyone know how to solve the problem or which may be the cause?","I had this occur on OS X after I updated XCode (through the App Store). Everything worked before the update, but after the update I had to start XCode and accept the license agreement. Then everything worked again.",0.4431875092007125,False,3,4272 +2016-04-19 11:56:38.960,Passing an image from Lambda to API Gateway,"I have a lambdas function that resizes and image, stores it back into S3. However I want to pass this image to my API to be returned to the client. +Is there a way to return a png image to the API gateway, and if so how can this be done?",API Gateway does not currently support passing through binary data either as part of a request nor as part of a response. This feature request is on our backlog and is prioritized fairly high.,0.0,False,2,4271 2016-04-19 15:31:31.727,theano g++ not detected,"I installed theano but when I try to use it I got this error: WARNING (theano.configdefaults): g++ not detected! Theano will be unable to execute @@ -41247,6 +41231,22 @@ InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault Restart you machine… I am sure there are some more complicated steps that someone smarter than me can add here to make this faster Run the model.fit function of the keras application which should run faster now … win!",0.2012947653214861,False,3,4272 +2016-04-19 15:31:31.727,theano g++ not detected,"I installed theano but when I try to use it I got this error: + +WARNING (theano.configdefaults): g++ not detected! Theano will be unable to execute + optimized C-implementations (for both CPU and GPU) and will default to Python + implementations. Performance will be severely degraded. + +I installed g++, and put the correct path in the environment variables, so it is like theano does not detect it. +Does anyone know how to solve the problem or which may be the cause?","On Windows, you need to install mingw to support g++. Usually, it is advisable to use Anaconda distribution to install Python. Theano works with Python3.4 or older versions. You can use conda install command to install mingw.",0.3869120172231254,False,3,4272 +2016-04-19 15:31:31.727,theano g++ not detected,"I installed theano but when I try to use it I got this error: + +WARNING (theano.configdefaults): g++ not detected! Theano will be unable to execute + optimized C-implementations (for both CPU and GPU) and will default to Python + implementations. Performance will be severely degraded. + +I installed g++, and put the correct path in the environment variables, so it is like theano does not detect it. +Does anyone know how to solve the problem or which may be the cause?","I had this occur on OS X after I updated XCode (through the App Store). Everything worked before the update, but after the update I had to start XCode and accept the license agreement. Then everything worked again.",0.4431875092007125,False,3,4272 2016-04-21 03:24:27.110,tensorflow sequence to sequence without softmax,"I was using Tensorflow sequence to sequence example code. for some reason, I don't want to add softmax to output. instead, I want to get the raw output of decoder without softmax. I was wondering if anyone know how to do it based on sequence to sequence example code? Or I need to create it from scratch or modify the the seq2seq.py (under the /tensorflow/tensorflow/python/ops/seq2seq.py)? Thank you",The model_with_buckets() function in seq2seq.py returns 2 tensors: the output and the losses. The outputs variable contains the raw output of the decoder that you're looking for (that would normally be fed to the softmax).,1.2,True,1,4273 2016-04-21 20:12:29.323,remove known exact row in huge csv,"I have a ~220 million row, 7 column csv file. I need to remove row 2636759. @@ -41417,15 +41417,7 @@ Msg Delay Reasons As asked in the comments: Internal/External API response times may vary. Hard to quantify. -If multiple exports are being processed at the same time, msgs from one export may get lagged behind or be received in a mixed sequence in queues down the line.","It looks like you can do the following: - -Assigner - -Reads from the assigner queue and assigns the proper ids -Packs the data in bulks and uploads them to S3. -Sends the path to S3 to the Dumper queue - -Dumper reads the bulks and dumps them to DB in bulks",0.0,False,2,4294 +If multiple exports are being processed at the same time, msgs from one export may get lagged behind or be received in a mixed sequence in queues down the line.",You should probably use a cache instead of a queue.,0.0,False,2,4294 2016-05-01 21:40:52.443,Scaling a sequential program into chain of queues,"I am trying to scale an export system that works in the following steps: Fetch a large number of records from a MySQL database. Each record is a person with an address and a product they want. @@ -41457,7 +41449,15 @@ Msg Delay Reasons As asked in the comments: Internal/External API response times may vary. Hard to quantify. -If multiple exports are being processed at the same time, msgs from one export may get lagged behind or be received in a mixed sequence in queues down the line.",You should probably use a cache instead of a queue.,0.0,False,2,4294 +If multiple exports are being processed at the same time, msgs from one export may get lagged behind or be received in a mixed sequence in queues down the line.","It looks like you can do the following: + +Assigner + +Reads from the assigner queue and assigns the proper ids +Packs the data in bulks and uploads them to S3. +Sends the path to S3 to the Dumper queue + +Dumper reads the bulks and dumps them to DB in bulks",0.0,False,2,4294 2016-05-02 08:19:27.860,"Selenium Python, New Page","My main Question: How do I switch pages? I did some things on a page and than switch to another one, @@ -41468,16 +41468,6 @@ I currently have a set of C++ .dll files. Each library contains many functions, My question is: Is there a programmatic way of interfacing with a Windows C++ .dll that does not require crafting corresponding wrappers for each of the functions? Thanks.","I would recommend using Cython to do your wrapping. Cython allows you to use C/C++ code directly with very little changes (in addition to some boilerplate). For wrapping large libraries, it's often straightforward to get something up and running very quickly with minimal extra wrapping work (such as in Ctypes). It's also been my experience that Cython scales better... although it takes more front end work to stand Cython up rather than Ctypes, it is in my opinion more maintainable and lends itself well to the programmatic generation of wrapping code to which you allude.",1.2,True,1,4297 2016-05-05 22:08:08.557,Trouble with TensorFlow in Jupyter Notebook,"I installed Jupyter notebooks in Ubuntu 14.04 via Anaconda earlier, and just now I installed TensorFlow. I would like TensorFlow to work regardless of whether I am working in a notebook or simply scripting. In my attempt to achieve this, I ended up installing TensorFlow twice, once using Anaconda, and once using pip. The Anaconda install works, but I need to preface any call to python with ""source activate tensorflow"". And the pip install works nicely, if start python the standard way (in the terminal) then tensorflow loads just fine. My question is: how can I also have it work in the Jupyter notebooks? -This leads me to a more general question: it seems that my python kernel in Jupyter/Anaconda is separate from the python kernel (or environment? not sure about the terminology here) used system wide. It would be nice if these coincided, so that if I install a new python library, it becomes accessible to all the varied ways I have of running python.","Here is what I did to enable tensorflow in Anaconda -> Jupyter. - -Install Tensorflow using the instructions provided at -Go to /Users/username/anaconda/env and ensure Tensorflow is installed -Open the Anaconda navigator and go to ""Environments"" (located in the left navigation) -Select ""All"" in teh first drop down and search for Tensorflow -If its not enabled, enabled it in the checkbox and confirm the process that follows. -Now open a new Jupyter notebook and tensorflow should work",0.1160922760327606,False,2,4298 -2016-05-05 22:08:08.557,Trouble with TensorFlow in Jupyter Notebook,"I installed Jupyter notebooks in Ubuntu 14.04 via Anaconda earlier, and just now I installed TensorFlow. I would like TensorFlow to work regardless of whether I am working in a notebook or simply scripting. In my attempt to achieve this, I ended up installing TensorFlow twice, once using Anaconda, and once using pip. The Anaconda install works, but I need to preface any call to python with ""source activate tensorflow"". And the pip install works nicely, if start python the standard way (in the terminal) then tensorflow loads just fine. -My question is: how can I also have it work in the Jupyter notebooks? This leads me to a more general question: it seems that my python kernel in Jupyter/Anaconda is separate from the python kernel (or environment? not sure about the terminology here) used system wide. It would be nice if these coincided, so that if I install a new python library, it becomes accessible to all the varied ways I have of running python.","Open an Anaconda Prompt screen: (base) C:\Users\YOU>conda create -n tf tensorflow After the environment is created type: conda activate tf Prompt moves to (tf) environment, that is: (tf) C:\Users\YOU> @@ -41494,6 +41484,16 @@ type conda activate tf the prompt moves to tf environment (tf) C:\Users\YOU> then type (tf) C:\Users\YOU>jupyter notebook",-0.0291462614471899,False,2,4298 +2016-05-05 22:08:08.557,Trouble with TensorFlow in Jupyter Notebook,"I installed Jupyter notebooks in Ubuntu 14.04 via Anaconda earlier, and just now I installed TensorFlow. I would like TensorFlow to work regardless of whether I am working in a notebook or simply scripting. In my attempt to achieve this, I ended up installing TensorFlow twice, once using Anaconda, and once using pip. The Anaconda install works, but I need to preface any call to python with ""source activate tensorflow"". And the pip install works nicely, if start python the standard way (in the terminal) then tensorflow loads just fine. +My question is: how can I also have it work in the Jupyter notebooks? +This leads me to a more general question: it seems that my python kernel in Jupyter/Anaconda is separate from the python kernel (or environment? not sure about the terminology here) used system wide. It would be nice if these coincided, so that if I install a new python library, it becomes accessible to all the varied ways I have of running python.","Here is what I did to enable tensorflow in Anaconda -> Jupyter. + +Install Tensorflow using the instructions provided at +Go to /Users/username/anaconda/env and ensure Tensorflow is installed +Open the Anaconda navigator and go to ""Environments"" (located in the left navigation) +Select ""All"" in teh first drop down and search for Tensorflow +If its not enabled, enabled it in the checkbox and confirm the process that follows. +Now open a new Jupyter notebook and tensorflow should work",0.1160922760327606,False,2,4298 2016-05-06 04:19:18.807,Kivy ScrollView (with Gridview) Suffering Performance Issues,"I have a GridView inside of a ScrollView. I am trying to create and display approximately ~12,000 items in the GridView (which clearly will not display appropriately on screen), but the number of items could feasible be ~40,000. Currently ~18 seconds are spent constructing all of the items (Labels), and any resizing of the window results in another significant delay. How can I speed up the construction and rendering of the items? I don't know how to do paging or delayed, on-demand loading on a ScrollView.","How can you imagine a user scrolling through 40000 labels? You should rethink your app design. Consider adding a text input, and based on the given string, fetch filtered data from the database you have.",0.0,False,1,4299 @@ -41528,12 +41528,12 @@ I searched around the harddrive and found the zeromq library in pkgs in my pytho 6. pip install --no-binary :all: pyzmq Then you can use pgm/epgm as you want.",0.3869120172231254,False,1,4303 2016-05-12 06:10:48.683,How to stop flask app.run()?,"I made a flask app following flask's tutorial. After python flaskApp.py, how can I stop the app? I pressed ctrl + c in the terminal but I can still access the app through the browser. I'm wondering how to stop the app? Thanks. -I even rebooted the vps. After the vps is restated, the app still is running!","Have you tried pkill python? -WARNING: do not do so before consulting your system admin if are sharing a server with others.",0.1352210990936997,False,2,4304 -2016-05-12 06:10:48.683,How to stop flask app.run()?,"I made a flask app following flask's tutorial. After python flaskApp.py, how can I stop the app? I pressed ctrl + c in the terminal but I can still access the app through the browser. I'm wondering how to stop the app? Thanks. I even rebooted the vps. After the vps is restated, the app still is running!","CTRL+C is the right way to quit the app, I do not think that you can visit the url after CTRL+C. In my environment it works well. What is the terminal output after CTRL+C? Maybe you can add some details. You can try to visit the url by curl to test if browser cache or anything related with browser cause this problem.",0.2655860252697744,False,2,4304 +2016-05-12 06:10:48.683,How to stop flask app.run()?,"I made a flask app following flask's tutorial. After python flaskApp.py, how can I stop the app? I pressed ctrl + c in the terminal but I can still access the app through the browser. I'm wondering how to stop the app? Thanks. +I even rebooted the vps. After the vps is restated, the app still is running!","Have you tried pkill python? +WARNING: do not do so before consulting your system admin if are sharing a server with others.",0.1352210990936997,False,2,4304 2016-05-12 10:44:52.963,Find out if/which BLAS library is used by Numpy,"I use numpy and scipy in different environments (MacOS, Ubuntu, RedHat). Usually I install numpy by using the package manager that is available (e.g., mac ports, apt, yum). However, if you don't compile Numpy manually, how can you be sure that it uses a BLAS library? Using mac ports, ATLAS is installed as a dependency. However, I am not sure if it is really used. When I perform a simple benchmark, the numpy.dot() function requires approx. 2 times the time than a dot product that is computed using the Eigen C++ library. I am not sure if this is a reasonable result.","numpy.show_config() just tells that info is not available on my Debian Linux. @@ -41599,13 +41599,13 @@ def Test(): print ('foo') Test()",1.2,True,1,4312 2016-05-18 22:33:13.253,Django sending xml requests at the same time,"Using the form i create several strings that looks like xml data. One part of this strings i need to send on several servers using urllib and another part, on soap server, then i use suds library. When i receive the respond, i need to compare all of this data and show it to user. The sum of these server is nine and quantity of servers can grow. When i make this requests successively, it takes lot of time. According to this i have a question, is there some python library that can make different requests at the same time? Thank you for answer.",You might want to consider using PycURL or Twisted. These should have the asynchronous capabilities you're looking for.,1.2,True,1,4313 -2016-05-19 03:10:57.693,How to convert two channel audio into one channel audio,I am playing around with some audio processing in python. Right now I have the audio as a 2x(Large Number) numpy array. I want to combine the channels since I only want to try some simple stuff. I am just unsure how I should do this mathematically. At first I thought this is kind of like converting an RGB image to gray-scale where you would average each of the color channels to create a gray pixel. Then I thought that maybe I should add them due to the superposition principal of waves (then again average is just adding and dividing by two.) Does anyone know the best way to do this?,i handle this by using Matlab.python can do the same. (left-channel+right-channel)/2.0,0.2012947653214861,False,2,4314 2016-05-19 03:10:57.693,How to convert two channel audio into one channel audio,I am playing around with some audio processing in python. Right now I have the audio as a 2x(Large Number) numpy array. I want to combine the channels since I only want to try some simple stuff. I am just unsure how I should do this mathematically. At first I thought this is kind of like converting an RGB image to gray-scale where you would average each of the color channels to create a gray pixel. Then I thought that maybe I should add them due to the superposition principal of waves (then again average is just adding and dividing by two.) Does anyone know the best way to do this?,"To convert any stereo audio to mono, what I have always seen is the following: For each pair of left and right samples: Add the values of the samples together in a way that will not overflow Divide the resulting value by two Use this resulting value as the sample in the mono track - make sure to round it properly if you are converting it to an integer value from a floating point value",1.2,True,2,4314 +2016-05-19 03:10:57.693,How to convert two channel audio into one channel audio,I am playing around with some audio processing in python. Right now I have the audio as a 2x(Large Number) numpy array. I want to combine the channels since I only want to try some simple stuff. I am just unsure how I should do this mathematically. At first I thought this is kind of like converting an RGB image to gray-scale where you would average each of the color channels to create a gray pixel. Then I thought that maybe I should add them due to the superposition principal of waves (then again average is just adding and dividing by two.) Does anyone know the best way to do this?,i handle this by using Matlab.python can do the same. (left-channel+right-channel)/2.0,0.2012947653214861,False,2,4314 2016-05-19 16:12:37.927,How to configure the Jenkins ShiningPanda plugin Python Installations,"The Jenkins ShiningPanda plugin provides a Managers Jenkins - Configure System setting for Python installations... which includes the ability to Install automatically. This should allow me to automatically setup Python on my slaves. But I'm having trouble figuring out how to use it. When I use the Add Installer drop down it gives me the ability to @@ -41823,19 +41823,19 @@ round(1.4 99 999 999 999 999) (without the spaces) gets rounded to 1. I suppose this has to do with imprecise floating point representations, but fail to understand how does it come that the first representation is interpreted as closer to 2 than to 1.","Because 1.4 999 999 999 999 999 when parsed is exactly 1.5, the difference between them is too small to represent at that magnitude. But 1.4 99 999 999 999 999 is low enough to parse to ""less than 1.5"", actually 1.4999999999999988897769753748434595763683319091796875, which is clearly less than 1.5",0.9999092042625952,False,1,4338 2016-06-09 08:56:53.973,how to indent the code block in Python IDE: Spyder?,"Is there any shortcut key in Spyder python IDE to indent the code block? -For example, Like ctr+[ in Matlab, I want to indent the code block together.",Spyder 4 select the lines and then press TAB or CTRL+] For indent and shift+TAB or CTRL+] for un-indent,0.0,False,2,4339 -2016-06-09 08:56:53.973,how to indent the code block in Python IDE: Spyder?,"Is there any shortcut key in Spyder python IDE to indent the code block? For example, Like ctr+[ in Matlab, I want to indent the code block together.","Select your code and press Tab for indent and Shift+Tab to un-indent. or go to Edit -> Indent/Unindent Edit section also contains some other tools for editing your code.",1.2,True,2,4339 +2016-06-09 08:56:53.973,how to indent the code block in Python IDE: Spyder?,"Is there any shortcut key in Spyder python IDE to indent the code block? +For example, Like ctr+[ in Matlab, I want to indent the code block together.",Spyder 4 select the lines and then press TAB or CTRL+] For indent and shift+TAB or CTRL+] for un-indent,0.0,False,2,4339 2016-06-09 09:06:23.340,Visual Studio Python Environments window does not display,"I have installed Win10, Visual Studio 2015, Python 2.7, Python 3.5 and PTVS 2.2.3. Unfortunately PTVS does not work at all. I can not load any Python projects that were loading previously in Visual Studio. It worked before I installed Python 3.5. I tried to uninstall Python 2.7 and get an error saying that the uninstall didn't success. After several tries, the problem appears to be around pip which is somehow blocking both install and uninstall of Python 2.7. When trying to open Python Tools from Tools menu, nothing happens. Neither window opens nor any error message is displayed. Python Environments window does not open even with the shortcut. In Tools > Options > Python Tools, the only text shown is: ""An error occurred loading this property page"". When I try to load/reload the Python project, the message is: ""error : Expected 1 export(s) with contract name ""Microsoft.PythonTools.Interpreter.IInterpreterOptionsService"" but found 0 after applying applicable constraints."" This has already been posted for 11 days ago, but no one has answered. To solve this, I would like to know how to make the Python Environment window appearing in Visual Studio. -Thanks for any help.","You'll need to open the ActivityLog.xml (%APPDATA%\Microsoft\VisualStudio\14.0\ActivityLog.xml) and see if there's any exceptions there related to PTVS. -It sounds like you have a pretty messed up configuration at this point. You could try uninstalling PTVS and re-installing it, but my guess is your messed up Python installs are somehow throwing PTVS off and causing it to crash somewhere.",0.0,False,3,4340 +Thanks for any help.","Thanks for your posts. +My problem was fixed after I installed VS 2015 update 3 which included a new release of PTVS (June 2.2.40623).",0.0,False,3,4340 2016-06-09 09:06:23.340,Visual Studio Python Environments window does not display,"I have installed Win10, Visual Studio 2015, Python 2.7, Python 3.5 and PTVS 2.2.3. Unfortunately PTVS does not work at all. I can not load any Python projects that were loading previously in Visual Studio. It worked before I installed Python 3.5. I tried to uninstall Python 2.7 and get an error saying that the uninstall didn't success. After several tries, the problem appears to be around pip which is somehow blocking both install and uninstall of Python 2.7. When trying to open Python Tools from Tools menu, nothing happens. Neither window opens nor any error message is displayed. Python Environments window does not open even with the shortcut. @@ -41887,8 +41887,8 @@ When trying to open Python Tools from Tools menu, nothing happens. Neither windo In Tools > Options > Python Tools, the only text shown is: ""An error occurred loading this property page"". When I try to load/reload the Python project, the message is: ""error : Expected 1 export(s) with contract name ""Microsoft.PythonTools.Interpreter.IInterpreterOptionsService"" but found 0 after applying applicable constraints."" This has already been posted for 11 days ago, but no one has answered. To solve this, I would like to know how to make the Python Environment window appearing in Visual Studio. -Thanks for any help.","Thanks for your posts. -My problem was fixed after I installed VS 2015 update 3 which included a new release of PTVS (June 2.2.40623).",0.0,False,3,4340 +Thanks for any help.","You'll need to open the ActivityLog.xml (%APPDATA%\Microsoft\VisualStudio\14.0\ActivityLog.xml) and see if there's any exceptions there related to PTVS. +It sounds like you have a pretty messed up configuration at this point. You could try uninstalling PTVS and re-installing it, but my guess is your messed up Python installs are somehow throwing PTVS off and causing it to crash somewhere.",0.0,False,3,4340 2016-06-09 17:48:01.297,Install RPi module on Pycharm,"I've been using IDLE with my raspberry for a while, it's nice at the beginning, but Pycharm provides lots more of features and I'm used to them since I've been also using Android Studio. The problem is I couldn't figure out how to install the RPi module to control the pins of my Raspberry. Does anyone know how to do this? In case it matters, it's python3 on a raspberry 2B.","You can run Pycharm directly on your Raspberry Pi: @@ -41929,8 +41929,9 @@ When I try to run scrapy from the command, with scrapy crawl ... for example, I The program 'scrapy' is currently not installed. -What's going on here? Are the symbolic links messed up? And any thoughts on how to fix it?","make sure you activate command that is -""Scripts\activate.bat""",0.0,False,5,4344 +What's going on here? Are the symbolic links messed up? And any thoughts on how to fix it?","I tried the following sudo pip install scrapy , however was promtly advised by Ubuntu 16.04 that it was already installed. +I had to first use sudo pip uninstall scrapy, then sudo pip install scrapy for it to successfully install. +Now you should successfully be able to run scrapy.",0.3072087248244539,False,5,4344 2016-06-10 21:12:07.610,"Scrapy installed, but won't run from the command line","I'm trying to run a scraping program I wrote for in python using scrapy on an ubuntu machine. Scrapy is installed. I can import until python no problem and when try pip install scrapy I get Requirement already satisfied (use --upgrade to upgrade): scrapy in /system/linux/lib/python2.7/dist-packages @@ -41939,16 +41940,7 @@ When I try to run scrapy from the command, with scrapy crawl ... for example, I The program 'scrapy' is currently not installed. -What's going on here? Are the symbolic links messed up? And any thoughts on how to fix it?","I had the same error. Running scrapy in a virtual environment solved it. - -Create a virtual env : python3 -m venv env -Activate your env : source env/bin/activate -Install Scrapy with pip : pip install scrapy -Start your crawler : scrapy crawl your_project_name_here - -For example my project name was kitten, I just did the following in step 4 -scrapy crawl kitten -NOTE: I did this on Mac OS running Python 3+",0.6203805995344163,False,5,4344 +What's going on here? Are the symbolic links messed up? And any thoughts on how to fix it?","I had the same issue. sudo pip install scrapy fixed my problem, although I don't know why must use sudo.",0.0,False,5,4344 2016-06-10 21:12:07.610,"Scrapy installed, but won't run from the command line","I'm trying to run a scraping program I wrote for in python using scrapy on an ubuntu machine. Scrapy is installed. I can import until python no problem and when try pip install scrapy I get Requirement already satisfied (use --upgrade to upgrade): scrapy in /system/linux/lib/python2.7/dist-packages @@ -41972,7 +41964,16 @@ When I try to run scrapy from the command, with scrapy crawl ... for example, I The program 'scrapy' is currently not installed. -What's going on here? Are the symbolic links messed up? And any thoughts on how to fix it?","I had the same issue. sudo pip install scrapy fixed my problem, although I don't know why must use sudo.",0.0,False,5,4344 +What's going on here? Are the symbolic links messed up? And any thoughts on how to fix it?","I had the same error. Running scrapy in a virtual environment solved it. + +Create a virtual env : python3 -m venv env +Activate your env : source env/bin/activate +Install Scrapy with pip : pip install scrapy +Start your crawler : scrapy crawl your_project_name_here + +For example my project name was kitten, I just did the following in step 4 +scrapy crawl kitten +NOTE: I did this on Mac OS running Python 3+",0.6203805995344163,False,5,4344 2016-06-10 21:12:07.610,"Scrapy installed, but won't run from the command line","I'm trying to run a scraping program I wrote for in python using scrapy on an ubuntu machine. Scrapy is installed. I can import until python no problem and when try pip install scrapy I get Requirement already satisfied (use --upgrade to upgrade): scrapy in /system/linux/lib/python2.7/dist-packages @@ -41981,9 +41982,8 @@ When I try to run scrapy from the command, with scrapy crawl ... for example, I The program 'scrapy' is currently not installed. -What's going on here? Are the symbolic links messed up? And any thoughts on how to fix it?","I tried the following sudo pip install scrapy , however was promtly advised by Ubuntu 16.04 that it was already installed. -I had to first use sudo pip uninstall scrapy, then sudo pip install scrapy for it to successfully install. -Now you should successfully be able to run scrapy.",0.3072087248244539,False,5,4344 +What's going on here? Are the symbolic links messed up? And any thoughts on how to fix it?","make sure you activate command that is +""Scripts\activate.bat""",0.0,False,5,4344 2016-06-11 19:33:25.763,Scikit-learn KNN(K Nearest Neighbors ) parallelize using Apache Spark,"I have been working on machine learning KNN (K Nearest Neighbors) algorithm with Python and Python's Scikit-learn machine learning API. I have created sample code with toy dataset simply using python and Scikit-learn and my KNN is working fine. But As we know Scikit-learn API is build to work on single machine and hence once I will replace my toy data with millions of dataset it will decrease my output performance. I have searched for many options, help and code examples, which will distribute my machine learning processing parallel using spark with Scikit-learn API, but I was not found any proper solution and examples. @@ -42022,14 +42022,6 @@ contests_by_user = Contest.objects.filter(id__in=pics_by_user.values_list('conte There might be an easier way though",0.0,False,1,4351 2016-06-16 04:55:19.567,"Odoo website, Creating a signup page for external users","How can I create a signup page in odoo website. The auth_signup module seems to do the job (according to their description). I don't know how to utilize it. -In the signup page there shouldn't be database selector -Where should I store the user data(including password); res.users or res.partner","User Signup is a standard feature provided by Odoo, and it seems that you already found it. -The database selector shows because you have several PostgresSSQL databases. -The easiest way is to set a filter that limits it to the one you want: -start the server with the option --dbfilter=^MYDB$, where MYDBis the database name. -User data is stored both in res.userand res.partner: the user specific data, such as login and password, are stored in res.user. Other data, such as the Name is stored in a related res.partner record.",0.2012947653214861,False,2,4352 -2016-06-16 04:55:19.567,"Odoo website, Creating a signup page for external users","How can I create a signup page in odoo website. The auth_signup module seems to do the job (according to their description). I don't know how to utilize it. - In the signup page there shouldn't be database selector Where should I store the user data(including password); res.users or res.partner","you can turn off db listing w/ some params in in odoo.cfg conf @@ -42039,6 +42031,14 @@ dbfilter = mydb auth_signup takes care of the registration, you don't need to do anything. A res.user will be created as well as a partner related to it. The pwd is stored in the user.",1.2,True,2,4352 +2016-06-16 04:55:19.567,"Odoo website, Creating a signup page for external users","How can I create a signup page in odoo website. The auth_signup module seems to do the job (according to their description). I don't know how to utilize it. + +In the signup page there shouldn't be database selector +Where should I store the user data(including password); res.users or res.partner","User Signup is a standard feature provided by Odoo, and it seems that you already found it. +The database selector shows because you have several PostgresSSQL databases. +The easiest way is to set a filter that limits it to the one you want: +start the server with the option --dbfilter=^MYDB$, where MYDBis the database name. +User data is stored both in res.userand res.partner: the user specific data, such as login and password, are stored in res.user. Other data, such as the Name is stored in a related res.partner record.",0.2012947653214861,False,2,4352 2016-06-16 09:24:58.713,Why does accumulate work for numpy.maximum but not numpy.argmax,"These two look like they should be very much equivalent and therefore what works for one should work for the other? So why does accumulate only work for maximum but not argmax? EDIT: A natural follow-up question is then how does one go about creating an efficient argmax accumulate in the most pythonic/numpy-esque way?","Because max is associative, but argmax is not: @@ -42127,11 +42127,6 @@ Any thoughts on how to resolve this?","I was able to resolve this issue using co Build successful, but the exe can't run. can not found msvcr100.dll. I can put msvcr100.dll with exe in the same dir, the exe can run. But I just want only one exe file. -Anyone know how to do?","Has solved. This is a bug of pyinstaller3.2, the new in the git has solved this bug. Down the newest source in the github, erverything works fine.",0.3869120172231254,False,2,4372 -2016-06-29 02:19:27.577,"pyinstaller 3.2 build pyqt4/python2.7 to onefile exe, can not run missing msvcr100.dll?","As title, -Build successful, but the exe can't run. can not found msvcr100.dll. -I can put msvcr100.dll with exe in the same dir, the exe can run. -But I just want only one exe file. Anyone know how to do?","Has solved. This is a bug of pyinstaller3.2, the new one in the git has solved this bug. Down the newest source in the GitHub, everything works fine. This is correct, I cant tell you how much that answer helped me out. I have been trying to build a single exe Exploit to execute on Windows XP with-out it crashing for my OSCP Labs/Exam. I followed so many tutorials and nothing seems to work. I was able to build the EXE but could not get it to run under a single EXE. @@ -42148,6 +42143,11 @@ Once that is completed, make sure Pyinstaller is in your $PATH and follow the st If this still doesn't work for you try using py2exe. Its a little more complicated but it your determined you will figure it out. If you have code written in python 2.x.x and 3.x.x you can have multiple environments of Python and have Pyinstaller installed in each. This is in the documentation as well. Thank you jim ying. Your 2 sentence answer was exactly what I needed.",0.3869120172231254,False,2,4372 +2016-06-29 02:19:27.577,"pyinstaller 3.2 build pyqt4/python2.7 to onefile exe, can not run missing msvcr100.dll?","As title, +Build successful, but the exe can't run. can not found msvcr100.dll. +I can put msvcr100.dll with exe in the same dir, the exe can run. +But I just want only one exe file. +Anyone know how to do?","Has solved. This is a bug of pyinstaller3.2, the new in the git has solved this bug. Down the newest source in the github, erverything works fine.",0.3869120172231254,False,2,4372 2016-06-29 15:01:00.750,"How to make GtkListView items flow from top to bottom, like in Thunar or Nautilus Compact View Mode?","I'm now practicing with Gtk by developing a file manager application similar to Thunar, and I simply can't figure out how to make the IconView items flow vertically instead of horizontally, like in Thunar or Nautilus' Compact View mode, as well as in Windows Explorer's List View Mode. Should I use TreeView istead? I'm practicing in Haskell bindings, the Gtk2Hs, but I'm also familiar with native C library and Python bindings (PyGtk), so explanations using these languages are also acceptable.","It finally seems that IconView has not such a feature right now, as Thunar uses its own control from libexo, while Caja/Nautilus use their own controls from other libraries.",1.2,True,1,4373 2016-06-30 10:17:12.550,How to get Webkit for Mac OS X,"I want to make a browser with Python GTK and Webkit for education purposes. I have GTK and it works, but I can't find how to get webkit for Mac OS X. I tried brew, pip3, easy_install. And I'm not sure if PyQT webkit port is the same as webkit.","For GTK3 @@ -42248,12 +42248,12 @@ The dot product is computed 'manually' by doing element-wise multiplication, the But now I want to change this password prompt that like ""your codes is:"". Dose anyone know how to do it?","The password prompt is part of keyboard-authentication which is part of the ssh protocol and thus cannot be changed. Technically, the prompt is actually client side. However, you can bypass security (very bad idea) and then output ""your codes is""[sic] via the channel",0.0,False,1,4387 2016-07-12 13:47:03.460,Sublime Text: How do you exit the multiple row layout,"I was wondering how you exit the multiple row layout on Sublime Text. I switched to a 3 row layout when editing one of my Django projects, but how do I exit from it (remove the extra rows I have added). Thanks, -Henry","Use View -> Layout menu. If you choose View -> Layout -> Single, other rows will be removed. Short keys depends on OS.",1.2,True,2,4388 -2016-07-12 13:47:03.460,Sublime Text: How do you exit the multiple row layout,"I was wondering how you exit the multiple row layout on Sublime Text. I switched to a 3 row layout when editing one of my Django projects, but how do I exit from it (remove the extra rows I have added). -Thanks, Henry","In the menu bar: View > Layout > Single Or from the keyboard (on Windows): Alt + Shift + 1 To find your default shortcuts, Preferences > Key Bindings - Default, and search for ""set_layout"".",0.3869120172231254,False,2,4388 +2016-07-12 13:47:03.460,Sublime Text: How do you exit the multiple row layout,"I was wondering how you exit the multiple row layout on Sublime Text. I switched to a 3 row layout when editing one of my Django projects, but how do I exit from it (remove the extra rows I have added). +Thanks, +Henry","Use View -> Layout menu. If you choose View -> Layout -> Single, other rows will be removed. Short keys depends on OS.",1.2,True,2,4388 2016-07-12 14:04:29.100,PyCharm Directly Open Python File,"I switched to PyCharm a couple of months ago, but I can't figure out how to get rid of the welcome screen when I open files. More specifically, I've set up my mac to open all .py files using PyCharm. However, when I double click on a .py file, it's the Welcome screen that opens up and not the .py file. How do I get PyCharm to just open the python script in the editor, without showing me a welcome screen?","PyCharm displays the Welcome screen when no project is open. From this screen, you can quickly access the major starting points of PyCharm. The Welcome screen appears when you close the current project in the only instance of PyCharm. If you are working with multiple projects, usually closing a project results in closing the PyCharm window in which it was running, except for the last project, closing this will show the Welcome screen.",0.0,False,1,4389 @@ -42409,12 +42409,12 @@ The problem is that the vectorization can be done either by words or n-grams but Looking through the documentation I didnt find how to do that, so is there any such option?","You seem to be misunderstanding what the TF-IDF vectorization is doing. For each word (or N-gram), it assigns a weight to the word which is a function of both the frequency of the term (TF) and of its inverse frequency of the other terms in the document (IDF). It makes sense to use it for words (e.g. knowing how often the word ""pizza"" comes up) or for N-grams (e.g. ""Cheese pizza"" for a 2-gram) Now, if you do it on lines, what will happen? Unless you happen to have a corpus in which lines are repeated exactly (e.g. ""I need help in Python""), your TF-IDF transformation will be garbage, as each sentence will appear exactly once in the document. And if your sentences are indeed always similar to the punctuation mark, then for all intents and purposes they are not sentences in your corpus, but words. This is why there is no option to do TF-IDF with sentences: it makes zero practical or theoretical sense.",1.2,True,1,4423 2016-07-28 03:00:06.023,Python pip installation not working how to do?,"I keep trying to install Pip using get-pip.py and only get the wheel file in the scripts folder. Try running ""pip"" in the command prompt and it just comes out with an error. Running windows 8 incase you need. -edit error is 'pip' is not recognized as an internal or external command...","Try navigating to ~/Python[version]/Scripts in cmd, then use pip[version] [command] [module] (ie. pip3 install themodulename or pip2 install themodulename)",0.0,False,2,4424 -2016-07-28 03:00:06.023,Python pip installation not working how to do?,"I keep trying to install Pip using get-pip.py and only get the wheel file in the scripts folder. Try running ""pip"" in the command prompt and it just comes out with an error. Running windows 8 incase you need. edit error is 'pip' is not recognized as an internal or external command...","If you are using latest version of Python. In computer properties, Go to Advanced System Settings -> Advanced tab -> Environmental Variables In System variables section, there is variable called PATH. Append c:\Python27\Scripts (Note append, not replace) Then open a new command prompt, try ""pip""",0.1352210990936997,False,2,4424 +2016-07-28 03:00:06.023,Python pip installation not working how to do?,"I keep trying to install Pip using get-pip.py and only get the wheel file in the scripts folder. Try running ""pip"" in the command prompt and it just comes out with an error. Running windows 8 incase you need. +edit error is 'pip' is not recognized as an internal or external command...","Try navigating to ~/Python[version]/Scripts in cmd, then use pip[version] [command] [module] (ie. pip3 install themodulename or pip2 install themodulename)",0.0,False,2,4424 2016-07-29 10:55:20.490,how to save jupyter output into a pdf file,"I am doing some data science analysis on jupyter and I wonder how to get all the output of my cell saved into a pdf file ? thanks","When I want to save a Jupyter Notebook I right click the mouse, select print, then change Destination to Save as PDF. This does not save the analysis outputs though. So if I want to save a regression output, for example, I highlight the output in Jupyter Notebook, right click, print, Save as PDF. This process creates fairly nice looking documents with code, interpretation and graphics all-in-one. There are programs that allow you to save more directly but I haven't been able to get them to work.",0.5457054096481145,False,1,4425 2016-07-30 10:15:26.823,Syntax error while installing seaborn using conda,"I've recently tried to install seaborn on ipython, which the latter was installed using anaconda. However, when I ran conda install seaborn, i was returned with a syntax error. I tried again with conda install -c anaconda seaborn=0.7.0 this time but syntax error was returned again. Apologies for my limited programming knowledge, but could anyone provide advice on how to resolve this issue?","conda is a command line tool, not a Python function. You should be typing these commands in a bash (or tcsh, etc.) shell, not in the IPython interpreter.",1.2,True,1,4426 @@ -42435,10 +42435,10 @@ Installing setuptools, pip, wheel...done. As you see, ST3 creates a Scripts inside the previous Scripts folder. As a result, the packages installed in step 4 are not used. I want to stop the creation of this second Scripts folder.","Solved. In ST3, use Virtualenv: Add Directory instead of Virtualenv: New. The latter creates a new virtualenv (hence the new Scripts folder).",0.0,False,1,4427 2016-08-01 10:30:34.620,Writing to particular address in memory in python,"I know python is a high level language and manages the memory allocation etc. on its own user/developer doesn't need to worry much unlike other languages like c, c++ etc. but is there a way through will we can write some value in a particular memory address in python -i know about id() which if hex type casted can give hexadecimal location but how can we write at a location.","Python itself does not include any facilities to allow the programmer direct access to memory. This means that sadly (or happily, depending on your outlook) the answer to your question is ""no"".",0.1016881243684853,False,2,4428 +i know about id() which if hex type casted can give hexadecimal location but how can we write at a location.","I can't advise how but I do know (one) why. Direct writing to registers allows one to set up a particular microcontroller. For example, configuring ports or peripherals. This is normally done in C (closer to hardware) but it would be a nice feature if you wanted to use Python for other reasons.",0.0,False,2,4428 2016-08-01 10:30:34.620,Writing to particular address in memory in python,"I know python is a high level language and manages the memory allocation etc. on its own user/developer doesn't need to worry much unlike other languages like c, c++ etc. but is there a way through will we can write some value in a particular memory address in python -i know about id() which if hex type casted can give hexadecimal location but how can we write at a location.","I can't advise how but I do know (one) why. Direct writing to registers allows one to set up a particular microcontroller. For example, configuring ports or peripherals. This is normally done in C (closer to hardware) but it would be a nice feature if you wanted to use Python for other reasons.",0.0,False,2,4428 +i know about id() which if hex type casted can give hexadecimal location but how can we write at a location.","Python itself does not include any facilities to allow the programmer direct access to memory. This means that sadly (or happily, depending on your outlook) the answer to your question is ""no"".",0.1016881243684853,False,2,4428 2016-08-01 16:37:02.753,Using Google Forms to write to multiple tables?,"I am creating a web project where I take in Form data and write to a SQL database. The forms will be a questionnaire with logic branching. Due to the nature of the form, and the fact that this is an MVP project, I've opted to use an existing form service (e.g Google Forms/Typeform). I was wondering if it's feasible to have form data submitted to multiple different tables (e.g CustomerInfo, FormDataA, FormDataB, etc.). While this might be possible with a custom form application, I do not think it's possible with Google Forms and/or Typeform. @@ -42474,13 +42474,13 @@ Googles edge cache will definitely cache static content especially if you app is You will probably need to use some cache busting techniques. You can test this by requesting the url that is presenting old content with the same url but appending something like ?x=1 to the url. If you then get current content then the edge cache is your problem and therefore the need to use cache busting techniques.",1.2,True,1,4432 +2016-08-04 06:08:58.867,How should we set the number of the neurons in the hidden layer in neural network?,In neural network theory - setting up the size of hidden layers seems to be a really important issue. Is there any criteria how to choose the number of neurons in a hidden layer?,"You have to set the number of neurons in hidden layer in such a way that it shouldn't be more than # of your training example. There are no thumb rule for number of neurons. +Ex: If you are using MINIST Dataset then you might have ~ 78K training example. So make sure that combination of Neural Network (784-30-10) = 784*30 + 30*10 which are less than training examples. but if you use like (784-100-10) then it exceeds the # of training example and highly probable to over-fit. +In short, make sure you are not over-fitting and hence you have good chances to get good result.",0.1352210990936997,False,2,4433 2016-08-04 06:08:58.867,How should we set the number of the neurons in the hidden layer in neural network?,In neural network theory - setting up the size of hidden layers seems to be a really important issue. Is there any criteria how to choose the number of neurons in a hidden layer?,"Yes - this is a really important issue. Basically there are two ways to do that: Try different topologies and choose best: due to the fact that number of neurons and layers are a discrete parameters you cannot differentiate your loss function with respect to this parameters in order to use a gradient descent methods. So the easiest way is to simply set up different topologies and compare them using either cross-validation or division of your training set to - training / testing / validating parts. You can also use a grid / random search schemas to do that. Libraries like scikit-learn have appropriate modules for that. Dropout: the training framework called dropout could also help. In this case you are setting up relatively big number of nodes in your layers and trying to adjust a dropout parameter for each layer. In this scenario - e.g. assuming that you will have a two-layer network with 100 nodes in your hidden layer with dropout_parameter = 0.6 you are learning the mixture of models - where every model is a neural network with size 40 (approximately 60 nodes are turned off). This might be also considered as figuring out the best topology for your task.",1.2,True,2,4433 -2016-08-04 06:08:58.867,How should we set the number of the neurons in the hidden layer in neural network?,In neural network theory - setting up the size of hidden layers seems to be a really important issue. Is there any criteria how to choose the number of neurons in a hidden layer?,"You have to set the number of neurons in hidden layer in such a way that it shouldn't be more than # of your training example. There are no thumb rule for number of neurons. -Ex: If you are using MINIST Dataset then you might have ~ 78K training example. So make sure that combination of Neural Network (784-30-10) = 784*30 + 30*10 which are less than training examples. but if you use like (784-100-10) then it exceeds the # of training example and highly probable to over-fit. -In short, make sure you are not over-fitting and hence you have good chances to get good result.",0.1352210990936997,False,2,4433 2016-08-04 20:02:17.877,Only call 'git stash pop' if there is anything to pop,"I am creating a post-commit script in Python and calling git commands using subprocess. In my script I want to stash all changes before I run some commands and then pop them back. The problem is that if there was nothing to stash, stash pop returns a none-zero error code resulting in an exception in subprocess.check_output(). I know how I can ignore the error return code, but I don't want to do it this way. So I have been thinking. Is there any way to get the number of items currently in stash? I know there is a command 'git stash list', but is there something more suited for my needs or some easy and safe way to parse the output of git stash list? @@ -42510,21 +42510,6 @@ PS: In my setup these files are both located in a folder: C:\Python35-32\Scripts",0.0,False,1,4436 2016-08-07 22:58:43.137,How to recover deleted iPython Notebooks,"I have iPython Notebook through Anaconda. I accidentally deleted an important notebook, and I can't seem to find it in trash (I don't think iPy Notebooks go to the trash). Does anyone know how I can recover the notebook? I am using Mac OS X. -Thanks!","This is bit of additional info on the answer by Thuener, -I did the following to recover my deleted .ipynb file. - -The cache is in ~/.cache/chromium/Default/Cache/ (I use chromium) -used grep in binary search mode, grep -a 'import math' (replace search string by a keyword specific in your code) -Edit the binary file in vim (it doesn't open in gedit) - - -The python ipynb should file start with '{ ""cells"":' and -ends with '""nbformat"": 4, ""nbformat_minor"": 2}' -remove everything outside these start and end points - -Rename the file as .ipynb, open it in your jupyter-notebook, it works.",0.7408590612005881,False,4,4437 -2016-08-07 22:58:43.137,How to recover deleted iPython Notebooks,"I have iPython Notebook through Anaconda. I accidentally deleted an important notebook, and I can't seem to find it in trash (I don't think iPy Notebooks go to the trash). -Does anyone know how I can recover the notebook? I am using Mac OS X. Thanks!","Sadly my file was neither in the checkpoints directory, nor chromium's cache. Fortunately, I had an ext4 formatted file system and was able to recover my file using extundelete: Figure out the drive your missing deleted file was stored on: @@ -42540,6 +42525,21 @@ If successful your recovered file will be located at: /your/alternate/location/your/deleted/file/diretory/delted.file",0.0,False,4,4437 2016-08-07 22:58:43.137,How to recover deleted iPython Notebooks,"I have iPython Notebook through Anaconda. I accidentally deleted an important notebook, and I can't seem to find it in trash (I don't think iPy Notebooks go to the trash). Does anyone know how I can recover the notebook? I am using Mac OS X. +Thanks!","This is bit of additional info on the answer by Thuener, +I did the following to recover my deleted .ipynb file. + +The cache is in ~/.cache/chromium/Default/Cache/ (I use chromium) +used grep in binary search mode, grep -a 'import math' (replace search string by a keyword specific in your code) +Edit the binary file in vim (it doesn't open in gedit) + + +The python ipynb should file start with '{ ""cells"":' and +ends with '""nbformat"": 4, ""nbformat_minor"": 2}' +remove everything outside these start and end points + +Rename the file as .ipynb, open it in your jupyter-notebook, it works.",0.7408590612005881,False,4,4437 +2016-08-07 22:58:43.137,How to recover deleted iPython Notebooks,"I have iPython Notebook through Anaconda. I accidentally deleted an important notebook, and I can't seem to find it in trash (I don't think iPy Notebooks go to the trash). +Does anyone know how I can recover the notebook? I am using Mac OS X. Thanks!","If you're using windows, it sends it to the recycle bin, thankfully. Clearly, it's a good idea to make checkpoints.",0.0340004944420038,False,4,4437 2016-08-07 22:58:43.137,How to recover deleted iPython Notebooks,"I have iPython Notebook through Anaconda. I accidentally deleted an important notebook, and I can't seem to find it in trash (I don't think iPy Notebooks go to the trash). Does anyone know how I can recover the notebook? I am using Mac OS X. @@ -42550,11 +42550,11 @@ I did the same error and I finally found the deleted file in the trash 2016-08-09 04:07:00.267,How do you deal with print() once you done with debugging/coding,"To python experts: I put lots of print() to check the value of my variables. Once I'm done, I need to delete the print(). It quite time-consuming and prompt to human errors. -Would like to learn how do you guys deal with print(). Do you delete it while coding or delete it at the end? Or there is a method to delete it automatically or you don't use print()to check the variable value?","What I do is put print statements in with with a special text marker in the string. I usually use print(""XXX"", thething). Then I just search for and delete the line with that string. It's also easier to spot in the output.",0.0,False,2,4439 +Would like to learn how do you guys deal with print(). Do you delete it while coding or delete it at the end? Or there is a method to delete it automatically or you don't use print()to check the variable value?","You can use logging with debug level and once the debugging is completed, change the level to info. So any statements with logger.debug() will not be printed.",0.2655860252697744,False,2,4439 2016-08-09 04:07:00.267,How do you deal with print() once you done with debugging/coding,"To python experts: I put lots of print() to check the value of my variables. Once I'm done, I need to delete the print(). It quite time-consuming and prompt to human errors. -Would like to learn how do you guys deal with print(). Do you delete it while coding or delete it at the end? Or there is a method to delete it automatically or you don't use print()to check the variable value?","You can use logging with debug level and once the debugging is completed, change the level to info. So any statements with logger.debug() will not be printed.",0.2655860252697744,False,2,4439 +Would like to learn how do you guys deal with print(). Do you delete it while coding or delete it at the end? Or there is a method to delete it automatically or you don't use print()to check the variable value?","What I do is put print statements in with with a special text marker in the string. I usually use print(""XXX"", thething). Then I just search for and delete the line with that string. It's also easier to spot in the output.",0.0,False,2,4439 2016-08-09 16:42:05.797,Running an R script from command line (to execute from python),"I'm currently trying to run an R script from the command line (my end goal is to execute it as the last line of a python script). I'm not sure what a batch file is, or how to make my R script 'executable'. Currently it is saved as a .R file. It works when I run it from R. How do I execute this from the windows command prompt line? Do i need to download something called Rscript.exe? Do I just save my R script as an .exe file? Please advise on the easiest way to achieve this. R: version 3.3 python: version 3.x os: windows","You probably already have R, since you can already run your script. @@ -42580,17 +42580,17 @@ Here's my situation: I have a skill and three Lambda functions (ARN:A, ARN:B, ARN:C). If I set the skill's endpoint to ARN:A and try to test it from the skill's service simulator, I get an error response: The remote endpoint could not be called, or the response it returned was invalid. I copy the lambda request, I head to the lambda console for ARN:A, I set the test even, paste the request from the service simulator, I test it and I get a perfectly fine ASK response. Then I head to the lambda console for ARN:B and I make a dummy handler that returns exactly the same response that ARN:A gave me from the console (literally copy and paste). I set my skill's endpoint to ARN:B, test it using the service simulator and I get the anticipated response (therefore, the response is well formatted) albeit static. I head to the lambda console again and copy and paste the code from ARN:A into a new ARN:C. Set the skill's endpoint to ARN:C and it works perfectly fine. Problem with ARN:C is that it doesn't have the proper permissions to persist data into DynamoDB (I'm still getting familiar with the system, not sure wether I can share an IAM role between different lambdas, I believe not). How can I figure out what's going on with ARN:A? Is that logged somewhere? I can't find any entry in cloudwatch/logs related to this particular lambda or for the skill. -Not sure if relevant, I'm using python for my lambda runtime, the code is (for now) inline on the web editor and I'm using boto3 for persisting to DynamoDB.","My guess would be that you missed a step on setup. There's one where you have to set the ""event source"". IF you don't do that, I think you get that message. -But the debug options are limited. I wrote EchoSim (the original one on GitHub) before the service simulator was written and, although it is a bit out of date, it does a better job of giving diagnostics. -Lacking debug options, the best is to do what you've done. Partition and re-test. Do static replies until you can work out where the problem is.",0.0,False,3,4444 +Not sure if relevant, I'm using python for my lambda runtime, the code is (for now) inline on the web editor and I'm using boto3 for persisting to DynamoDB.","tl;dr: The remote endpoint could not be called, or the response it returned was invalid. also means there may have been a timeout waiting for the endpoint. +I was able to narrow it down to a timeout. +Seems like the Alexa service simulator (and the Alexa itself) is less tolerant to long responses than the lambda testing console. During development I had increased the timeout of ARN:1 to 30 seconds (whereas I believe the default is 3 seconds). The DynamoDB table used by ARN:1 has more data and it takes slightly longer to process than ARN:3 which has an almost empty table. As soon as I commented out some of the data loading stuff it was running slightly faster and the Alexa service simulator was working again. I can't find the time budget documented anywhere, I'm guessing 3 seconds? I most likely need to move to another backend, DynamoDB+Python on lambda is too slow for very trivial requests.",1.2,True,3,4444 2016-08-11 04:02:31.683,Troubleshooting Amazon's Alexa Skill Kit (ASK) Lambda interaction,"I'm starting with ASK development. I'm a little confused by some behavior and I would like to know how to debug errors from the ""service simulator"" console. How can I get more information on the The remote endpoint could not be called, or the response it returned was invalid. errors? Here's my situation: I have a skill and three Lambda functions (ARN:A, ARN:B, ARN:C). If I set the skill's endpoint to ARN:A and try to test it from the skill's service simulator, I get an error response: The remote endpoint could not be called, or the response it returned was invalid. I copy the lambda request, I head to the lambda console for ARN:A, I set the test even, paste the request from the service simulator, I test it and I get a perfectly fine ASK response. Then I head to the lambda console for ARN:B and I make a dummy handler that returns exactly the same response that ARN:A gave me from the console (literally copy and paste). I set my skill's endpoint to ARN:B, test it using the service simulator and I get the anticipated response (therefore, the response is well formatted) albeit static. I head to the lambda console again and copy and paste the code from ARN:A into a new ARN:C. Set the skill's endpoint to ARN:C and it works perfectly fine. Problem with ARN:C is that it doesn't have the proper permissions to persist data into DynamoDB (I'm still getting familiar with the system, not sure wether I can share an IAM role between different lambdas, I believe not). How can I figure out what's going on with ARN:A? Is that logged somewhere? I can't find any entry in cloudwatch/logs related to this particular lambda or for the skill. -Not sure if relevant, I'm using python for my lambda runtime, the code is (for now) inline on the web editor and I'm using boto3 for persisting to DynamoDB.","tl;dr: The remote endpoint could not be called, or the response it returned was invalid. also means there may have been a timeout waiting for the endpoint. -I was able to narrow it down to a timeout. -Seems like the Alexa service simulator (and the Alexa itself) is less tolerant to long responses than the lambda testing console. During development I had increased the timeout of ARN:1 to 30 seconds (whereas I believe the default is 3 seconds). The DynamoDB table used by ARN:1 has more data and it takes slightly longer to process than ARN:3 which has an almost empty table. As soon as I commented out some of the data loading stuff it was running slightly faster and the Alexa service simulator was working again. I can't find the time budget documented anywhere, I'm guessing 3 seconds? I most likely need to move to another backend, DynamoDB+Python on lambda is too slow for very trivial requests.",1.2,True,3,4444 +Not sure if relevant, I'm using python for my lambda runtime, the code is (for now) inline on the web editor and I'm using boto3 for persisting to DynamoDB.","My guess would be that you missed a step on setup. There's one where you have to set the ""event source"". IF you don't do that, I think you get that message. +But the debug options are limited. I wrote EchoSim (the original one on GitHub) before the service simulator was written and, although it is a bit out of date, it does a better job of giving diagnostics. +Lacking debug options, the best is to do what you've done. Partition and re-test. Do static replies until you can work out where the problem is.",0.0,False,3,4444 2016-08-11 04:02:31.683,Troubleshooting Amazon's Alexa Skill Kit (ASK) Lambda interaction,"I'm starting with ASK development. I'm a little confused by some behavior and I would like to know how to debug errors from the ""service simulator"" console. How can I get more information on the The remote endpoint could not be called, or the response it returned was invalid. errors? Here's my situation: I have a skill and three Lambda functions (ARN:A, ARN:B, ARN:C). If I set the skill's endpoint to ARN:A and try to test it from the skill's service simulator, I get an error response: The remote endpoint could not be called, or the response it returned was invalid. @@ -42677,15 +42677,15 @@ I have a context processor for the template engine that will read from the envir 2016-08-16 03:16:30.193,Pycharm edu terminal plugin missing,"First time posting, let me know how I can improve my questions. I have installed PyCharm Edu 3.0 and Anaconda 3 on an older laptop. I am attempting to access the embedded terminal in the IDE and I am unable to launch it. I have searched through similar questions here and the JetBrains docs, and the common knowledge seems to be installing the ""Terminal"" Plugin. My version of PyCharm does not have this plugin, and I am unable to find it in the JetBrains plugin list or community repositories. -If anyone has experienced this before or knows where I am going wrong attempting to launch the terminal I would appreciate the feedback.",Click preferences and choose plugin. Next click install Jetbrains plugin and choose Command line Tool Support. I hope this will help you,-0.2012947653214861,False,2,4450 -2016-08-16 03:16:30.193,Pycharm edu terminal plugin missing,"First time posting, let me know how I can improve my questions. -I have installed PyCharm Edu 3.0 and Anaconda 3 on an older laptop. I am attempting to access the embedded terminal in the IDE and I am unable to launch it. -I have searched through similar questions here and the JetBrains docs, and the common knowledge seems to be installing the ""Terminal"" Plugin. My version of PyCharm does not have this plugin, and I am unable to find it in the JetBrains plugin list or community repositories. If anyone has experienced this before or knows where I am going wrong attempting to launch the terminal I would appreciate the feedback.","Go to File > Settings > Plugins > Browse repositories > Search and Install Native Terminal This will install a terminal which will use the Windows Native terminal. A small black button will appear on the tool bar. If you did not enable the tool bar, here is the trick: View | toolbar check this toolbar option and the cmd button will be shown on the bar",0.0,False,2,4450 +2016-08-16 03:16:30.193,Pycharm edu terminal plugin missing,"First time posting, let me know how I can improve my questions. +I have installed PyCharm Edu 3.0 and Anaconda 3 on an older laptop. I am attempting to access the embedded terminal in the IDE and I am unable to launch it. +I have searched through similar questions here and the JetBrains docs, and the common knowledge seems to be installing the ""Terminal"" Plugin. My version of PyCharm does not have this plugin, and I am unable to find it in the JetBrains plugin list or community repositories. +If anyone has experienced this before or knows where I am going wrong attempting to launch the terminal I would appreciate the feedback.",Click preferences and choose plugin. Next click install Jetbrains plugin and choose Command line Tool Support. I hope this will help you,-0.2012947653214861,False,2,4450 2016-08-16 04:09:26.390,Python3 Running atexit only on the main process,"I have a program that spawns multiple child processes, how would I make the program only call atexit.register(function) on the main process and not on the child processes as well? Thanks","The functions registered via atexit are inherited by the children processes. The simplest way to prevent that, is via calling atexit after you have spawned the children processes.",0.0,False,1,4451 @@ -42702,12 +42702,12 @@ The error is below: shiratori's answer helped me solve my problem, although at least for me it was slightly more complicated. Specifically, my nltk data was stored in C:\Users\USERNAME\AppData\Roaming\nltk_data (i think this is a default location). This is where it had always been stored, and always had worked fine, however suddenly nltk did not seem to be recognizing this location, and hence looked in the next drive. To solve it, I copied and pasted all the data in that folder to C:\nltk_data and now it is running fine again. Anyway, not sure if this is Windows induced problem, or what exactly changed to cause code that was working to stop working, but this solved it.",0.1352210990936997,False,1,4454 2016-08-17 06:49:29.810,How to install scikit-learn,"I know how to install external modules using the pip command but for Scikit-learn I need to install NumPy and Matplotlib as well. +How can I install these modules using the pip command?","Old post, but right answer is, +'sudo pip install -U numpy matplotlib --upgrade' for python2 or 'sudo pip3 install -U numpy matplotlib --upgrade' for python3",0.0,False,2,4455 +2016-08-17 06:49:29.810,How to install scikit-learn,"I know how to install external modules using the pip command but for Scikit-learn I need to install NumPy and Matplotlib as well. How can I install these modules using the pip command?","Using Python 3.4, I run the following from the command line: c:\python34\python.exe -m pip install package_name So you would substitute ""numpy"" and ""matplotlib"" for 'package_name'",-0.2012947653214861,False,2,4455 -2016-08-17 06:49:29.810,How to install scikit-learn,"I know how to install external modules using the pip command but for Scikit-learn I need to install NumPy and Matplotlib as well. -How can I install these modules using the pip command?","Old post, but right answer is, -'sudo pip install -U numpy matplotlib --upgrade' for python2 or 'sudo pip3 install -U numpy matplotlib --upgrade' for python3",0.0,False,2,4455 2016-08-17 18:30:17.467,Can't find TF_MIN_GPU_MULTIPROCESSOR_COUNT,"I get a message that says my GPU Device is ignored because its multiprocessor count is lower than the minimum set. However, it gives me the environment variable TF_MIN_GPU_MULTIPROCESSOR_COUNT but it doesn't seem to exist because I keep getting command not found. When I look at the environment variables using set or printenv and grep for the variable name, it doesn't exist. Does anyone know where I can find it or how I can change its set value?","Do something like this before running your main script export TF_MIN_GPU_MULTIPROCESSOR_COUNT=4 Note though that the default is set for a reason -- if you enable slower GPU by changing that variable, your program may run slower than it would without any GPU available, because TensorFlow will try to put run everything on that GPU",1.2,True,2,4456 @@ -42719,14 +42719,14 @@ public Class Foo { String pass = ""foo""; } how can I access this via jpype since pass is a reserved keyword? I tried -getattr(Jpype.JClass(Foo)(), ""pass"") but it fails to find the attribute named pass","Figured out that jpype appends an ""_"" at the end for those methods/fields in its source code. So you can access it by Jpype.JClass(""Foo"").pass_ -Wish it's documented somewhere",0.2012947653214861,False,2,4457 +getattr(Jpype.JClass(Foo)(), ""pass"") but it fails to find the attribute named pass",unfortunally Fields or methods conflicting with a python keyword can’t be accessed,0.0,False,2,4457 2016-08-17 23:37:01.227,jpype accessing java mehtod/variable whose name is reserved name in python,"Any idea how this can be done? ie, if we have a variable defined in java as below public Class Foo { String pass = ""foo""; } how can I access this via jpype since pass is a reserved keyword? I tried -getattr(Jpype.JClass(Foo)(), ""pass"") but it fails to find the attribute named pass",unfortunally Fields or methods conflicting with a python keyword can’t be accessed,0.0,False,2,4457 +getattr(Jpype.JClass(Foo)(), ""pass"") but it fails to find the attribute named pass","Figured out that jpype appends an ""_"" at the end for those methods/fields in its source code. So you can access it by Jpype.JClass(""Foo"").pass_ +Wish it's documented somewhere",0.2012947653214861,False,2,4457 2016-08-18 11:59:32.230,Django and celery on different servers and celery being able to send a callback to django once a task gets completed,"I have a django project where I am using celery with rabbitmq to perform a set of async. tasks. So the setup i have planned goes like this. Django app running on one server. @@ -42805,11 +42805,11 @@ The same says in the health status at AWS Console. So, my question is the following: How can I force Elastic Beanstalk to make the uploaded application version the current one so it doesn't complain?","I've realised that the problem was that Elastic Beanstalk, for some reasons, kept the unsuccessfully deployed versions under .elasticbeanstalk. The solution, at least in my case, was to remove those temporal (or whatever you call them) versions of the application.",1.2,True,1,4469 2016-08-30 01:50:27.790,How to convert a list by mapping an element into multiple elements in python?,"For example, how to convert [1, 5, 7] into [1,2,5,6,7,8] into python? -[x, x+1 for x in [1,5,7]] can't work for sure...","If you just want to fill the list with the numbers between the min and max+1 values you can use [i for i in range (min(x),max(x)+2)] assuming x is your list.",0.0,False,2,4470 -2016-08-30 01:50:27.790,How to convert a list by mapping an element into multiple elements in python?,"For example, -how to convert [1, 5, 7] into [1,2,5,6,7,8] into python? [x, x+1 for x in [1,5,7]] can't work for sure...","You can do your list comprehension logic with tuples and then flatten the resulting list: [n for pair in [(x, x+1) for x in [1,5,7]] for n in pair]",0.0582430451621389,False,2,4470 +2016-08-30 01:50:27.790,How to convert a list by mapping an element into multiple elements in python?,"For example, +how to convert [1, 5, 7] into [1,2,5,6,7,8] into python? +[x, x+1 for x in [1,5,7]] can't work for sure...","If you just want to fill the list with the numbers between the min and max+1 values you can use [i for i in range (min(x),max(x)+2)] assuming x is your list.",0.0,False,2,4470 2016-08-30 19:53:33.110,"how to install libhdf5-dev? (without yum, rpm nor apt-get)","I want to use h5py which needs libhdf5-dev to be installed. I installed hdf5 from the source, and thought that any options with compiling that one would offer me the developer headers, but doesn't look like it. Anyone know how I can do this? Is there some other source i need to download? (I cant find any though) I am on amazon linux, yum search libhdf5-dev doesn't give me any result and I cant use rpm nor apt-get there, hence I wanted to compile it myself.","For Centos 8, I got the below warning message : @@ -42836,14 +42836,14 @@ the pyd file was compiled with a 32 bit Python, was called with a 64 bit Python" I got (r'^\d{6}-\d{2}$') and (r'^\d{5}-\d{2}$') but how do you get the letter? -thanks!!","For the letter use [a-zA-Z], and if it's only upper case then [A-Z] is sufficient.",0.0,False,2,4474 +thanks!!","it seems the pattern generically is 6 characters with possible letter or number at last char max then - then 2 numbers? so then you'd use this pattern +pattern = r'^d{5}.+-\d{2}$'",0.0,False,2,4474 2016-08-31 19:42:23.270,Regular Expression with letter,"I need to match things that format something along the lines of 657432-76, 54678-01, 54364A-12 I got (r'^\d{6}-\d{2}$') and (r'^\d{5}-\d{2}$') but how do you get the letter? -thanks!!","it seems the pattern generically is 6 characters with possible letter or number at last char max then - then 2 numbers? so then you'd use this pattern -pattern = r'^d{5}.+-\d{2}$'",0.0,False,2,4474 +thanks!!","For the letter use [a-zA-Z], and if it's only upper case then [A-Z] is sufficient.",0.0,False,2,4474 2016-09-01 14:54:31.790,How to test RPC of SOAP web services?,"I am currently learning building a SOAP web services with django and spyne. I have successfully tested my model using unit test. However, when I tried to test all those @rpc functions, I have no luck there at all. What I have tried in testing those @rpc functions: 1. Get dummy data in model database @@ -42930,12 +42930,12 @@ Thanks in advance","A Tensor in TensorFlow is a node in the graph which, when ru 2016-09-08 06:03:42.833,Show distinct column values in pyspark dataframe,"With pyspark dataframe, how do you do the equivalent of Pandas df['col'].unique(). I want to list out all the unique values in a pyspark dataframe column. Not the SQL type way (registertemplate then SQL query for distinct values). -Also I don't need groupby then countDistinct, instead I want to check distinct VALUES in that column.","If you want to select ALL(columns) data as distinct frrom a DataFrame (df), then -df.select('*').distinct().show(10,truncate=False)",0.0407936753323291,False,2,4488 +Also I don't need groupby then countDistinct, instead I want to check distinct VALUES in that column.","You can use df.dropDuplicates(['col1','col2']) to get only distinct rows based on colX in the array.",0.694782670314738,False,2,4488 2016-09-08 06:03:42.833,Show distinct column values in pyspark dataframe,"With pyspark dataframe, how do you do the equivalent of Pandas df['col'].unique(). I want to list out all the unique values in a pyspark dataframe column. Not the SQL type way (registertemplate then SQL query for distinct values). -Also I don't need groupby then countDistinct, instead I want to check distinct VALUES in that column.","You can use df.dropDuplicates(['col1','col2']) to get only distinct rows based on colX in the array.",0.694782670314738,False,2,4488 +Also I don't need groupby then countDistinct, instead I want to check distinct VALUES in that column.","If you want to select ALL(columns) data as distinct frrom a DataFrame (df), then +df.select('*').distinct().show(10,truncate=False)",0.0407936753323291,False,2,4488 2016-09-08 10:01:02.473,How do I get Django to log why an sql transaction failed?,"I am trying to debug a Pootle (pootle is build on django) installation which fails with a django transaction error whenever I try to add a template to an existing language. Using the python debugger I can see that it fails when pootle tries to save a model as well as all the queries that have been made in that session. What I can't see is what specifically causes the save to fail. I figure pootle/django must have added some database database constraint, how do I figure out which one? MySql (the database being used) apparently can't log just failed transactions.","Install django debug toolbar, you can easily check all of the queries that have been executed",1.2,True,1,4489 2016-09-08 15:02:13.857,Comparing the contents of very large files efficiently,"I need to compare two files of differing formats quickly and I'm not sure how to do it. I would very much appreciate it if someone could point me in the right direction. @@ -43073,14 +43073,14 @@ Tweaking Python-interpreter, disabling gc.disable() at all and tuning the defaul 2016-09-22 18:11:26.080,How to read a .py file after I install Anaconda?,"I have installed Anaconda, but I do not know how to open a .py file.. If it is possible, please explain plainly, I browsed several threads, but I understood none of them.. Thanks a lot for your helps.. -Best,","You can use any text editor to open a .py file, e.g. TextMate, TextWrangler, TextEdit, PyCharm, AquaMacs, etc.",0.0,False,2,4502 -2016-09-22 18:11:26.080,How to read a .py file after I install Anaconda?,"I have installed Anaconda, but I do not know how to open a .py file.. -If it is possible, please explain plainly, I browsed several threads, but I understood none of them.. -Thanks a lot for your helps.. Best,","In the menu structure of your operating system, you should see a folder for Anaconda. In that folder is an icon for Spyder. Click that icon. After a while (Spyder loads slowly) you will see the Spyder integrated environment. You can choose File then Open from the menu, or just click the Open icon that looks like an open folder. In the resulting Open dialog box, navigate to the relevant folder and open the relevant .py file. The Open dialog box will see .py, .pyw, and .ipy files by default, but clicking the relevant list box will enable you to see and load many other kinds of files. Opening that file will load the contents into the editor section of Spyder. You can view or edit the file there, or use other parts of Spyder to run, debug, and do other things with the file. As of now, there is no in-built way to load a .py file in Spyder directly from the operating system. You can set that up in Windows by double-clicking a .py file, then choosing the spyder.exe file, and telling Windows to always use that application to load the file. The Anaconda developers have said that a soon-to-come version of Anaconda will modify the operating system so that .py and other files will load in Spyder with a double-click. But what I said above works for Windows. This answer was a bit condensed, since I do not know your level of understanding. Ask if you need more details.",1.2,True,2,4502 +2016-09-22 18:11:26.080,How to read a .py file after I install Anaconda?,"I have installed Anaconda, but I do not know how to open a .py file.. +If it is possible, please explain plainly, I browsed several threads, but I understood none of them.. +Thanks a lot for your helps.. +Best,","You can use any text editor to open a .py file, e.g. TextMate, TextWrangler, TextEdit, PyCharm, AquaMacs, etc.",0.0,False,2,4502 2016-09-23 11:32:25.740,force eclipse to use Python 3.5 autocompletion,"I changed the interpreter for my python projects from 2.x to 3.5 recently. The code interpretes correctly with the 3.5 version. I noticed that the autocompletion function of Eclipse still autocompletes as if I am using 2.x Python version. For example: print gets autocompleted without parenthesis as a statement and not as a function. Any idea how to notify the Eclipse that it need to use 3.5 autocompletion?","If you are using PyDev, make sure that interpreter grammar is set to 3.0 (right click project -> Properties -> PyDev - Interpreter/Grammar)",1.2,True,1,4503 2016-09-23 15:59:10.440,Python sending files from a user directory to another user directory,I am very new to Python. I am curious to how I would be able to copy some files from my directory to another Users directory on my computer using python script? And would I be correct in saying I need to check the permissions of the users and files? So my question is how do I send files and also check the permissions at the same time,"shutil is a very usefull thing to use when copying files. @@ -43172,11 +43172,11 @@ Thank you.",There is always a widget with the keyboard focus. You can query that 2016-09-29 13:42:07.020,Is it possible to include interpreter path (or set any default code) when I create new python file in Pycharm?,"I haven't been able to find anything and I am not sure if this is the place I should be asking... But I want to include the path to my interpreter in every new project I create. The reason being is that I develop locally and sync my files to a linux server. It is annoying having to manually type #! /users/w/x/y/z/bin/python every time I create a new project. Also would be nice to include certain imports I use 90% of the time. I got to thinking, in the program I produce music with you can set a default project file. Meaning, when you click new project it is set up how you have configured (include certain virtual instruments, effects, etc). -Is it possible to do this or something similar with IDE, and more specifically, Pycharm?","Click on the top-right tab with your project name, then go Edit Configurations and there you can change the interpreter.",0.0,False,2,4517 +Is it possible to do this or something similar with IDE, and more specifically, Pycharm?","You should open File in the main menu and click Default Settings, collapse the Editor then click File and Code Templates, in the Files tab click on the + sign and create a new Template, give the new template a name and extension, in the editor box put your template content, in your case #! /users/w/x/y/z/bin/python apply and OK. After that everytime you open a project, select that template to include default lines you want. You could make number of templates.",1.2,True,2,4517 2016-09-29 13:42:07.020,Is it possible to include interpreter path (or set any default code) when I create new python file in Pycharm?,"I haven't been able to find anything and I am not sure if this is the place I should be asking... But I want to include the path to my interpreter in every new project I create. The reason being is that I develop locally and sync my files to a linux server. It is annoying having to manually type #! /users/w/x/y/z/bin/python every time I create a new project. Also would be nice to include certain imports I use 90% of the time. I got to thinking, in the program I produce music with you can set a default project file. Meaning, when you click new project it is set up how you have configured (include certain virtual instruments, effects, etc). -Is it possible to do this or something similar with IDE, and more specifically, Pycharm?","You should open File in the main menu and click Default Settings, collapse the Editor then click File and Code Templates, in the Files tab click on the + sign and create a new Template, give the new template a name and extension, in the editor box put your template content, in your case #! /users/w/x/y/z/bin/python apply and OK. After that everytime you open a project, select that template to include default lines you want. You could make number of templates.",1.2,True,2,4517 +Is it possible to do this or something similar with IDE, and more specifically, Pycharm?","Click on the top-right tab with your project name, then go Edit Configurations and there you can change the interpreter.",0.0,False,2,4517 2016-09-29 14:49:55.217,Adding a text box to an excel chart using openpyxl,"I'm trying to add a text box to a chart I've generated with openpyxl, but can't find documentation or examples showing how to do so. Does openpyxl support it?","I'm not sure what you mean by ""text box"". In theory you can add pretty much anything covered by the DrawingML specification to a chart but the practice may be slightly different. However, there is definitely no built-in API for this so you'd have to start by creating a sample file and working backwards from it.",0.0,False,1,4518 2016-09-29 20:27:59.523,how to export data to unix system location using python,"I am trying to write the file to my company's project folder which is unix system and the location is /department/projects/data/. So I used the following code @@ -43213,13 +43213,13 @@ Hope this helps. Regards.",1.2,True,1,4523 2016-10-03 17:11:54.947,Automate file downloading using a chrome extension,"I have a .csv file with a list of URLs I need to extract data from. I need to automate the following process: (1) Go to a URL in the file. (2) Click the chrome extension that will redirect me to another page which displays some of the URL's stats. (3) Click the link in the stats page that enables me to download the data as a .csv file. (4) Save the .csv. (5) Repeat for the next n URLs. Any idea how to do this? Any help greatly appreciated!",There is a python package called mechanize. It helps you automate the processes that can be done on a browser. So check it out.I think mechanize should give you all the tools required to solve the problem.,0.0,False,1,4524 +2016-10-04 11:51:11.397,Using pip on Windows installed with both python 2.7 and 3.5,"I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version?","The answer from Farhan.K will work. However, I think a more convenient way would be to rename python35\Scripts\pip.exe to python35\Scripts\pip3.exe assuming python 3 is installed in C:\python35. +After renaming, you can use pip3 when installing packages to python v3 and pip when installing packages to python v2. Without the renaming, your computer will use whichever pip is in your path.",0.0509761841073563,False,4,4525 2016-10-04 11:51:11.397,Using pip on Windows installed with both python 2.7 and 3.5,"I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version?","You will have to use the absolute path of pip. E.g: if I installed python 3 to C:\python35, I would use: C:\> python35\Scripts\pip.exe install packagename Or if you're on linux, use pip3 install packagename If you don't specify a full path, it will use whichever pip is in your path.",1.2,True,4,4525 -2016-10-04 11:51:11.397,Using pip on Windows installed with both python 2.7 and 3.5,"I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version?","The answer from Farhan.K will work. However, I think a more convenient way would be to rename python35\Scripts\pip.exe to python35\Scripts\pip3.exe assuming python 3 is installed in C:\python35. -After renaming, you can use pip3 when installing packages to python v3 and pip when installing packages to python v2. Without the renaming, your computer will use whichever pip is in your path.",0.0509761841073563,False,4,4525 2016-10-04 11:51:11.397,Using pip on Windows installed with both python 2.7 and 3.5,"I am using Windows 10. Currently, I have Python 2.7 installed. I would like to install Python 3.5 as well. However, if I have both 2.7 and 3.5 installed, when I run pip, how do I get the direct the package to be installed to the desired Python version?","I tried many things , then finally pip3 install --upgrade pip worked for me as i was facing this issue since i had both python3 and python2.7 installed on my system. mind the pip3 in the beginning and pip in the end. @@ -43229,10 +43229,10 @@ And yes you do have to run in admin mode the command prompt and make sure if the 3- close the command prompt and reopen it again to return to the default direction and use the command pip3.exe install package_name to install any package you want",-0.0509761841073563,False,4,4525 2016-10-04 20:22:27.530,How to DISABLE Jupyter notebook matplotlib plot inline?,"Well, I know I can use %matplotlib inline to plot inline. However, how to disable it? -Sometime I just want to zoom in the figure that I plotted. Which I can't do on a inline-figure.",Use %matplotlib notebook to change to a zoom-able display.,1.2,True,2,4526 +Sometime I just want to zoom in the figure that I plotted. Which I can't do on a inline-figure.",%matplotlib auto should switch to the default backend.,0.5457054096481145,False,2,4526 2016-10-04 20:22:27.530,How to DISABLE Jupyter notebook matplotlib plot inline?,"Well, I know I can use %matplotlib inline to plot inline. However, how to disable it? -Sometime I just want to zoom in the figure that I plotted. Which I can't do on a inline-figure.",%matplotlib auto should switch to the default backend.,0.5457054096481145,False,2,4526 +Sometime I just want to zoom in the figure that I plotted. Which I can't do on a inline-figure.",Use %matplotlib notebook to change to a zoom-able display.,1.2,True,2,4526 2016-10-05 18:06:56.533,In-house made package and environmental variables link,"I created a python package for in-house use which relies upon some environmental variables (namely, the user and password to enter an online database). for my company, the convenience of installing a package rather than having it in every project is significant as the functions inside are used in completely separate projects and maintainability is a primary issue. so, how do I ""link"" the package with the environmental variables?",I think I'll just detail in the readme file what to insert and where. I tried to find a difficult solution when it was really simple and straightforward,0.0,False,1,4527 2016-10-05 19:49:37.127,django-tables2 flooding database with queries,"im using django-tables2 in order to show values from a database query. And everythings works fine. Im now using Django-dabug-toolbar and was looking through my pages with it. More out of curiosity than performance needs. When a lokked at the page with the table i saw that the debug toolbar registerd over 300 queries for a table with a little over 300 entries. I dont think flooding the DB with so many queries is a good idea even if there is no performance impact (at least not now). All the data should be coming from only one query. @@ -43283,11 +43283,7 @@ Error: spawn python ENOENT Could someone please help me out and tell me how to fix this? I'm running on windows 10. -Thanks!","Add python path by following these steps. -1. Go to uninstall a program. -2. Go to Python 3.6.1 (this is my python version). Select and click on Uninstall/change. -3.Click on Modify. -4. Click next > In advanced options > tick add Python to environment variable. Click install. Restart VS code.",0.0679224682270276,False,5,4533 +Thanks!",Simply restart your VB studio code. Those show that some packages have been downloaded but not yet installed until reboot it.,0.0679224682270276,False,5,4533 2016-10-10 00:18:44.023,"Visual Studio Python ""Failed to launch the Python Process, please validate the path 'python'' & Error: spawn python ENOENT","I just downloaded Python and Visual Studio. I'm trying to test the debugging feature for a simple ""Hello World"" script and I'm receiving this error: Failed to launch the Python Process, please validate the path 'python' @@ -43298,13 +43294,8 @@ Error: spawn python ENOENT Could someone please help me out and tell me how to fix this? I'm running on windows 10. -Thanks!","Do not uninstall! -1) Go to location that you installed the program. -*example: C:\Program Files (x86)\Microsoft VS Code -copy the location. -2) right click on computer> properties >Advanced System Settings> Environment variables > under user variables find ""path"" click> edit> under variable value: go to the end of the line add ; then paste your location>ok > then go under system variables find ""path""> do the same thing.... add ; then paste your location. - FOR EXAMPLE"" ;C:\Program Files (x86)\Microsoft VS Code -3) Restart your Visual Studio Code",0.4431875092007125,False,5,4533 +Thanks!","Figured it out, if you just started python then you probably did not add python to your path. +To do so uninstall python and then reinstall it. This time click ""add python to path"" at the bottom of the install screen.",0.0,False,5,4533 2016-10-10 00:18:44.023,"Visual Studio Python ""Failed to launch the Python Process, please validate the path 'python'' & Error: spawn python ENOENT","I just downloaded Python and Visual Studio. I'm trying to test the debugging feature for a simple ""Hello World"" script and I'm receiving this error: Failed to launch the Python Process, please validate the path 'python' @@ -43315,8 +43306,13 @@ Error: spawn python ENOENT Could someone please help me out and tell me how to fix this? I'm running on windows 10. -Thanks!","Figured it out, if you just started python then you probably did not add python to your path. -To do so uninstall python and then reinstall it. This time click ""add python to path"" at the bottom of the install screen.",0.0,False,5,4533 +Thanks!","Do not uninstall! +1) Go to location that you installed the program. +*example: C:\Program Files (x86)\Microsoft VS Code +copy the location. +2) right click on computer> properties >Advanced System Settings> Environment variables > under user variables find ""path"" click> edit> under variable value: go to the end of the line add ; then paste your location>ok > then go under system variables find ""path""> do the same thing.... add ; then paste your location. + FOR EXAMPLE"" ;C:\Program Files (x86)\Microsoft VS Code +3) Restart your Visual Studio Code",0.4431875092007125,False,5,4533 2016-10-10 00:18:44.023,"Visual Studio Python ""Failed to launch the Python Process, please validate the path 'python'' & Error: spawn python ENOENT","I just downloaded Python and Visual Studio. I'm trying to test the debugging feature for a simple ""Hello World"" script and I'm receiving this error: Failed to launch the Python Process, please validate the path 'python' @@ -43327,7 +43323,11 @@ Error: spawn python ENOENT Could someone please help me out and tell me how to fix this? I'm running on windows 10. -Thanks!",Simply restart your VB studio code. Those show that some packages have been downloaded but not yet installed until reboot it.,0.0679224682270276,False,5,4533 +Thanks!","Add python path by following these steps. +1. Go to uninstall a program. +2. Go to Python 3.6.1 (this is my python version). Select and click on Uninstall/change. +3.Click on Modify. +4. Click next > In advanced options > tick add Python to environment variable. Click install. Restart VS code.",0.0679224682270276,False,5,4533 2016-10-10 12:46:26.873,One of threads rewrites console input in Python,"I have a problem with console app with threading. In first thread i have a function, which write symbol ""x"" into output. In second thread i have function, which waiting for users input. (Symbol ""x"" is just random choice for this question). For ex. Thread 1: @@ -43387,9 +43387,7 @@ bokeh seems promising, but really taxes my jupyter kernel. Bonus: The nonzero entries of X are positive real numbers. If there was some way to reflect their magnitude, that would be great as well (e.g. colour intensity, transparency, or across a colour bar). -Every 500 rows of X belong to the same class. That's 12 classes * 500 observations (rows) per class = 6000 rows. E.g. X[:500] are from class A, X[500:1000] are from class B, etc. Would be nice to colour-code the dots by class. For the moment I'll settle for manually including horizontal lines every 500 rows to delineate between classes.","It seems to me heatmap is the best candidate for this type of plot. imshow() will return u a colored matrix with color scale legend. -I don't get ur stretched ellipses problem, shouldnt it be a colored squred for each data point? -u can try log color scale if it is sparse. also plot the 12 classes separately to analyze if theres any inter-class differences.",0.0,False,2,4536 +Every 500 rows of X belong to the same class. That's 12 classes * 500 observations (rows) per class = 6000 rows. E.g. X[:500] are from class A, X[500:1000] are from class B, etc. Would be nice to colour-code the dots by class. For the moment I'll settle for manually including horizontal lines every 500 rows to delineate between classes.",plt.matshow also turned out to be a feasible solution. I could also plot a heatmap with colorbars and all that.,0.0,False,2,4536 2016-10-11 04:29:47.253,Python: Plot a sparse matrix,"I have a sparse matrix X, shape (6000, 300). I'd like something like a scatterplot which has a dot where the X(i, j) != 0, and blank space otherwise. I don't know how many nonzero entries there are in each row of X. X[0] has 15 nonzero entries, X[1] has 3, etc. The maximum number of nonzero entries in a row is 16. Attempts: @@ -43400,7 +43398,9 @@ bokeh seems promising, but really taxes my jupyter kernel. Bonus: The nonzero entries of X are positive real numbers. If there was some way to reflect their magnitude, that would be great as well (e.g. colour intensity, transparency, or across a colour bar). -Every 500 rows of X belong to the same class. That's 12 classes * 500 observations (rows) per class = 6000 rows. E.g. X[:500] are from class A, X[500:1000] are from class B, etc. Would be nice to colour-code the dots by class. For the moment I'll settle for manually including horizontal lines every 500 rows to delineate between classes.",plt.matshow also turned out to be a feasible solution. I could also plot a heatmap with colorbars and all that.,0.0,False,2,4536 +Every 500 rows of X belong to the same class. That's 12 classes * 500 observations (rows) per class = 6000 rows. E.g. X[:500] are from class A, X[500:1000] are from class B, etc. Would be nice to colour-code the dots by class. For the moment I'll settle for manually including horizontal lines every 500 rows to delineate between classes.","It seems to me heatmap is the best candidate for this type of plot. imshow() will return u a colored matrix with color scale legend. +I don't get ur stretched ellipses problem, shouldnt it be a colored squred for each data point? +u can try log color scale if it is sparse. also plot the 12 classes separately to analyze if theres any inter-class differences.",0.0,False,2,4536 2016-10-11 07:25:02.260,"How to update pandas when python is installed as part of ArcGIS10.4, or another solution","I recently installed ArcGIS10.4 and now when I run python 2.7 programs using Idle (for purposes unrelated to ArcGIS) it uses the version of python attached to ArcGIS. One of the programs I wrote needs an updated version of the pandas module. When I try to update the pandas module in this verion of python (by opening command prompt as an administrator, moving to C:\Python27\ArcGIS10.4\Scripts and using the command pip install --upgrade pandas) the files download ok but there is an access error message when PIP tries to upgrade. I have tried restarting the computer in case something was open. The error message is quite long and I can't cut and paste from command prompt but it finishes with "" Permission denied: 'C:\Python27\ArcGIS10.4\Lib\site-packages\numpy\core\multiarray.pyd' "" @@ -43489,8 +43489,9 @@ Using leader_only option with ebextensions: Works fine initially, but if an EC2 Creating a new Django app just for async tasks in the Elastic Beanstalk worker tier: Nice, because web servers and workers can be scaled independently and the web server performance is not affected by huge async work loads performed by the workers. However, this approach does not work with Celery because the worker tier SQS daemon removes messages and posts the message bodies to a predefined urls. Additionally, I don't like the idea of having a complete additional Django app that needs to import the models from the main app and needs to be separately updated and deployed if the tasks are modified in the main app. How to I use Celery with scheduled tasks in a distributed Elastic Beanstalk environment without task duplication? E.g. how can I make sure that exactly one instance is running across all instances all the time in the Elastic Beanstalk environment (even if the current instance with Celerybeat crashes)? -Are there any other ways to achieve this? What's the best way to use Elastic Beanstalk's Worker Tier Environment with Django?","In case someone experience similar issues: I ended up switching to a different Queue / Task framework for django. It is called django-q and was set up and working in less than an hour. It has all the features that I needed and also better Django integration than Celery (since djcelery is no longer active). -Django-q is super easy to use and also lighter than the huge Celery framework. I can only recommend it!",1.2,True,2,4547 +Are there any other ways to achieve this? What's the best way to use Elastic Beanstalk's Worker Tier Environment with Django?","I guess you could single out celery beat to different group. +Your auto scaling group runs multiple django instances, but celery is not included in the ec2 config of the scaling group. +You should have different set (or just one) of instance for celery beat",0.2012947653214861,False,2,4547 2016-10-19 00:48:48.457,Multiple instances of celerybeat for autoscaled django app on elasticbeanstalk,"I am trying to figure out the best way to structure a Django app that uses Celery to handle async and scheduled tasks in an autoscaling AWS ElasticBeanstalk environment. So far I have used only a single instance Elastic Beanstalk environment with Celery + Celerybeat and this worked perfectly fine. However, I want to have multiple instances running in my environment, because every now and then an instance crashes and it takes a lot of time until the instance is back up, but I can't scale my current architecture to more than one instance because Celerybeat is supposed to be running only once across all instances as otherwise every task scheduled by Celerybeat will be submitted multiple times (once for every EC2 instance in the environment). I have read about multiple solutions, but all of them seem to have issues that don't make it work for me: @@ -43500,9 +43501,8 @@ Using leader_only option with ebextensions: Works fine initially, but if an EC2 Creating a new Django app just for async tasks in the Elastic Beanstalk worker tier: Nice, because web servers and workers can be scaled independently and the web server performance is not affected by huge async work loads performed by the workers. However, this approach does not work with Celery because the worker tier SQS daemon removes messages and posts the message bodies to a predefined urls. Additionally, I don't like the idea of having a complete additional Django app that needs to import the models from the main app and needs to be separately updated and deployed if the tasks are modified in the main app. How to I use Celery with scheduled tasks in a distributed Elastic Beanstalk environment without task duplication? E.g. how can I make sure that exactly one instance is running across all instances all the time in the Elastic Beanstalk environment (even if the current instance with Celerybeat crashes)? -Are there any other ways to achieve this? What's the best way to use Elastic Beanstalk's Worker Tier Environment with Django?","I guess you could single out celery beat to different group. -Your auto scaling group runs multiple django instances, but celery is not included in the ec2 config of the scaling group. -You should have different set (or just one) of instance for celery beat",0.2012947653214861,False,2,4547 +Are there any other ways to achieve this? What's the best way to use Elastic Beanstalk's Worker Tier Environment with Django?","In case someone experience similar issues: I ended up switching to a different Queue / Task framework for django. It is called django-q and was set up and working in less than an hour. It has all the features that I needed and also better Django integration than Celery (since djcelery is no longer active). +Django-q is super easy to use and also lighter than the huge Celery framework. I can only recommend it!",1.2,True,2,4547 2016-10-19 08:47:26.880,Split and shift RGB channels in Python,"What I'm trying to do is recreating what is commonly called an ""RGB shift"" effect, which is very easy to achieve with image manipulation programs. I imagine I can ""split"" the channels of the image by either opening the image as a matrix of triples or opening the image three times and every time operate just on one channel, but I wouldn't know how to ""offset"" the channels when merging them back together (possibly by creating a new image and position each channel's [0,0] pixel in an offsetted position?) and reduce each channel's opacity as to not show just the last channel inserted into the image. Has anyone tried to do this? Do you know if it is possible? If so, how did you do it? @@ -43525,11 +43525,6 @@ gmap=gmplot.GoogleMapPlotter(""Seattle"") gmap.marker(47.61028142523736, -122.34147349538826, title=""A street corner in Seattle"") st=""testmap.html"" gmap.draw(st)",0.9999092042625952,False,1,4550 -2016-10-20 07:39:41.337,jupyter notebook select python,"I have anaconda2 and anaconda3 installed on windows machine, have no access to internet and administrator rights. How can I switch between python 2 and 3 when starting jupyter? Basic ""jupyter notebook"" command starts python 2. With internet I would just add environment for python 3 and select it in jupyter notebook after start but how can I do this in this situation?","Did you install python by Anaconda? -Try to install under Anaconda2/envs when choosing destination folder, -like this: -D:/Anaconda2/envs/py3 -then""activate py3"" by cmd, py3 must be then same name of installation folder",0.0,False,2,4551 2016-10-20 07:39:41.337,jupyter notebook select python,"I have anaconda2 and anaconda3 installed on windows machine, have no access to internet and administrator rights. How can I switch between python 2 and 3 when starting jupyter? Basic ""jupyter notebook"" command starts python 2. With internet I would just add environment for python 3 and select it in jupyter notebook after start but how can I do this in this situation?","There's important points to consider: you have to have jupyter notebook installed in each environment you want to run it from @@ -43539,6 +43534,11 @@ You can list the packages in your environment with conda list. You can also chec From what you write, since your notebook defaults to python2, conda list should show you python 2 related packages. So, as has been pointed, first activate the anaconda environment for python3 with the command activate your_python3_environment then restart your Notebook. You don't need internet for this but you do need to be able to swap between anaconda2 and 3 (which you say are both installed) and both should have jupyter installed.",0.2012947653214861,False,2,4551 +2016-10-20 07:39:41.337,jupyter notebook select python,"I have anaconda2 and anaconda3 installed on windows machine, have no access to internet and administrator rights. How can I switch between python 2 and 3 when starting jupyter? Basic ""jupyter notebook"" command starts python 2. With internet I would just add environment for python 3 and select it in jupyter notebook after start but how can I do this in this situation?","Did you install python by Anaconda? +Try to install under Anaconda2/envs when choosing destination folder, +like this: +D:/Anaconda2/envs/py3 +then""activate py3"" by cmd, py3 must be then same name of installation folder",0.0,False,2,4551 2016-10-22 14:38:16.543,How to check if a CSV has a header using Python?,I have a CSV file and I want to check if the first row has only strings in it (ie a header). I'm trying to avoid using any extras like pandas etc. I'm thinking I'll use an if statement like if row[0] is a string print this is a CSV but I don't really know how to do that :-S any suggestions?,I think the best way to check this is -> simply reading 1st line from file and then match your string instead of any library.,0.0,False,1,4552 2016-10-22 15:47:29.577,Can't launch Spyder on windows 7,"After installing Winpython on windows 7 64 bits, when I launch Spyder I face this: ImportError: No module named encodings @@ -43843,11 +43843,11 @@ I would like to know how is it executed by the interpreter exactly. I think that python module is compiled to a bytecode and then it will be interpreted. In the case of C/C++ module functions from a such module are just executed. So, jump to the address and start execution. Please correct me if I am wrong/ Please say more.","When you import a C extension, python uses the platform's shared library loader to load the library and then, as you say, jumps to a function in the library. But you can't load just any library or jump to any function this way. It only works for libs specifically implemented to support python and to functions that are exported by the library as a python object. The lib must understand python objects and use those objects to communicate. Alternately, instead of importing, you can use a foreign-function library like ctypes to load the library and convert data to the C view of data to make calls.",1.2,True,1,4580 +2016-11-06 17:50:55.907,How to structure a very small Django Project?,"It is a little oxymoron now that I am making a small Django project that it is hard to decide how to structure such project. Before I will at least will have 10 to 100 apps per project. Now my project is just a website that presents information about a company with no use database, meaning it's really static, with only 10 to 20 pages. Now how do you start, do you create an app for such project.","Frankly I won't use Django in that case, I would use Flask for such small projects. it's easy to learn and setup a small website. +PS: I use Flask in small and large apps!",0.1352210990936997,False,2,4581 2016-11-06 17:50:55.907,How to structure a very small Django Project?,"It is a little oxymoron now that I am making a small Django project that it is hard to decide how to structure such project. Before I will at least will have 10 to 100 apps per project. Now my project is just a website that presents information about a company with no use database, meaning it's really static, with only 10 to 20 pages. Now how do you start, do you create an app for such project.","meaning it's really static Use nginx to serve static files. Do not use django. You will setup project structure when it will be required.",0.3869120172231254,False,2,4581 -2016-11-06 17:50:55.907,How to structure a very small Django Project?,"It is a little oxymoron now that I am making a small Django project that it is hard to decide how to structure such project. Before I will at least will have 10 to 100 apps per project. Now my project is just a website that presents information about a company with no use database, meaning it's really static, with only 10 to 20 pages. Now how do you start, do you create an app for such project.","Frankly I won't use Django in that case, I would use Flask for such small projects. it's easy to learn and setup a small website. -PS: I use Flask in small and large apps!",0.1352210990936997,False,2,4581 2016-11-06 21:47:15.293,Simple algorithm to move from one tile to another using only a chess knight's moves,"I have a problem shown below that wants to find the quickest way to get between any two points by using only the moves of a knight in chess. My first thought was to us the A* algorithm or Dijkstra's algorithm however, I don't know how to make sure only the moves of a knight are used. I would appreciate it if you could suggest a better algorithm or just some tips to help me. Thank you. Write a function called answer(src, dest) which takes in two parameters: the source square, on which you start, and the destination square, which is where you need to land to solve the puzzle. The function should return an integer representing the smallest number of moves it will take for you to travel from the source square to the destination square using a chess knight's moves (that is, two squares in any direction immediately followed by one square perpendicular to that direction, or vice versa, in an ""L"" shape). Both the source and destination squares will be an integer between 0 and 63, inclusive, and are numbered like the example chessboard below: @@ -43869,9 +43869,10 @@ Write a function called answer(src, dest) which takes in two parameters: the sou |48|49|50|51|52|53|54|55| ------------------------- |56|57|58|59|60|61|62|63| --------------------------","For this problem, simply doing a breadth-first search is enough (Dijkstra and BFS work in same way for unweighted graphs). To ensure that only the chess knight's moves are used, you'll have to define the moves in a proper way. -Notice that a chess knight moves two squares to any direction, then one square perpendicular to that. This means it can move two squares left of right then one square up or down, or two squares up or down then one square left or right. -The calculation will be much easier if you identify the cells by rows (0 - 7) and columns (0 - 7) instead of 0 - 63. This can be done easily by dividing the cell index by 8 and using the quotient and remainder as row and column indices. So, if the knight is at position (x, y) now, its next possible positions can be any of (x - 2, y - 1), (x - 2, y + 1), (x + 2, y - 1), (x + 2, y + 1), (x - 1, y - 2), (x - 1, y + 2), (x + 1, y - 2), (x + 1, y + 2). Be careful that all of these 8 cells may not be inside the grid, so discard the locations that falls out of the board.",0.1016881243684853,False,3,4582 +-------------------------","While User_Targaryen's answer is the best because it directly answers your question, I would recommend an algebraic solution, if your goal is computing is the delivery of an answer in the shortest amount of time. +To shorten the algorithm, use reflections about the x, y, and xy axes, so as to consider only positive (x, y) where x >= y, and place the starting move at the origin, coordinate (0, 0). This is one octant (one eighth) of the possible directions. +A hint to discovering the solution is to use graph-paper or Dijkstra's algorithm with the restriction of reaching all points in the first octant up to 5 moves, and display this as a grid. Each cell of the grid should be labeled with a digit representing the minimum number of moves. +Let me know if you would like to broaden your question and would like additional information.",0.1016881243684853,False,3,4582 2016-11-06 21:47:15.293,Simple algorithm to move from one tile to another using only a chess knight's moves,"I have a problem shown below that wants to find the quickest way to get between any two points by using only the moves of a knight in chess. My first thought was to us the A* algorithm or Dijkstra's algorithm however, I don't know how to make sure only the moves of a knight are used. I would appreciate it if you could suggest a better algorithm or just some tips to help me. Thank you. Write a function called answer(src, dest) which takes in two parameters: the source square, on which you start, and the destination square, which is where you need to land to solve the puzzle. The function should return an integer representing the smallest number of moves it will take for you to travel from the source square to the destination square using a chess knight's moves (that is, two squares in any direction immediately followed by one square perpendicular to that direction, or vice versa, in an ""L"" shape). Both the source and destination squares will be an integer between 0 and 63, inclusive, and are numbered like the example chessboard below: @@ -43918,10 +43919,9 @@ Write a function called answer(src, dest) which takes in two parameters: the sou |48|49|50|51|52|53|54|55| ------------------------- |56|57|58|59|60|61|62|63| --------------------------","While User_Targaryen's answer is the best because it directly answers your question, I would recommend an algebraic solution, if your goal is computing is the delivery of an answer in the shortest amount of time. -To shorten the algorithm, use reflections about the x, y, and xy axes, so as to consider only positive (x, y) where x >= y, and place the starting move at the origin, coordinate (0, 0). This is one octant (one eighth) of the possible directions. -A hint to discovering the solution is to use graph-paper or Dijkstra's algorithm with the restriction of reaching all points in the first octant up to 5 moves, and display this as a grid. Each cell of the grid should be labeled with a digit representing the minimum number of moves. -Let me know if you would like to broaden your question and would like additional information.",0.1016881243684853,False,3,4582 +-------------------------","For this problem, simply doing a breadth-first search is enough (Dijkstra and BFS work in same way for unweighted graphs). To ensure that only the chess knight's moves are used, you'll have to define the moves in a proper way. +Notice that a chess knight moves two squares to any direction, then one square perpendicular to that. This means it can move two squares left of right then one square up or down, or two squares up or down then one square left or right. +The calculation will be much easier if you identify the cells by rows (0 - 7) and columns (0 - 7) instead of 0 - 63. This can be done easily by dividing the cell index by 8 and using the quotient and remainder as row and column indices. So, if the knight is at position (x, y) now, its next possible positions can be any of (x - 2, y - 1), (x - 2, y + 1), (x + 2, y - 1), (x + 2, y + 1), (x - 1, y - 2), (x - 1, y + 2), (x + 1, y - 2), (x + 1, y + 2). Be careful that all of these 8 cells may not be inside the grid, so discard the locations that falls out of the board.",0.1016881243684853,False,3,4582 2016-11-07 03:20:59.700,"information retrieval evaluation python precision, recall, f score, AP,MAP","i wrote one program to do the information retrieval and extraction. user enter the query in the search bar, the program can show the relevant txt result such as the relevant sentence and the article which consists the sentence. I did some research for how to evaluate the result. I might need to calculate the precision, recall, AP, MAP.... However, I am new to that. How to calculate the result. Since my dataset is not labeled and i did not do the classification. The dataset I used was the article from BBC news. there were 200 articles. i named it as 001.txt, 002.txt ...... 200.txt @@ -44021,37 +44021,37 @@ Thanks!","This is not python specific, but if you want to share a config globall 2016-11-13 13:49:53.100,manipulating SVGs with python,"I want to read an existing SVG file, traverse all elements and remove them if they match certain conditions (e.g. remove all objects with red border). There is the svgwrite library for Python2/3 but the tutorials/documentation I found only show how to add some lines and save the file. Can I also manipulate/remove existing elements inside an SVG document with svgwrite? If not - is there an alternative for Python?",The svgwrite package only creates svg. It does not read a svg file. I have not tried any packages to read and process svg files.,0.0,False,1,4593 -2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"In Spyder 4.1, you can change background color from: -Tools > Preferences > Appearance > Syntax highlighting scheme",0.0,False,9,4594 -2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"I've seen some people recommending installing aditional software but in my opinion the best way is by using the built-in skins, you can find them at: -Tools > Preferences > Syntax Coloring",0.0226718512221269,False,9,4594 2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"1.Click Tools 2.Click Preferences 3.Select Syntax Coloring",0.0,False,9,4594 -2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"At First click on preferences(Ctrl+Shift+alt+p) then click the option of syntax coloring and change the scheme to ""Monokai"".Now apply it and you will get the dark scheme.",0.0,False,9,4594 -2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"On mine it's Tools --> Preferences --> Editor and ""Syntax Color Scheme"" dropdown is at the very bottom of the list.",0.0226718512221269,False,9,4594 -2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"I tried the option: Tools > Preferences > Syntax coloring > dark spyder -is not working. -You should rather use the path: -Tools > Preferences > Syntax coloring > spyder -then begin modifications as you want your editor to appear",0.0453204071731508,False,9,4594 -2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"Yes, that's the intuitive answer. Nothing in Spyder is intuitive. Go to Preferences/Editor and select the scheme you want. Then go to Preferences/Syntax Coloring and adjust the colors if you want to. -tcebob",-0.1128953525810619,False,9,4594 +2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"I think some of the people answering this question don’t actually try to do what they recommend, because there is something wrong with way the Mac OS version handles the windows. +When you choose the new color scheme and click OK, the preferences window looks like it closed, but it is still there behind the main spyder window. You need to switch windows with command ~ or move the main spyder window to expose the preferences window. Then you need to click Apply to get the new color scheme.",0.0453204071731508,False,9,4594 2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"If you're using Spyder 3, please go to Tools > Preferences > Syntax Coloring and select there the dark theme you want to use. In Spyder 4, a dark theme is used by default. But if you want to select a different theme you can go to Tools > Preferences > Appearance > Syntax highlighting theme",1.2,True,9,4594 -2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"I think some of the people answering this question don’t actually try to do what they recommend, because there is something wrong with way the Mac OS version handles the windows. -When you choose the new color scheme and click OK, the preferences window looks like it closed, but it is still there behind the main spyder window. You need to switch windows with command ~ or move the main spyder window to expose the preferences window. Then you need to click Apply to get the new color scheme.",0.0453204071731508,False,9,4594 +2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"Yes, that's the intuitive answer. Nothing in Spyder is intuitive. Go to Preferences/Editor and select the scheme you want. Then go to Preferences/Syntax Coloring and adjust the colors if you want to. +tcebob",-0.1128953525810619,False,9,4594 +2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"I tried the option: Tools > Preferences > Syntax coloring > dark spyder +is not working. +You should rather use the path: +Tools > Preferences > Syntax coloring > spyder +then begin modifications as you want your editor to appear",0.0453204071731508,False,9,4594 +2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"At First click on preferences(Ctrl+Shift+alt+p) then click the option of syntax coloring and change the scheme to ""Monokai"".Now apply it and you will get the dark scheme.",0.0,False,9,4594 +2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"In Spyder 4.1, you can change background color from: +Tools > Preferences > Appearance > Syntax highlighting scheme",0.0,False,9,4594 +2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"On mine it's Tools --> Preferences --> Editor and ""Syntax Color Scheme"" dropdown is at the very bottom of the list.",0.0226718512221269,False,9,4594 +2016-11-14 19:03:11.403,How to change the Spyder editor background to dark?,I've just updated Spyder to version 3.1 and I'm having trouble changing the colour scheme to dark. I've been able to change the Python and iPython console's to dark but the option to change the editor to dark is not where I would expect it to be. Could anybody tell me how to change the colour scheme of the Spyder 3.1 editor to dark?,"I've seen some people recommending installing aditional software but in my opinion the best way is by using the built-in skins, you can find them at: +Tools > Preferences > Syntax Coloring",0.0226718512221269,False,9,4594 +2016-11-16 07:37:01.950,Visual Studio Code - removing pylint,"Simple question - but any steps on how to remove pylint from a Windows 10 machine with Python 3.5.2 installed. +I got an old version of pylint installed that's spellchecking on old Python 2 semantics and it's bugging the heck out of me when the squigglies show up in Visual Studio Code.",i had this problem but it was fixed with this solution CTRL + SHIFT + P > Selecionar linter > Linter desabilitado.,0.0,False,2,4595 2016-11-16 07:37:01.950,Visual Studio Code - removing pylint,"Simple question - but any steps on how to remove pylint from a Windows 10 machine with Python 3.5.2 installed. I got an old version of pylint installed that's spellchecking on old Python 2 semantics and it's bugging the heck out of me when the squigglies show up in Visual Studio Code.","If you just want to disable pylint then the updated VSCode makes it much more easier. Just hit CTRL + SHIFT + P > Select linter > Disabled Linter. Hope this helps future readers.",0.9999917628565104,False,2,4595 -2016-11-16 07:37:01.950,Visual Studio Code - removing pylint,"Simple question - but any steps on how to remove pylint from a Windows 10 machine with Python 3.5.2 installed. -I got an old version of pylint installed that's spellchecking on old Python 2 semantics and it's bugging the heck out of me when the squigglies show up in Visual Studio Code.",i had this problem but it was fixed with this solution CTRL + SHIFT + P > Selecionar linter > Linter desabilitado.,0.0,False,2,4595 2016-11-16 08:38:45.963,AWS lambda function to retrieve any uploaded files from s3 and upload the unzipped folder back to s3 again,"I have an s3 bucket which is used for users to upload zipped directories, often 1GB in size. The zipped directory holdes images in subfolders and more. I need to create a lambda function, that will get triggered upon new uploads, unzip the file, and upload the unzipped content back to an s3 bucket, so I can access the individual files via http - but I'm pretty clueless as to how I can write such a function? My concerns are: @@ -44083,9 +44083,9 @@ And tried adding extra escapes: Also tried raw strings:load_data_statement = r"" Also tried raw strings:load_data_statement = r""""""load data local infile \'tgt_metadata_%s.txt\' INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\'';"""""" % metadata_filename The execute line is simple `cur.execute(load_data_statement) And the error I'm getting is odd: `pymysql.err.ProgrammingError: (1064, ""You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tgt_metadta_mal.txt'.txt' INTO table tgt_metadata FIELDS TERMINATED BY ','; ENC' at line 1"") -I don't understand why the message starts at 'tgt_metadata_mal.txt and shows only the first 3 letters of ENCLOSED BY...","No need for escaping that string. -cursor.execute(""SELECT * FROM Codes WHERE ShortCode = %s"", text) -You should use %s instead of your strings and then (in this case text) would be your string. This is the most secure way of protecting from SQL Injection",0.5457054096481145,False,2,4599 +I don't understand why the message starts at 'tgt_metadata_mal.txt and shows only the first 3 letters of ENCLOSED BY...","I think the problem is with the SQL statement you print. The single quote in ''' should be escaped: '\''. Your backslash escapes the quote at Python level, and not the MySQL level. Thus the Python string should end with ENCLOSED BY '\\''; +You may also use the raw string literal notation: +r""""""INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\'';""""""",0.0,False,2,4599 2016-11-18 08:36:11.277,In Python how do I escape a single quote within a string that will be used as a SQL statement?,"I built a simple statement to run a load data local infile on a MySQL table. I'm using Python to generate the string and also run the query. So I'm using the Python package pymysql. This is the line to build the string. Assume metadata_filename is a proper string: @@ -44105,9 +44105,9 @@ And tried adding extra escapes: Also tried raw strings:load_data_statement = r"" Also tried raw strings:load_data_statement = r""""""load data local infile \'tgt_metadata_%s.txt\' INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\'';"""""" % metadata_filename The execute line is simple `cur.execute(load_data_statement) And the error I'm getting is odd: `pymysql.err.ProgrammingError: (1064, ""You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'tgt_metadta_mal.txt'.txt' INTO table tgt_metadata FIELDS TERMINATED BY ','; ENC' at line 1"") -I don't understand why the message starts at 'tgt_metadata_mal.txt and shows only the first 3 letters of ENCLOSED BY...","I think the problem is with the SQL statement you print. The single quote in ''' should be escaped: '\''. Your backslash escapes the quote at Python level, and not the MySQL level. Thus the Python string should end with ENCLOSED BY '\\''; -You may also use the raw string literal notation: -r""""""INTO TABLE table1 FIELDS TERMINATED BY ',' ENCLOSED BY '\'';""""""",0.0,False,2,4599 +I don't understand why the message starts at 'tgt_metadata_mal.txt and shows only the first 3 letters of ENCLOSED BY...","No need for escaping that string. +cursor.execute(""SELECT * FROM Codes WHERE ShortCode = %s"", text) +You should use %s instead of your strings and then (in this case text) would be your string. This is the most secure way of protecting from SQL Injection",0.5457054096481145,False,2,4599 2016-11-18 09:36:12.407,Pass a NAN in input vector for prediction,"I have a classifier that has been trained using a given set of input training data vectors. There are missing values in the training data which is filled as numpy.Nan values and Using imputers to fill in the missing values. However, In case of my input vector for prediction, how do I pass in the input where the value is missing? should I pass the value as nan? Does imputer play a role in this.? If I have to fill in the value manually, How do I fill in the value for such case will I need to calculate the mean/median/frequency from the existing data. @@ -44191,14 +44191,14 @@ In bucket's properties, create a new event notification for an event type of s3: Then for the lambda function, write a code either in Python or NodeJS (or whatever you like) and parse the received event and send it to Slack webhook URL.",0.0,False,1,4612 2016-11-26 04:57:39.317,Checking code for compatibility with Python 2 and 3,"Is there any automated way to test that code is compatible with both Python 2 and 3? I've seen plenty of documentation on how to write code that is compatible with both, but nothing on automatically checking. Basically a kind of linting for compatibility between versions rather than syntax/style. I have thought of either running tests with both interpreters or running a tool like six or 2to3 and checking that nothing is output; unfortunately, the former requires that you have 100% coverage with your tests and I would assume the latter requires that you have valid Python 2 code and would only pick up issues in compatibility with Python 3. +Is there anything out there that will accomplish this task?",Could you not look at the output from 2to3 to see if any code changes may be necessary ?,0.2012947653214861,False,2,4613 +2016-11-26 04:57:39.317,Checking code for compatibility with Python 2 and 3,"Is there any automated way to test that code is compatible with both Python 2 and 3? I've seen plenty of documentation on how to write code that is compatible with both, but nothing on automatically checking. Basically a kind of linting for compatibility between versions rather than syntax/style. +I have thought of either running tests with both interpreters or running a tool like six or 2to3 and checking that nothing is output; unfortunately, the former requires that you have 100% coverage with your tests and I would assume the latter requires that you have valid Python 2 code and would only pick up issues in compatibility with Python 3. Is there anything out there that will accomplish this task?","There is no ""fool-proof"" way of doing this other than running the code on both versions and finding inconsistencies. With that said, CPython2.7 has a -3 flag which (according to the man page) says: Warn about Python 3.x incompatibilities that 2to3 cannot trivially fix. As for the case where you have valid python3 code and you want to backport it to python2.x -- You likely don't actually want to do this. python3.x is the future. This is likely to be a very painful problem in the general case. A lot of the reason to start using python3.x is because then you gain access to all sorts of cool new features. Trying to re-write code that is already relying on cool new features is frequently going to be very difficult. Your much better off trying to upgrade python2.x packages to work on python3.x than doing things the other way around.",1.2,True,2,4613 -2016-11-26 04:57:39.317,Checking code for compatibility with Python 2 and 3,"Is there any automated way to test that code is compatible with both Python 2 and 3? I've seen plenty of documentation on how to write code that is compatible with both, but nothing on automatically checking. Basically a kind of linting for compatibility between versions rather than syntax/style. -I have thought of either running tests with both interpreters or running a tool like six or 2to3 and checking that nothing is output; unfortunately, the former requires that you have 100% coverage with your tests and I would assume the latter requires that you have valid Python 2 code and would only pick up issues in compatibility with Python 3. -Is there anything out there that will accomplish this task?",Could you not look at the output from 2to3 to see if any code changes may be necessary ?,0.2012947653214861,False,2,4613 2016-11-27 12:54:59.907,Running a python program in Windows?,"I have Python 3.6 and Windows 7. I am able to successfully start the python interpreter in interactive mode, which I have confirmed by going to cmd, and typing in python, so my computer knows how to find the interpreter. I am confused however, as to how to access files from the interpreter. For example, I have a file called test.py (yes, I made sure the correct file extension was used). @@ -44234,13 +44234,13 @@ I can connect to hbase","the hbase data model does not offer that efficiently wi I am using ubuntu 16.04.",I think you have to build it yourself from source... You can easily find a guide for that if you google it.,-0.2012947653214861,False,1,4617 2016-11-28 18:44:50.737,How to not hardcode a String in a software?,"I'm wondering how it's possible to not hard-code a string, for example, an IP in some software, or in remote connection software. I heared about a Cyber Security Expert which found the IP of someone who was hacking people in hes software, and with that they tracked him. -So, how can I avoid hardcoding my IP in to the software, and how do people find my IP if I do hardcode it?","You could do any of these: 1) read the string from a file, 2) read the string from a database, 3) pass the string as a command line argument",0.0,False,4,4618 -2016-11-28 18:44:50.737,How to not hardcode a String in a software?,"I'm wondering how it's possible to not hard-code a string, for example, an IP in some software, or in remote connection software. -I heared about a Cyber Security Expert which found the IP of someone who was hacking people in hes software, and with that they tracked him. So, how can I avoid hardcoding my IP in to the software, and how do people find my IP if I do hardcode it?","One option is to use asymmetric encryption, you can request the private string from a server using it (see SSL/TLS). If you want to do it locally you should write/read to a file (OS should take care of authorization, by means of user access)",0.0,False,4,4618 2016-11-28 18:44:50.737,How to not hardcode a String in a software?,"I'm wondering how it's possible to not hard-code a string, for example, an IP in some software, or in remote connection software. I heared about a Cyber Security Expert which found the IP of someone who was hacking people in hes software, and with that they tracked him. +So, how can I avoid hardcoding my IP in to the software, and how do people find my IP if I do hardcode it?","You could do any of these: 1) read the string from a file, 2) read the string from a database, 3) pass the string as a command line argument",0.0,False,4,4618 +2016-11-28 18:44:50.737,How to not hardcode a String in a software?,"I'm wondering how it's possible to not hard-code a string, for example, an IP in some software, or in remote connection software. +I heared about a Cyber Security Expert which found the IP of someone who was hacking people in hes software, and with that they tracked him. So, how can I avoid hardcoding my IP in to the software, and how do people find my IP if I do hardcode it?","There are several ways to obscure a hard-coded string. One of the simplest is to XOR the bits with another string or a repeated constant. Thus you could have two hardcoded short arrays that, when XORed together, produce the string you want to obscure.",1.2,True,4,4618 2016-11-28 18:44:50.737,How to not hardcode a String in a software?,"I'm wondering how it's possible to not hard-code a string, for example, an IP in some software, or in remote connection software. I heared about a Cyber Security Expert which found the IP of someone who was hacking people in hes software, and with that they tracked him. @@ -44265,7 +44265,7 @@ What ML model can I use to support this notion of ranking ? Also, I can’t dete I have to my disposition an infinite number of items since I generate them myself. The ranking function could be anything but let’s say it is : attribute a score = 1/3 * ( x1 + x2 + x3 ) to each item and sort by descending score The goal for the model is to guess as close as possible what the ranking function is by outputting similar results for the same batch of 5 items. -Thanks in advance !","Since there's an unknown function that generates the output, it's a regression problem. Neural network with 2 hidden layers and e.g. sigmoid can learn any arbitrary function.",0.3869120172231254,False,2,4622 +Thanks in advance !","It could be treated as a regression problem with the following trick: You are given 5 items with 5 feature vectors and the ""black box"" function outputs 5 distinct scores as [1, 2, 3, 4, 5]. Treat these as continuous values. So, you can think of your function as operating by taking five distinct input vectors x1, x2, x3, x4, x5 and outputting five scalar target variables t1, t2, t3, t4, t5 where the target variables for your training set are the scores the items get. For example, if the ranking for a single sample is (x1,4), (x2,5), (x3,3), (x4,1), (x5,2) then set t1=4, t2=5, t3=3, t4=1 and t5=2. MLPs have the ""universal approximation"" capability and given a black box function, they can approximate it arbitrarily close, dependent on the hidden unit count. So, build a 2 layer MLP with the inputs as the five feature vectors and the outputs as the five ranking scores. You are going to minimize a sum of squares error function, the classical regression error function. And don't use any regularization term, since you are going to try to mimic a deterministic black fox function, there is no random noise inherent in the outputs of that function, so you shouldn't be afraid of any overfitting issues.",1.2,True,2,4622 2016-12-02 23:25:31.600,ML model to predict rankings (arbitrary ordering of a list),"I need some orientation for a problem I’m trying to solve. Anything would be appreciated, a keyword to Google or some indication ! So I have a list of 5 items. All items share the same features, let’s say each item has 3 features for the example. I pass the list to a ranking function which takes into account the features of every item in the list and returns an arbitrary ordered list of these items. @@ -44276,7 +44276,7 @@ What ML model can I use to support this notion of ranking ? Also, I can’t dete I have to my disposition an infinite number of items since I generate them myself. The ranking function could be anything but let’s say it is : attribute a score = 1/3 * ( x1 + x2 + x3 ) to each item and sort by descending score The goal for the model is to guess as close as possible what the ranking function is by outputting similar results for the same batch of 5 items. -Thanks in advance !","It could be treated as a regression problem with the following trick: You are given 5 items with 5 feature vectors and the ""black box"" function outputs 5 distinct scores as [1, 2, 3, 4, 5]. Treat these as continuous values. So, you can think of your function as operating by taking five distinct input vectors x1, x2, x3, x4, x5 and outputting five scalar target variables t1, t2, t3, t4, t5 where the target variables for your training set are the scores the items get. For example, if the ranking for a single sample is (x1,4), (x2,5), (x3,3), (x4,1), (x5,2) then set t1=4, t2=5, t3=3, t4=1 and t5=2. MLPs have the ""universal approximation"" capability and given a black box function, they can approximate it arbitrarily close, dependent on the hidden unit count. So, build a 2 layer MLP with the inputs as the five feature vectors and the outputs as the five ranking scores. You are going to minimize a sum of squares error function, the classical regression error function. And don't use any regularization term, since you are going to try to mimic a deterministic black fox function, there is no random noise inherent in the outputs of that function, so you shouldn't be afraid of any overfitting issues.",1.2,True,2,4622 +Thanks in advance !","Since there's an unknown function that generates the output, it's a regression problem. Neural network with 2 hidden layers and e.g. sigmoid can learn any arbitrary function.",0.3869120172231254,False,2,4622 2016-12-03 11:46:35.843,total memory used by running python code,I am running python program using Linux operating system and i want to know how much total memory used for this process. Is there any way to determine the total memory usage ?,You can just open task manager and look how much ram does it take. I use Ubuntu and it came preinstalled.,0.0,False,1,4623 2016-12-04 11:06:23.810,"python 3.4 tkinter, click trough window","I'm trying to write a semi transparent click trough program to use like onion skin over my 3d application. the one thing I couldn't find googling is how to make the window click trough. is there an attribute or something for it in tkinter? or maybe some way around it?","You can use PyAutoGUI and Tkinter to: @@ -44413,6 +44413,7 @@ l,l^M What exactly am I doing wrong?","turns out it was the json.dumps(), should've read more into what it does! Thanks.",0.0,False,1,4629 +2016-12-05 17:42:03.440,How to set up word wrap for an stc.StyledTextCtrl() in wxPython,"I was wondering about this, so I did quite a bit of google searches, and came up with the SetWrapMode(self, mode) function. However, it was never really detailed, and there was nothing that really said how to use it. I ended up figuring it out, so I thought I'd post a thread here and answer my own question for anyone else who is wondering how to make an stc.StyledTextCtrl() have word wrap.","It would be more maintainable to use the constants stc.WRAP_NONE, stc.WRAP_WORD, stc.WRAP_CHAR and stc.WRAP_WHITESPACE instead of their numerical values.",0.0,False,2,4630 2016-12-05 17:42:03.440,How to set up word wrap for an stc.StyledTextCtrl() in wxPython,"I was wondering about this, so I did quite a bit of google searches, and came up with the SetWrapMode(self, mode) function. However, it was never really detailed, and there was nothing that really said how to use it. I ended up figuring it out, so I thought I'd post a thread here and answer my own question for anyone else who is wondering how to make an stc.StyledTextCtrl() have word wrap.","I see you answered your own question, and you are right in every way except for one small detail. There are actually several different wrap modes. The types and values corresponding to them are as follows: 0: None @@ -44421,7 +44422,6 @@ What exactly am I doing wrong?","turns out it was the json.dumps(), should've re 3: White Space Wrap So you cannot enter any value above 0 to get word wrap. In fact if you enter a value outside of the 0-3 you should just end up getting no wrap as the value shouldn't be recognized by Scintilla, which is what the stc library is.",0.0,False,2,4630 -2016-12-05 17:42:03.440,How to set up word wrap for an stc.StyledTextCtrl() in wxPython,"I was wondering about this, so I did quite a bit of google searches, and came up with the SetWrapMode(self, mode) function. However, it was never really detailed, and there was nothing that really said how to use it. I ended up figuring it out, so I thought I'd post a thread here and answer my own question for anyone else who is wondering how to make an stc.StyledTextCtrl() have word wrap.","It would be more maintainable to use the constants stc.WRAP_NONE, stc.WRAP_WORD, stc.WRAP_CHAR and stc.WRAP_WHITESPACE instead of their numerical values.",0.0,False,2,4630 2016-12-06 07:26:10.103,How to import IBM Bluemix Watson speech-to-text in Choregraphe?,"Currently, I am doing a project about Nao Robot. I am having problem with importing the python class file into choregraphe. So anyone knows how to do this? Error message @@ -44483,7 +44483,11 @@ I read some posts that say that pdb is implemented using sys.settrace. If nothing else works I should be able to recreate the behavior I need using this. -Is there any established/straight forward way to implement the behavior that I am looking for?","sys.settrace() is the fundamental building block for stepping through Python code. pdb is implemented entirely in Python, so you can just look at the module to see how it does things. It also has various public functions/methods for stepping under program control, read the library reference for your version of Python for details.",1.2,True,2,4636 +Is there any established/straight forward way to implement the behavior that I am looking for?","I read some posts that say that pdb is implemented using sys.settrace. + If nothing else works I should be able to recreate the behavior I need + using this. + +Don't view this as a last resort. I think it's the best approach for what you want to accomplish.",0.2012947653214861,False,2,4636 2016-12-09 19:59:08.040,How to programmatically execute/step through Python code line by line,"I am trying to find a way that I can have a program step through Python code line by line and do something with the results of each line. In effect a debugger that could be controlled programmatically rather than manually. pdb would be exactly what I am looking for if it returned its output after each step as a string and I could then call pdb again to pickup where I left off. However, instead it outputs to stdout and I have to manually input ""step"" via the keyboard. Things I have tried: @@ -44505,11 +44509,7 @@ I read some posts that say that pdb is implemented using sys.settrace. If nothing else works I should be able to recreate the behavior I need using this. -Is there any established/straight forward way to implement the behavior that I am looking for?","I read some posts that say that pdb is implemented using sys.settrace. - If nothing else works I should be able to recreate the behavior I need - using this. - -Don't view this as a last resort. I think it's the best approach for what you want to accomplish.",0.2012947653214861,False,2,4636 +Is there any established/straight forward way to implement the behavior that I am looking for?","sys.settrace() is the fundamental building block for stepping through Python code. pdb is implemented entirely in Python, so you can just look at the module to see how it does things. It also has various public functions/methods for stepping under program control, read the library reference for your version of Python for details.",1.2,True,2,4636 2016-12-11 03:25:32.893,Throw an exception while doing dataframe sum in Pandas,"I have a dataframe in which one of the row is filled with string ""Error"" I am trying to add rows of 2 different dataframe. However, since I have the string in one of the row, it is concatenating the 2 strings. So, I am having the dataframe filled with a row ""ErrorError"". I would prefer leaving this row empty than concatenating the strings. @@ -44540,7 +44540,7 @@ ALTER TABLE ""django_admin_log"" ADD CONSTRAINT ""django_admin_log_user_id_c564e CREATE INDEX ""django_admin_log_417f1b1c"" ON ""django_admin_log"" (""content_type_id""); CREATE INDEX ""django_admin_log_e8701ad4"" ON ""django_admin_log"" (""user_id""); COMMIT;"" -but i still get the same error? i use postgresql if anyone cares.","After ./manage.py sqlmigrate admin 0001, please run python manage.py migrate.",0.0,False,2,4639 +but i still get the same error? i use postgresql if anyone cares.","experienced the same issue, the best way is to copy the CREATE TABLE log, login to your database ./manage.py dbshell and Paste the content over there without adding the last line (COMMIT ) it will solve the problem and manually create the table for you.",0.2655860252697744,False,2,4639 2016-12-12 05:56:48.343,I accidentally deleted django_admin_log and now i can not use the django admin,"I get this error ""ProgrammingError at /admin/ @@ -44559,7 +44559,7 @@ ALTER TABLE ""django_admin_log"" ADD CONSTRAINT ""django_admin_log_user_id_c564e CREATE INDEX ""django_admin_log_417f1b1c"" ON ""django_admin_log"" (""content_type_id""); CREATE INDEX ""django_admin_log_e8701ad4"" ON ""django_admin_log"" (""user_id""); COMMIT;"" -but i still get the same error? i use postgresql if anyone cares.","experienced the same issue, the best way is to copy the CREATE TABLE log, login to your database ./manage.py dbshell and Paste the content over there without adding the last line (COMMIT ) it will solve the problem and manually create the table for you.",0.2655860252697744,False,2,4639 +but i still get the same error? i use postgresql if anyone cares.","After ./manage.py sqlmigrate admin 0001, please run python manage.py migrate.",0.0,False,2,4639 2016-12-12 18:57:14.163,Python SMTP Send Email and Receive Reply,"I know how to send email through Outlook/Gmail using the Python SMTP library. However, I was wondering if it was possible to receive replys from those automated emails sent from Python. For example, if I sent an automated email from Python (Outlook/Gmail) and I wanted the user to be able to reply ""ok"" or ""quit"" to the automated email to either continue the script or kick off another job or something, how would I go about doing that in Python? Thanks","SMTP is only for sending. To receive (read) emails, you will need to use other protocols, such as POP3, IMAP4, etc.",0.0,False,1,4640 @@ -44629,13 +44629,13 @@ I was wondering why this was and how can I make it so that the datatypes for my sentence = ""John was accused of crimes by David""",Go through the spacy 2.0 nightly build. It should have the solution you're looking for.,-0.2012947653214861,False,1,4649 2016-12-19 11:39:54.123,"how to automatically remove ""Powered by ..."" in Pelican CMS?","When generating content using Pelican, everything is Ok except that I see in the footer ""Proudly powered by Pelican ..."" I want to get rid of it. I know I can remove it from the generated files manually, but that is tedious. -Is there a way to prevent the generation of the above phrase by asking Pelican to do that for me? Some magic Pelican command or settings, maybe?","Probably is not the answer you are looking for, but if you are already customizing the CSS, think about usgin CSS to hide the section.",-0.1016881243684853,False,2,4650 -2016-12-19 11:39:54.123,"how to automatically remove ""Powered by ..."" in Pelican CMS?","When generating content using Pelican, everything is Ok except that I see in the footer ""Proudly powered by Pelican ..."" -I want to get rid of it. I know I can remove it from the generated files manually, but that is tedious. Is there a way to prevent the generation of the above phrase by asking Pelican to do that for me? Some magic Pelican command or settings, maybe?","In your theme template, there will be a line like, {% extends ""!simple/base.html"" %} This base.html is used as the foundation for creating the theme. This file is available in : %PYTHON%\Lib\site-packages\pelican\themes\simple\templates You can edit this file to remove the ""Powered By..""",0.296905446847765,False,2,4650 +2016-12-19 11:39:54.123,"how to automatically remove ""Powered by ..."" in Pelican CMS?","When generating content using Pelican, everything is Ok except that I see in the footer ""Proudly powered by Pelican ..."" +I want to get rid of it. I know I can remove it from the generated files manually, but that is tedious. +Is there a way to prevent the generation of the above phrase by asking Pelican to do that for me? Some magic Pelican command or settings, maybe?","Probably is not the answer you are looking for, but if you are already customizing the CSS, think about usgin CSS to hide the section.",-0.1016881243684853,False,2,4650 2016-12-20 23:33:31.903,How to use openpyxl to insert one sheet to a template?,"I want to generate excel spreadsheets by python, the first few tabs are exactly same, all are refer to the last page, so how to insert the last page by openpyxl? because the first few tabs are too complex so load_workbook is always failed, is there have any other way to insert tabs without loading?","As far as i know, openpyxl does not allow you to access only one cell, or a limited number of cells for that matter. In order to access any information in a given worksheet, openpyxl will create one in the memory. This is the reason for which you will be unable to add a Sheet without opening the entire document in memory and overwriting it at the end.",0.0,False,1,4651 2016-12-21 03:40:36.417,Using http and mqtt together in a single threaded python app,"I am a noob to web and mqtt programming, I am working on a python application that uses mqtt (via hivemq or rabbitmq broker) and also needs to implement http rest api for clients. I realized using python bottle framework is pretty easy to provide a simple http server, however both bottle and mqtt have their event loop, how do I combine these 2 event loop, I want to have a single threaded app to avoid complexity.","I'm not familiar with bottle but a quick look at the docs it doesn't look like there is any other way to start it's event loop apart from with the run() function. @@ -44886,13 +44886,6 @@ The solution was to open the file (which could not be correctly read as it was a 2017-01-13 10:59:16.793,protect python code from reverse engineering,"I'm creating a program in python (2.7) and I want to protect it from reverse engineering. I compiled it using cx_freeze (supplies basic security- obfuscation and anti-debugging) How can I add more protections such as obfuscation, packing, anti-debugging, encrypt the code recognize VM. -I thought maybe to encrypt to payload and decrypt it on run time, but I have no clue how to do it.","Story time: I was a Python programmer for a long time. Recently I joined in a company as a Python programmer. My manager was a Java programmer for a decade I guess. He gave me a project and at the initial review, he asked me that are we obfuscating the code? and I said, we don't do that kind of thing in Python. He said we do that kind of things in Java and we want the same thing to be implemented in python. Eventually I managed to obfuscate code just removing comments and spaces and renaming local variables) but entire python debugging process got messed up. -Then he asked me, Can we use ProGuard? I didn't know what the hell it was. After some googling I said it is for Java and cannot be used in Python. I also said whatever we are building we deploy in our own servers, so we don't need to actually protect the code. But he was reluctant and said, we have a set of procedures and they must be followed before deploying. -Eventually I quit my job after a year tired of fighting to convince them Python is not Java. I also had no interest in making them to think differently at that point of time. -TLDR; Because of the open source nature of the Python, there are no viable tools available to obfuscate or encrypt your code. I also don't think it is not a problem as long as you deploy the code in your own server (providing software as a service). But if you actually provide the product to the customer, there are some tools available to wrap up your code or byte code and give it like a executable file. But it is always possible to view your code if they want to. Or you choose some other language that provides better protection if it is absolutely necessary to protect your code. Again keep in mind that it is always possible to do reverse engineering on the code.",0.3869120172231254,False,2,4675 -2017-01-13 10:59:16.793,protect python code from reverse engineering,"I'm creating a program in python (2.7) and I want to protect it from reverse engineering. -I compiled it using cx_freeze (supplies basic security- obfuscation and anti-debugging) -How can I add more protections such as obfuscation, packing, anti-debugging, encrypt the code recognize VM. I thought maybe to encrypt to payload and decrypt it on run time, but I have no clue how to do it.","There's no way to make anything digital safe nowadays. What you CAN do is making it hard to a point where it's frustrating to do it, but I admit I don't know python specific ways to achieve that. The amount of security of your program is not actually a function of programsecurity, but of psychology. Yes, psychology. @@ -44903,6 +44896,13 @@ For example could you turn your program into a single compiled block of bytecode There are lots of ways of messing with people's heads and while I can't tell you any python specific ways, if you think in context of ""How to be difficult"", you'll find the weirdest ways of making it a mess to deal with your code. Funnily enough this is much easier in assembly, than python, so maybe you should look into executing foreign code via ctypes or whatever. Summon your inner Troll!",0.6730655149877884,False,2,4675 +2017-01-13 10:59:16.793,protect python code from reverse engineering,"I'm creating a program in python (2.7) and I want to protect it from reverse engineering. +I compiled it using cx_freeze (supplies basic security- obfuscation and anti-debugging) +How can I add more protections such as obfuscation, packing, anti-debugging, encrypt the code recognize VM. +I thought maybe to encrypt to payload and decrypt it on run time, but I have no clue how to do it.","Story time: I was a Python programmer for a long time. Recently I joined in a company as a Python programmer. My manager was a Java programmer for a decade I guess. He gave me a project and at the initial review, he asked me that are we obfuscating the code? and I said, we don't do that kind of thing in Python. He said we do that kind of things in Java and we want the same thing to be implemented in python. Eventually I managed to obfuscate code just removing comments and spaces and renaming local variables) but entire python debugging process got messed up. +Then he asked me, Can we use ProGuard? I didn't know what the hell it was. After some googling I said it is for Java and cannot be used in Python. I also said whatever we are building we deploy in our own servers, so we don't need to actually protect the code. But he was reluctant and said, we have a set of procedures and they must be followed before deploying. +Eventually I quit my job after a year tired of fighting to convince them Python is not Java. I also had no interest in making them to think differently at that point of time. +TLDR; Because of the open source nature of the Python, there are no viable tools available to obfuscate or encrypt your code. I also don't think it is not a problem as long as you deploy the code in your own server (providing software as a service). But if you actually provide the product to the customer, there are some tools available to wrap up your code or byte code and give it like a executable file. But it is always possible to view your code if they want to. Or you choose some other language that provides better protection if it is absolutely necessary to protect your code. Again keep in mind that it is always possible to do reverse engineering on the code.",0.3869120172231254,False,2,4675 2017-01-13 12:14:12.317,"In requests-python, when is connection released when using req_json = req.json()?","I read the following on python-requests website: Note that connections are only released back to the pool for reuse once all body data has been read; be sure to either set stream to False or read the content property of the Response object. @@ -45222,15 +45222,15 @@ I am currently using some scripts with threading, but that never used to be a pr Please use the IPython console instead because the Python console is going to be removed in Spyder 3.2.",0.2012947653214861,False,1,4716 2017-02-07 12:23:56.853,Python caching attributes in object with __slots__,"I am trying to cache a computationally expensive property in a class defined with the __slots__ attribute. Any idea, how to store the cache for later use? Of course the usual way to store a dictionary in instance._cache would not work without __dict__ being defined. For several reasons i do not want to add a '_cache' string to __slots__. +I was thinking whether this is one of the rare use cases for global. Any thoughts or examples on this matter?","Something like Borg pattern can help. +You can alterate the status of your instance in the __init__ or __new__ methods.",-0.2655860252697744,False,2,4717 +2017-02-07 12:23:56.853,Python caching attributes in object with __slots__,"I am trying to cache a computationally expensive property in a class defined with the __slots__ attribute. +Any idea, how to store the cache for later use? Of course the usual way to store a dictionary in instance._cache would not work without __dict__ being defined. For several reasons i do not want to add a '_cache' string to __slots__. I was thinking whether this is one of the rare use cases for global. Any thoughts or examples on this matter?","There is no magic possible there - ou want to store a value, so you need a place to store your value. You can't just decide ""I won't have an extra entry on my __slots__ because it is not elegant"" - you don't need to call it _cached: give it whatever name you want, but these cached values are something you want to exist in each of the object's instances, and therefore you need an attribute. You can cache in a global (module level) dictionary, in which the keys are id(self) - but that would be a major headache to keep synchronized when instances are deleted. (The same thing is true for a class-level dictionary, with the further downside of it still be visible on the instance). TL;DR: the ""one and obvious way to do it"" is to have a shadow attribute, starting with ""_"" to keep the values you want cached, and declare these in __slots__. (If you use a _cached dictionary per instance, you loose the main advantage from __slots__, that is exactly not needing one dictionary per instance).",1.2,True,2,4717 -2017-02-07 12:23:56.853,Python caching attributes in object with __slots__,"I am trying to cache a computationally expensive property in a class defined with the __slots__ attribute. -Any idea, how to store the cache for later use? Of course the usual way to store a dictionary in instance._cache would not work without __dict__ being defined. For several reasons i do not want to add a '_cache' string to __slots__. -I was thinking whether this is one of the rare use cases for global. Any thoughts or examples on this matter?","Something like Borg pattern can help. -You can alterate the status of your instance in the __init__ or __new__ methods.",-0.2655860252697744,False,2,4717 2017-02-07 12:30:24.620,Django: best way to convert data from model to view,"My django app displays the objects from database in table view. The problem is that these objects (models) are pretty complex: the have 50+ fields. Nearly for each field I have to do some formatting: conver phone numbers from int 71234567689 to ""+7 (123) 456789"" @@ -45501,6 +45501,8 @@ how to set?","This was fixed in Spyder 3.2, which was released in July of 2017." Thanks for answering.","Online photo editor means that most of the processing will be done on the client side (i.e. in browser). Python is mostly a server-side language, so I would suggest using some other, more browser-friendly, language (perhaps, JavaScrip?)",0.0,False,1,4758 2017-03-03 15:46:27.173,how to switch python interpreter in cmd?,"I have installed both versions of python that is python 2.7 and python 3.5.3. When I run python command in command prompt, python 3.5.3 interpreter shows up. How can I switch to python 2.7 interpreter?","As has been mentioned in other answers to this and similar questions, if you're using Windows, cmd reads down the PATH variable from the top down. On my system I have Python 3.8 and 3.10 installed. I wanted my cmd to solely use 3.8, so I moved it to the top of the PATH variable and the next time I opened cmd and used python --version it returned 3.8. Hopefully this is useful for future devs researching this specific question.",0.0,False,5,4759 +2017-03-03 15:46:27.173,how to switch python interpreter in cmd?,"I have installed both versions of python that is python 2.7 and python 3.5.3. When I run python command in command prompt, python 3.5.3 interpreter shows up. How can I switch to python 2.7 interpreter?","Usually on all major operating systems the commands python2 and python3 run the correct version of Python respectively. If you have several versions of e.g. Python 3 installed, python32 or python35 would start Python 3.2 or Python 3.5. python usually starts the lowest version installed I think. +Hope this helps!",0.0,False,5,4759 2017-03-03 15:46:27.173,how to switch python interpreter in cmd?,"I have installed both versions of python that is python 2.7 and python 3.5.3. When I run python command in command prompt, python 3.5.3 interpreter shows up. How can I switch to python 2.7 interpreter?","It depends on OS (and the way Python has been installed). For most current installations: @@ -45510,8 +45512,6 @@ py -2 launches Python2 py -3 launches Python3 On Unix-likes, the most common way is to have different names for the executables of different versions (or to have different symlinks do them). So you can normally call directly python2.7 or python2 to start that version (and python3 or python3.5 for the alternate one). By default only a part of all those symlinks can have been installed but at least one per version. Search you path to find them",0.0,False,5,4759 -2017-03-03 15:46:27.173,how to switch python interpreter in cmd?,"I have installed both versions of python that is python 2.7 and python 3.5.3. When I run python command in command prompt, python 3.5.3 interpreter shows up. How can I switch to python 2.7 interpreter?","Usually on all major operating systems the commands python2 and python3 run the correct version of Python respectively. If you have several versions of e.g. Python 3 installed, python32 or python35 would start Python 3.2 or Python 3.5. python usually starts the lowest version installed I think. -Hope this helps!",0.0,False,5,4759 2017-03-03 15:46:27.173,how to switch python interpreter in cmd?,"I have installed both versions of python that is python 2.7 and python 3.5.3. When I run python command in command prompt, python 3.5.3 interpreter shows up. How can I switch to python 2.7 interpreter?","If you use Windows OS: py -2.7 for python 2.7 py -3 for python 3.x @@ -45665,13 +45665,13 @@ What i actually do is to connect to my raspberry with ssh. I am writing my sourc What i want to do is to write source code on my development computer but i do not know how to synchronize (transfer) this source code to raspberry. It is possible to do that with ftp for example but i will have to do something manual. I am looking for a system where i can press F5 on my IDE and this IDE will transfer modified source files. Do you know how can i do that ? -Thanks","Following a couple of bad experiences where I lost code which was only on my Pi's SD card, I now run WinSCP on my laptop, and edit files from Pi on my laptop, they open in Notepad++ and WinSCP automatically saves edits to Pi. And also I can use WinSCP folder sync feature to copy contents of SD card folder to my latop. Not perfect, but better what I was doing before",0.0,False,2,4779 +Thanks",I have done this before using bitbucket as a standard repository and it is not too bad. If you set up cron scripts to git pull it's almost like continuous integration.,0.0,False,2,4779 2017-03-14 13:38:07.647,Synchronize python files between my development computer and my raspberry,"I am writing a web python application with tornado framework on a raspberry pi. What i actually do is to connect to my raspberry with ssh. I am writing my source code with vi, on the raspberry. What i want to do is to write source code on my development computer but i do not know how to synchronize (transfer) this source code to raspberry. It is possible to do that with ftp for example but i will have to do something manual. I am looking for a system where i can press F5 on my IDE and this IDE will transfer modified source files. Do you know how can i do that ? -Thanks",I have done this before using bitbucket as a standard repository and it is not too bad. If you set up cron scripts to git pull it's almost like continuous integration.,0.0,False,2,4779 +Thanks","Following a couple of bad experiences where I lost code which was only on my Pi's SD card, I now run WinSCP on my laptop, and edit files from Pi on my laptop, they open in Notepad++ and WinSCP automatically saves edits to Pi. And also I can use WinSCP folder sync feature to copy contents of SD card folder to my latop. Not perfect, but better what I was doing before",0.0,False,2,4779 2017-03-15 05:13:08.727,Using javascript to pass web forms values to python script,"What I have done: 1- Created a web form using HTML and javascript to create a SSL certificate that can create dynamic certificates. 2- Successfully parsed through an existing certificate and passed the required values to the web form. @@ -45721,9 +45721,9 @@ GTIN 8 NO. NAME. PRICE. 64704739, TROUSERS, 15.00 47550544, CEREAL, 2.00 29783656, TOY, 10.00","Just read your text document, pick up rights informations, then put in in 3 differents arrays for name, GTIN, and price. Maybe you can show what your document looks like.",0.0,False,1,4785 -2017-03-16 23:48:59.197,How to run code in Pycharm,"If I go to ""tools"" and select ""python console"", and enter several lines of code, how do I execute this? If my cursor is at the end of the script, I can just hit enter. But how can I run the code using keyboard shortcuts if the cursor is not at the end? In Spyder this is done using shift+enter, but I can't figure out how to do it here. I've seen places say control+enter, but that doesn't work. Thanks!","If you use Win 10, 64Bits. Run your codes using Ctrl + Shift + F10 or simply right click on the workspace and click Run from the options.",0.2012947653214861,False,3,4786 2017-03-16 23:48:59.197,How to run code in Pycharm,"If I go to ""tools"" and select ""python console"", and enter several lines of code, how do I execute this? If my cursor is at the end of the script, I can just hit enter. But how can I run the code using keyboard shortcuts if the cursor is not at the end? In Spyder this is done using shift+enter, but I can't figure out how to do it here. I've seen places say control+enter, but that doesn't work. Thanks!","in mac. you can use fn+shift+f10 and happy coding with python",0.1016881243684853,False,3,4786 +2017-03-16 23:48:59.197,How to run code in Pycharm,"If I go to ""tools"" and select ""python console"", and enter several lines of code, how do I execute this? If my cursor is at the end of the script, I can just hit enter. But how can I run the code using keyboard shortcuts if the cursor is not at the end? In Spyder this is done using shift+enter, but I can't figure out how to do it here. I've seen places say control+enter, but that doesn't work. Thanks!","If you use Win 10, 64Bits. Run your codes using Ctrl + Shift + F10 or simply right click on the workspace and click Run from the options.",0.2012947653214861,False,3,4786 2017-03-16 23:48:59.197,How to run code in Pycharm,"If I go to ""tools"" and select ""python console"", and enter several lines of code, how do I execute this? If my cursor is at the end of the script, I can just hit enter. But how can I run the code using keyboard shortcuts if the cursor is not at the end? In Spyder this is done using shift+enter, but I can't figure out how to do it here. I've seen places say control+enter, but that doesn't work. Thanks!","Right click on project name / select New / select Python File Pycharm needs to know you're running a Python file before option to run is available",0.0,False,3,4786 2017-03-17 09:13:06.670,how to run python file in mongodb using cmd,I have a python file named abc.py. I can run it in mongodb with the help of robomongo but i couldnt run it in cmd. Can anyone tell me how to run a .py file in mongodb using cmd ?,"First you need to ensure that your directory is in the correct folder. @@ -45755,7 +45755,7 @@ to run correctly error thrown is cv2.error: ......\modules\python\src2\cv2.cpp:163: error: (-215) The data should normally be NULL! in function NumpyAllocator::allocate Also I am using Anaconda openCV version 3, and strictly dont want to switch to lower versions -P.S. as suggested at many places to edit file cv2.cpp option is not available with anaconda.",I would recommend installing pip in your anaconda environment then just doing: pip install opencv-contrib-python. This comes will opencv and opencv-contrib.,0.7408590612005881,False,2,4791 +P.S. as suggested at many places to edit file cv2.cpp option is not available with anaconda.",The question is old but I thought to update the answer with the latest information. My Anaconda version is 2019.10 and build channel is py_37_0 . I used pip install opencv-python==3.4.2.17 and pip install opencv-contrib-python==3.4.2.17. Now they are also visible as installed packages in Anaconda navigator and I am able to use patented methods like SIFT etc.,0.0679224682270276,False,2,4791 2017-03-19 11:56:32.790,how to get opencv_contrib module in anaconda,"Can anyone tell me commands to get contrib module for anaconda I need that module for matches = flann.knnMatch(des1,des2,k=2) @@ -45763,7 +45763,7 @@ to run correctly error thrown is cv2.error: ......\modules\python\src2\cv2.cpp:163: error: (-215) The data should normally be NULL! in function NumpyAllocator::allocate Also I am using Anaconda openCV version 3, and strictly dont want to switch to lower versions -P.S. as suggested at many places to edit file cv2.cpp option is not available with anaconda.",The question is old but I thought to update the answer with the latest information. My Anaconda version is 2019.10 and build channel is py_37_0 . I used pip install opencv-python==3.4.2.17 and pip install opencv-contrib-python==3.4.2.17. Now they are also visible as installed packages in Anaconda navigator and I am able to use patented methods like SIFT etc.,0.0679224682270276,False,2,4791 +P.S. as suggested at many places to edit file cv2.cpp option is not available with anaconda.",I would recommend installing pip in your anaconda environment then just doing: pip install opencv-contrib-python. This comes will opencv and opencv-contrib.,0.7408590612005881,False,2,4791 2017-03-21 00:49:45.707,python - IO Error [Errno 2] No such file or directory when downloading package,"I was trying to download a Python wrapper called rawpy on my Windows machine. I used the command ""pip install rawpy"". I have already looked at many other SO threads but could find no solution. The exact error is : IO Error: [Errno 2] No such file or directory: @@ -45834,7 +45834,8 @@ I get a popup error box that says: Python has stopped working A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available. -Can someone tell me how to resolve this issue or where to look for any error messages that might clue me in as to what is causing the problem?","I finally got the ""python manage.py runserver"" command to work. The only thing different I did was before setting up the virtual env and installing Django was set my executionpolicy to Unrestricted. Previously it had been set to RemoteSigned. I hadn't been gettiing any warning or errors but thought I would try it and it worked.",0.0,False,2,4800 +Can someone tell me how to resolve this issue or where to look for any error messages that might clue me in as to what is causing the problem?","I encountered the same problem. After trying everything, I switched from PS to cmd, cd to the same directory and run python manage.py runserver. Then it worked. Then I ctrl+C quit the server, switched back to PS, ran the command, it still threw the same dialog window (Python stopped working). Then I went back to cmd, typed the command and the server started fine. +Conclusion: Use cmd to run the command, not PS.",0.0,False,2,4800 2017-03-26 01:47:09.853,Python stops working on manage.py runserver,"I am new to stackoverflow, very new to Python and trying to learn Django. I am on Windows 10 and running commands from powershell (as administrator). I am in a virtual environment. I am trying to set up Django. @@ -45848,8 +45849,7 @@ I get a popup error box that says: Python has stopped working A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available. -Can someone tell me how to resolve this issue or where to look for any error messages that might clue me in as to what is causing the problem?","I encountered the same problem. After trying everything, I switched from PS to cmd, cd to the same directory and run python manage.py runserver. Then it worked. Then I ctrl+C quit the server, switched back to PS, ran the command, it still threw the same dialog window (Python stopped working). Then I went back to cmd, typed the command and the server started fine. -Conclusion: Use cmd to run the command, not PS.",0.0,False,2,4800 +Can someone tell me how to resolve this issue or where to look for any error messages that might clue me in as to what is causing the problem?","I finally got the ""python manage.py runserver"" command to work. The only thing different I did was before setting up the virtual env and installing Django was set my executionpolicy to Unrestricted. Previously it had been set to RemoteSigned. I hadn't been gettiing any warning or errors but thought I would try it and it worked.",0.0,False,2,4800 2017-03-26 08:47:57.337,How to add custom-fields (First and Last Name) in django-registration 2.2 (HMAC activation Workflow)?,"There are already some question on this but most of their answers are using models based workflow which is not a recommended way anymore according to django-registration. I am just frustrated from last week, trying to figure out how to add first and last name fields in registration form in HMAC Workflow.","I am not intimately familiar with django, but an easy solution would be to follow the default registration workflow to let your user register. Then when your user tries to login for the first time you present them with a form to fill with all the extra information you might need. In this way you also decouple the actual account creation from asking the user for more information, creating for them an extra incentive to actually go through with this process (""Oh man why do I need to provide my name, let's not sign up"" vs ""Oh well, I have already registered and given them an email might as well go through with it"") @@ -46039,15 +46039,15 @@ Either options are doable but I would suggest Scenario A. It's easier, quicker a 2017-04-07 05:12:15.973,The Anaconda launcher takes long time to load,"I'm new to coding and decided to install Anaconda because I heard it was the most practical platform for beginners. The problem is, every time I try opening it, it literally takes at least 15 minutes to boot up while showing me ""Updating metadata..."" and subsequently showing me ""Updating repodata..."" statements. Would any of you know how to fix or go around this issue? +I'm using a macbook air that has 8gb of RAM and an i5 processor, if that helps.","Some time restart works. I was also facing same issue, when I restarted my system it works like charm.",0.0,False,2,4826 +2017-04-07 05:12:15.973,The Anaconda launcher takes long time to load,"I'm new to coding and decided to install Anaconda because I heard it was the most practical platform for beginners. +The problem is, every time I try opening it, it literally takes at least 15 minutes to boot up while showing me ""Updating metadata..."" and subsequently showing me ""Updating repodata..."" statements. +Would any of you know how to fix or go around this issue? I'm using a macbook air that has 8gb of RAM and an i5 processor, if that helps.","I started Anaconda Navigator with ""Run as Administrator"" privileges on my Windows machine, and it worked like a charm. Though it did ask me for Admin credentials for a couple of times while loading different scripts, but the response was <1 min, compared to 6 - 8 mins. earlier. Search for Anaconda through desktop search or go to Cortana tool on the desktop toolbar and type Anaconda On the Anaconda icon that shows up, right-click and choose ""Run as Administrator"" Provide Admin credentials when prompted This should hopefully work for Windows 10 users.",0.0,False,2,4826 -2017-04-07 05:12:15.973,The Anaconda launcher takes long time to load,"I'm new to coding and decided to install Anaconda because I heard it was the most practical platform for beginners. -The problem is, every time I try opening it, it literally takes at least 15 minutes to boot up while showing me ""Updating metadata..."" and subsequently showing me ""Updating repodata..."" statements. -Would any of you know how to fix or go around this issue? -I'm using a macbook air that has 8gb of RAM and an i5 processor, if that helps.","Some time restart works. I was also facing same issue, when I restarted my system it works like charm.",0.0,False,2,4826 2017-04-07 06:08:07.263,How to restart a failed task on Airflow,"I am using a LocalExecutor and my dag has 3 tasks where task(C) is dependant on task(A). Task(B) and task(A) can run in parallel something like below A-->C B @@ -46089,9 +46089,9 @@ That is, every time I try something that should last maybe 5 secs, I end up spen Anybody know where to look to spot what is causing these constant death/rebirth circles? I have been using spyder for some time now and I never experienced this behaviour before, so I'm drawn to think it might have to do with PyQt, but that's about how far I can go.","I had a similar problem and found that my application only worked when the graphics settings inside Spyder are set to inline. This can be done at Tools -> Preferences -> IPython console -> Graphics, now change the Backends to inline. Hope this helps.",0.2012947653214861,False,1,4831 +2017-04-11 16:33:50.373,Activating Anaconda Environment in VsCode,"I have Anaconda working on my system and VsCode working, but how do I get VsCode to activate a specific environment when running my python script?",Just launch the VS Code from the Anaconda Navigator. It works for me.,0.1352210990936997,False,3,4832 2017-04-11 16:33:50.373,Activating Anaconda Environment in VsCode,"I have Anaconda working on my system and VsCode working, but how do I get VsCode to activate a specific environment when running my python script?","Unfortunately, this does not work on macOS. Despite the fact that I have export CONDA_DEFAULT_ENV='$HOME/anaconda3/envs/dev' in my .zshrc and ""python.pythonPath"": ""${env.CONDA_DEFAULT_ENV}/bin/python"", in my VSCode prefs, the built-in terminal does not use that environment's Python, even if I have started VSCode from the command line where that variable is set.",0.1618299653758019,False,3,4832 -2017-04-11 16:33:50.373,Activating Anaconda Environment in VsCode,"I have Anaconda working on my system and VsCode working, but how do I get VsCode to activate a specific environment when running my python script?",Just launch the VS Code from the Anaconda Navigator. It works for me.,0.1352210990936997,False,3,4832 2017-04-11 16:33:50.373,Activating Anaconda Environment in VsCode,"I have Anaconda working on my system and VsCode working, but how do I get VsCode to activate a specific environment when running my python script?","As I was not able to solve my problem by suggested ways, I will share how I fixed it. First of all, even if I was able to activate an environment, the corresponding environment folder was not present in C:\ProgramData\Anaconda3\envs directory. So I created a new anaconda environment using Anaconda prompt, @@ -46153,11 +46153,11 @@ If you need multiple sheets, you will have to make multiple csv files.",0.999329 However, I saw numerous other ways of installing Spyder, primarily via a pip3 install in the environment itself, but I found nothing as to how to actually RUN the pip-installed Spyder. Running ""Spyder3"" always runs the default install regardless of location. Does anyone know how to actually run it? I was curious because I figured it would allow for a similar functionality that Anaconda provides where you can simply select your virtual environment and run the respective Spyder version for it.","I figured out the issue. Seems that I was somehow running it from the wrong location, just had to run Spyder3 from the v-env bin folder.",1.2,True,1,4844 -2017-04-17 18:33:00.927,Jupyter reload custom.css?,"I'm using Jupyer 4.3.0. I find that when I update my ~/.jupyter/custom/custom.css, the changes are not reflected in my notebook until I kill jupyter-notebook and start it again. This is annoying, so how can I make Jupyter Notebook recognize the custom.css file changes without completely restarting the notebook?","The /custom/custom.css stopped working for me when I generated a config file, but if anyone stumbles to this problem too, the solution is to uncomment the line c.NotebookApp.extra_static_paths = [] in the jupyter_notebook_config.py file and add ""./custom/"" - or whatever path you chose for your custom css - inside the brackets. -P.S.: OS is Linux Manjaro 5.12 and Jupyter Notebook version is 6.3.0.",0.0,False,2,4845 2017-04-17 18:33:00.927,Jupyter reload custom.css?,"I'm using Jupyer 4.3.0. I find that when I update my ~/.jupyter/custom/custom.css, the changes are not reflected in my notebook until I kill jupyter-notebook and start it again. This is annoying, so how can I make Jupyter Notebook recognize the custom.css file changes without completely restarting the notebook?","I'm using Jupyter 5.0. Right now I've tried to edit custom.css and the changes are reflected immediately after reloading a page without restarting. I'm not sure about 4.3 version, but I guess it should work the same way. What did the property you change?",1.2,True,2,4845 +2017-04-17 18:33:00.927,Jupyter reload custom.css?,"I'm using Jupyer 4.3.0. I find that when I update my ~/.jupyter/custom/custom.css, the changes are not reflected in my notebook until I kill jupyter-notebook and start it again. This is annoying, so how can I make Jupyter Notebook recognize the custom.css file changes without completely restarting the notebook?","The /custom/custom.css stopped working for me when I generated a config file, but if anyone stumbles to this problem too, the solution is to uncomment the line c.NotebookApp.extra_static_paths = [] in the jupyter_notebook_config.py file and add ""./custom/"" - or whatever path you chose for your custom css - inside the brackets. +P.S.: OS is Linux Manjaro 5.12 and Jupyter Notebook version is 6.3.0.",0.0,False,2,4845 2017-04-18 07:54:11.413,how to combine 2D arrays into a 3D array in python?,"I have a project in which there is a for loop running about 14 times. In every iteration, a 2D array is created with this shape (4,3). I would like to concatenate those 2D arrays into one 3D array (with the shape of 4,3,14) so that every 2D array would be in different ""layer"". How should that be implemented in Python?","If your arrays are only 'list', sumplt defines an empty list at the beginning and append item into it: foo=[] @@ -46242,6 +46242,9 @@ I have an image as input,I run my function 2 times(image with and without image Any idea how to improve performance (processing time) in EC2?","I think you need to profile your code locally and ensure it really is CPU bound. Could it be that time is spent on the network or accessing disk (e.g. reading the image to start with). If it is CPU bound then explore how to exploit all the cores available (and 25% sounds suspicious - is it maxing out one core?). Python can be hard to parallelise due to the (in)famous GIL. However, only worry about this when you can prove it's a problem, profile first!",0.999329299739067,False,1,4858 2017-04-25 22:54:56.227,Cassandra: occasional permission errors,"I use cqlengine with django. In some occasions Cassandra throws an error indicating that user has no permissions do to something. Sometimes this is select, sometimes this is update or sometimes it is something else. I have no code to share, because there is no specific line that does this. I am very sure that user has all the permissions, and sometimes it works. So if user did not have the permissions it should always throw no permission error. +So what might be the reasons behind this and how to find the problem?","Is the system_auth keyspace RF the same as the amount of nodes? Did you try to run a repair on the system_auth keyspace already? If not do so. +For me it sounds like a consistency issue.",0.0,False,2,4859 +2017-04-25 22:54:56.227,Cassandra: occasional permission errors,"I use cqlengine with django. In some occasions Cassandra throws an error indicating that user has no permissions do to something. Sometimes this is select, sometimes this is update or sometimes it is something else. I have no code to share, because there is no specific line that does this. I am very sure that user has all the permissions, and sometimes it works. So if user did not have the permissions it should always throw no permission error. So what might be the reasons behind this and how to find the problem?","If you have authentication enabled, make sure you set appropriate RF for keyspace system_auth (should be equal to number of nodes). Secondly, make sure the user you have created has following permissions on all keyspaces. {'ALTER', 'CREATE', 'DROP', 'MODIFY', 'SELECT'}. If you have the user as a superuser make sure you add 'AUTHORIZE' as a permission along with the ones listed above for that user. Thirdly, you can set off a read-repair job for all the data in system_auth keyspace by running CONSISTENCY ALL; @@ -46249,22 +46252,19 @@ SELECT * from system_auth.users ; SELECT * from system_auth.permissions ; SELECT * from system_auth.credentials ; Hope this will resolve the issue !",0.0,False,2,4859 -2017-04-25 22:54:56.227,Cassandra: occasional permission errors,"I use cqlengine with django. In some occasions Cassandra throws an error indicating that user has no permissions do to something. Sometimes this is select, sometimes this is update or sometimes it is something else. I have no code to share, because there is no specific line that does this. I am very sure that user has all the permissions, and sometimes it works. So if user did not have the permissions it should always throw no permission error. -So what might be the reasons behind this and how to find the problem?","Is the system_auth keyspace RF the same as the amount of nodes? Did you try to run a repair on the system_auth keyspace already? If not do so. -For me it sounds like a consistency issue.",0.0,False,2,4859 2017-04-26 03:07:18.517,How to extract COMPLAINT features from texts in order to classify complaints from non-complaints texts,"I have a corpus of around 6000 texts with comments from social network (FB, twitter), news content from general and regional news and magazines, etc. I have gone through first 300 of these texts and tag each of these 300 texts' content as either customer complaint or non-complaint. Instead of naive way of bag of words, I am wondering how can I accurately extract the features of these complaints and non-complaints texts? My goal is to use SVM or other classification algorithm/ library such as Liblinear to most accurately classify the rest of these texts as either complaint or non-complaint with the current training set of 300 texts. Is this procedure similar to sentiment analysis? If not, where should I start?","I think you will find that bag-of-words is not so naive. It's actually a perfectly valid way of representing your data to give it to an SVM. If that's not giving you enough accuracy you can always include bigrams, i.e. word pairs, in your feature vector instead of just unigrams.",0.0,False,1,4860 2017-04-26 10:33:28.567,How to stop/kill Airflow tasks from the UI,"How can I stop/kill a running task on Airflow UI? I am using LocalExecutor. +Even if I use CeleryExecutor, how do can I kill/stop the running task?","As menioned by Pablo and Jorge pausing the Dag will not stop the task from being executed if the execution already started. However there is a way to stop a running task from the UI but it's a bit hacky. +When the task is on running state you can click on CLEAR this will call job.kill() the task will be set to shut_down and moved to up_for_retry immediately hence it is stopped. +Clearly Airflow did not meant for you to clear tasks in Running state however since Airflow did not disable it either you can use it as I suggested. Airflow meant CLEAR to be used with failed, up_for_retry etc... Maybe in the future the community will use this bug(?) and implement this as a functionality with ""shut down task"" button.",0.4540544406412981,False,2,4861 +2017-04-26 10:33:28.567,How to stop/kill Airflow tasks from the UI,"How can I stop/kill a running task on Airflow UI? I am using LocalExecutor. Even if I use CeleryExecutor, how do can I kill/stop the running task?","from airflow gitter (@villasv) "" Not gracefully, no. You can stop a dag (unmark as running) and clear the tasks states or even delete them in the UI. The actual running tasks in the executor won't stop, but might be killed if the executor realizes that it's not in the database anymore. """,0.7153027079198643,False,2,4861 -2017-04-26 10:33:28.567,How to stop/kill Airflow tasks from the UI,"How can I stop/kill a running task on Airflow UI? I am using LocalExecutor. -Even if I use CeleryExecutor, how do can I kill/stop the running task?","As menioned by Pablo and Jorge pausing the Dag will not stop the task from being executed if the execution already started. However there is a way to stop a running task from the UI but it's a bit hacky. -When the task is on running state you can click on CLEAR this will call job.kill() the task will be set to shut_down and moved to up_for_retry immediately hence it is stopped. -Clearly Airflow did not meant for you to clear tasks in Running state however since Airflow did not disable it either you can use it as I suggested. Airflow meant CLEAR to be used with failed, up_for_retry etc... Maybe in the future the community will use this bug(?) and implement this as a functionality with ""shut down task"" button.",0.4540544406412981,False,2,4861 2017-04-26 11:53:42.973,how to design this security demands?,"A python program P running on server S1, listening port 8443. Some other services can send id_isa, ip pair to P. P could use this pair and make a ssh connection to the ip (create a ssh process). How to make protect the id_rsa file even the machine S1 is cracked ? How to let root user can't get the id_rsa content (It seems ssh can use -i keyfile only)? @@ -46283,10 +46283,10 @@ Apologies if the question is poorly phrased/explained - I'm entirely self taught To store the data there are many options which could either be a flat file(write to a text file), save as a python binary(use shelf or pickle), or install an actual database like MySQL or PostgreSQL and many more. Google for info. Additionally an ORM like SQLAlchemy may make controlling, querying, and updating your database a little easier since it will handle all tables as objects and create the SQL itself so you don't need to code all queries as strings.",0.0,False,1,4864 2017-04-28 16:13:20.563,How to recognize Chinese or English name using python,"Given a bunch of names, how can we find out which are Chinese names and which are English names? For the Chinese names, I build a list of the Chinese last names to find out the Chinese names. For example, Bruce Lee, Lee is a Chinese last name, so we regard Bruce Lee is a Chinese name. However, the Chinese last names list is large. Is there any better way to do it? If you are not familiar with the Chinese name, you can tell how you will distinct the English names from some other names, like French names, Italian names, etc.","If you have the lists of typical Chinese and English names and the problem is performance only, I suggest you convert the lists into sets and then ask for membership in both sets as this is much faster than finding out whether an element is present in a large list.",0.3869120172231254,False,1,4865 2017-04-29 14:20:47.563,How can I open a Windows 10 app with a python script?,"So, as you may know there are certain apps on Windows that can be installed from the app store, and are classified as Windows Trusted Apps. I am not sure, but I think these do not use the classic .exe format. So I am writing a python script to automate some stuff when I start my pc, and I need to start a certain Windows App, but I don't know how to do this as I don't know what I need to start to do so, and I also do not know where these files are located. Anyone can help?","You can use this new technique, its called winapps its used for searching, modifying, and uninstalling apps. Its download command on cmd windows is pip install winapps.",0.0,False,1,4866 +2017-04-30 17:10:26.033,Downloading Random.py Using Anaconda,"I am trying to download the random module and was wondering if I copy a code and put it in a file editor, how do I go about installing it through pip? I placed the code in notepad and saved it on my desktop as random.py. What do I do now so that I can get this in installed through anaconda? I tried pip install random.py but it says the package is not found. Is there perhaps a zip file of the random module that I can install?",Use pip install random. That works with every Python distribution.,-0.1352210990936997,False,2,4867 2017-04-30 17:10:26.033,Downloading Random.py Using Anaconda,"I am trying to download the random module and was wondering if I copy a code and put it in a file editor, how do I go about installing it through pip? I placed the code in notepad and saved it on my desktop as random.py. What do I do now so that I can get this in installed through anaconda? I tried pip install random.py but it says the package is not found. Is there perhaps a zip file of the random module that I can install?","If using python3, it will simply be pip3 install random as @Remi stated.",0.0,False,2,4867 -2017-04-30 17:10:26.033,Downloading Random.py Using Anaconda,"I am trying to download the random module and was wondering if I copy a code and put it in a file editor, how do I go about installing it through pip? I placed the code in notepad and saved it on my desktop as random.py. What do I do now so that I can get this in installed through anaconda? I tried pip install random.py but it says the package is not found. Is there perhaps a zip file of the random module that I can install?",Use pip install random. That works with every Python distribution.,-0.1352210990936997,False,2,4867 2017-04-30 21:20:16.187,Mathematical functions on Python 3,"I have a work to do on numerical analysis that consists on implementing algorithms for root-finding problems. Among them are the Newton method which calculates values for a function f(x) and it's first derivative on each iteraction. For that method I need a way to the user of my application enter a (mathematical) function and save it as a variable and use that information to give values of that function on different points. I know just the very basic of Python programming and maybe this is pretty easy, but how can I do it?","If you trust the user, you could input a string, the complete function expression as it would be done in Python, then call eval() on that string. Python itself evaluates the expression. However, the user could use that string to do many things in your program, many of them very nasty such as taking over your computer or deleting files. If you do not trust the user, you have much more work to do. You could program a ""function builder"", much like the equation editor in Microsoft Word and similar programs. If you ""know just the very basic of Python programming"" this is beyond you. You might be able to use a search engine to find one for Python. @@ -46888,11 +46888,11 @@ anaconda python 3.6","Set the environment path variable of your default python i or if this doesn't work do: in cmd C:\Python27\python.exe yourfilename.py in the command first part is your interpreter location and second is your file name",1.2,True,1,4940 +2017-06-16 16:50:21.430,Discord.py show who invited a user,"I am currently trying to figure out a way to know who invited a user. From the official docs, I would think that the member class would have an attribute showing who invited them, but it doesn't. I have a very faint idea of a possible method to get the user who invited and that would be to get all invites in the server then get the number of uses, when someone joins the server, it checks to see the invite that has gone up a use. But I don't know if this is the most efficient method or at least the used method.","Watching the number of uses an invite has had, or for when they run out of uses and are revoked, is the only way to see how a user was invited to the server.",0.1352210990936997,False,2,4941 2017-06-16 16:50:21.430,Discord.py show who invited a user,"I am currently trying to figure out a way to know who invited a user. From the official docs, I would think that the member class would have an attribute showing who invited them, but it doesn't. I have a very faint idea of a possible method to get the user who invited and that would be to get all invites in the server then get the number of uses, when someone joins the server, it checks to see the invite that has gone up a use. But I don't know if this is the most efficient method or at least the used method.","In Discord, you're never going to 100% sure who invited the user. Using Invite, you know who created the invite. Using on_member_join, you know who joined. So, yes, you could have to check invites and see which invite got revoked. However, you will never know for sure who invited since anyone can paste the same invite link anywhere.",0.1352210990936997,False,2,4941 -2017-06-16 16:50:21.430,Discord.py show who invited a user,"I am currently trying to figure out a way to know who invited a user. From the official docs, I would think that the member class would have an attribute showing who invited them, but it doesn't. I have a very faint idea of a possible method to get the user who invited and that would be to get all invites in the server then get the number of uses, when someone joins the server, it checks to see the invite that has gone up a use. But I don't know if this is the most efficient method or at least the used method.","Watching the number of uses an invite has had, or for when they run out of uses and are revoked, is the only way to see how a user was invited to the server.",0.1352210990936997,False,2,4941 2017-06-16 18:24:13.907,Get unix file type with Python os module,"I would like to get the unix file type of a file specified by path (find out whether it is a regular file, a named pipe, a block device, ...) I found in the docs os.stat(path).st_type but in Python 3.6, this seems not to work. Another approach is to use os.DirEntry objects (e. g. by os.listdir(path)), but there are only methods is_dir(), is_file() and is_symlink(). @@ -46924,12 +46924,12 @@ You will need some logic to ""unlock for checking"" if the first user does not c 2017-06-18 19:31:38.603,How to share data between programs that use different languages to run,"I want to share data between programs that run locally which uses different languages, I don't know how to approach this. For example, if I have a program that uses C# to run and another that uses python to run, and I want to share some strings between the two, how can I do it? I thought about using sockets for this but I'm not sure that this is the right approach, I also thought about saving the data in a file, then reading the file from the other program, but, it might even be worse than using sockets. -Note that I need to share strings almost a thousand times between the programs","Any kind of IPC (InterProcess Communication) — sockets or shared memory. Any common format — plain text files or structured, JSON, e.g. Or a database.",0.2012947653214861,False,2,4945 +Note that I need to share strings almost a thousand times between the programs","There are a lot of ways to do so, I would recommend you reading more about IPC (Inter Process Communication) - sockets, pipes, named pipes, shared memory and etc... +Each method has it's own advantages, therefore, you need to think about what you're trying to achieve and choose the method that fits you the best.",1.2,True,2,4945 2017-06-18 19:31:38.603,How to share data between programs that use different languages to run,"I want to share data between programs that run locally which uses different languages, I don't know how to approach this. For example, if I have a program that uses C# to run and another that uses python to run, and I want to share some strings between the two, how can I do it? I thought about using sockets for this but I'm not sure that this is the right approach, I also thought about saving the data in a file, then reading the file from the other program, but, it might even be worse than using sockets. -Note that I need to share strings almost a thousand times between the programs","There are a lot of ways to do so, I would recommend you reading more about IPC (Inter Process Communication) - sockets, pipes, named pipes, shared memory and etc... -Each method has it's own advantages, therefore, you need to think about what you're trying to achieve and choose the method that fits you the best.",1.2,True,2,4945 +Note that I need to share strings almost a thousand times between the programs","Any kind of IPC (InterProcess Communication) — sockets or shared memory. Any common format — plain text files or structured, JSON, e.g. Or a database.",0.2012947653214861,False,2,4945 2017-06-18 19:41:42.263,Python(scapy): how to sniff packets that are only outboun packets,"how do I sniff packets that are only outbound packets? I tried to sniff only destination port but it doesn't succeed at all",Maybe you can get your device MAC address and filter any packets with that address as source address.,0.0,False,1,4946 2017-06-19 09:17:05.203,python- how to find same words in two different excel workbooks,"I want to find the same words in two different excel workbooks. I have two excel workbooks (data.xls and data1.xls). If in data.xls have the same words in the data1.xls, i want it to print the row of data1.xls that contain of the same words with data.xls. I hope u can help me. Thank you.","I am assuming that both excel sheets have a list of words, with one word in each cell. @@ -47153,18 +47153,7 @@ I can see two general solutions to this problem. One is to install rpy2 through Incompatible library version: _rinterface.cpython-36m-darwin.so requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0 -After much struggling, I've found no good result with either.","I uninstalled rpy2 and reinstalled with --verborse. I then found - -ld: warning: ignoring file /opt/local/lib/libpcre.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libpcre.dylib - ld: warning: ignoring file /opt/local/lib/liblzma.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/liblzma.dylib - ld: warning: ignoring file /opt/local/lib/libbz2.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libbz2.dylib - ld: warning: ignoring file /opt/local/lib/libz.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libz.dylib - ld: warning: ignoring file /opt/local/lib/libiconv.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libiconv.dylib - ld: warning: ignoring file /opt/local/lib/libicuuc.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libicuuc.dylib - ld: warning: ignoring file /opt/local/lib/libicui18n.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libicui18n.dylib - ld: warning: ignoring file /opt/local/Library/Frameworks/R.framework/R, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/Library/Frameworks/R.framework/R - -So I supposed the reason is the architecture incompatibility of the libiconv in opt/local, causing make to fall back onto the outdate libiconv in usr/lib. This is strange because my machine should be running on x86_64 not i386. I then tried export ARCHFLAGS=""-arch x86_64"" and reinstalled libiconv using port. This resolved the problem.",1.2,True,2,4969 +After much struggling, I've found no good result with either.",I had uninstall the version pip installed and install from source python setup.py install on the download https://bitbucket.org/rpy2/rpy2/downloads/. FWIW not using Anaconda at all either.,0.0,False,2,4969 2017-06-29 22:49:40.293,Installing rpy2 to work with R 3.4.0 on OSX,"I would like to use some R packages requiring R version 3.4 and above. I want to access these packages in python (3.6.1) through rpy2 (2.8). I have R version 3.4 installed, and it is located in /Library/Frameworks/R.framework/Resources However, when I use pip3 install rpy2 to install and use the python 3.6.1 in /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6) as my interpreter, I get the error: @@ -47185,17 +47174,28 @@ I can see two general solutions to this problem. One is to install rpy2 through Incompatible library version: _rinterface.cpython-36m-darwin.so requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0 -After much struggling, I've found no good result with either.",I had uninstall the version pip installed and install from source python setup.py install on the download https://bitbucket.org/rpy2/rpy2/downloads/. FWIW not using Anaconda at all either.,0.0,False,2,4969 -2017-06-30 05:32:37.393,how can I change default python version in pythonanywhere?,"I am trying to deploy my Django application on pythonanywhere through manual-configuration. I selected Python 3.6.When I opened the console and type ""python --version"" It is showing python 2.7 instead of 3.6. How can I change this? -Please help me.","Try to type ""python3 --version"". This can work on linux, but I am not sure whether it works on pythonanywhere",0.0,False,3,4970 -2017-06-30 05:32:37.393,how can I change default python version in pythonanywhere?,"I am trying to deploy my Django application on pythonanywhere through manual-configuration. I selected Python 3.6.When I opened the console and type ""python --version"" It is showing python 2.7 instead of 3.6. How can I change this? -Please help me.",Python 3.6 is available as python3.6 in a console on PythonAnywhere.,1.2,True,3,4970 +After much struggling, I've found no good result with either.","I uninstalled rpy2 and reinstalled with --verborse. I then found + +ld: warning: ignoring file /opt/local/lib/libpcre.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libpcre.dylib + ld: warning: ignoring file /opt/local/lib/liblzma.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/liblzma.dylib + ld: warning: ignoring file /opt/local/lib/libbz2.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libbz2.dylib + ld: warning: ignoring file /opt/local/lib/libz.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libz.dylib + ld: warning: ignoring file /opt/local/lib/libiconv.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libiconv.dylib + ld: warning: ignoring file /opt/local/lib/libicuuc.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libicuuc.dylib + ld: warning: ignoring file /opt/local/lib/libicui18n.dylib, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/lib/libicui18n.dylib + ld: warning: ignoring file /opt/local/Library/Frameworks/R.framework/R, file was built for x86_64 which is not the architecture being linked (i386): /opt/local/Library/Frameworks/R.framework/R + +So I supposed the reason is the architecture incompatibility of the libiconv in opt/local, causing make to fall back onto the outdate libiconv in usr/lib. This is strange because my machine should be running on x86_64 not i386. I then tried export ARCHFLAGS=""-arch x86_64"" and reinstalled libiconv using port. This resolved the problem.",1.2,True,2,4969 2017-06-30 05:32:37.393,how can I change default python version in pythonanywhere?,"I am trying to deploy my Django application on pythonanywhere through manual-configuration. I selected Python 3.6.When I opened the console and type ""python --version"" It is showing python 2.7 instead of 3.6. How can I change this? Please help me.","to set your default python version from 2.7 to 3.7 run the command below $ alias python=python3 that's it now check the version $ python --version it should be solved",0.2012947653214861,False,3,4970 +2017-06-30 05:32:37.393,how can I change default python version in pythonanywhere?,"I am trying to deploy my Django application on pythonanywhere through manual-configuration. I selected Python 3.6.When I opened the console and type ""python --version"" It is showing python 2.7 instead of 3.6. How can I change this? +Please help me.","Try to type ""python3 --version"". This can work on linux, but I am not sure whether it works on pythonanywhere",0.0,False,3,4970 +2017-06-30 05:32:37.393,how can I change default python version in pythonanywhere?,"I am trying to deploy my Django application on pythonanywhere through manual-configuration. I selected Python 3.6.When I opened the console and type ""python --version"" It is showing python 2.7 instead of 3.6. How can I change this? +Please help me.",Python 3.6 is available as python3.6 in a console on PythonAnywhere.,1.2,True,3,4970 2017-06-30 17:24:12.180,Python : Redirecting device with MITM,"I have built a MITM with python and scapy.I want to make the ""victim"" device be redirected to a specific page each time it tried to access a website. Any suggestions on how to do it? *Keep in mind that all the traffic from the device already passes through my machine before being routed.","You can directly answer HTTP requests to pages different to that specific webpage with HTTP redirections (e.g. HTTP 302). Moreover, you should only route packets going to the desired webpage and block the rest (you can do so with a firewall such as iptables).",1.2,True,1,4971 2017-07-01 06:19:03.213,how to get random pixel index from binary image with value 1 in python?,"I have a binary image of large size (2000x2000). In this image most of the pixel values are zero and some of them are 1. I need to get only 100 randomly chosen pixel coordinates with value 1 from image. I am beginner in python, so please answer.","I'd suggest making a list of coordinates of all non-zero pixels (by checking all pixels in the image), then using random.shuffle on the list and taking the first 100 elements.",0.296905446847765,False,1,4972 @@ -47468,11 +47468,7 @@ on terminal.",0.0,False,1,5011 2017-07-26 19:26:01.650,Downloading python 3 on windows,"I am currently trying to figure out how to set up using python 3 on my machine (Windows 10 pro 64-bit), but I keep getting stuck. I used the Python 3.6 downloader to install python, but whenever I try to use Command Prompt it keeps saying ""'python' is not recognized as an internal or external command, operable program or batch file"" as if I have not yet installed it. Unlike answers to previous questions, I have already added "";C:\Python36"" to my Path environment variable, so what am I doing wrong? -I am relatively new to python, but know how to use it on my Mac, so please let me know if I'm just fundamentally confused about something.","In environmental variables under path, add your python path... you said you already so please ensure is their comma separation between previous path.. -And once added save environment variables tab. And close all command prompt then open it. -Then only command prompt will refresh with your python config.. -Main thing, if you enter python which mean python 2. -For python3 type, python3 then it should work",0.1352210990936997,False,3,5012 +I am relatively new to python, but know how to use it on my Mac, so please let me know if I'm just fundamentally confused about something.","Thanks everyone, I ended up uninstalling and then re-downloading python, and selecting the button that says ""add to environment variables."" Previously, I typed the addition to Path myself, so I thought it might make a difference if I included it in the installation process instead. Then, I completely restarted my computer rather than just Command Prompt itself. I'm not sure which of these two things did it, but it works now!",0.0,False,3,5012 2017-07-26 19:26:01.650,Downloading python 3 on windows,"I am currently trying to figure out how to set up using python 3 on my machine (Windows 10 pro 64-bit), but I keep getting stuck. I used the Python 3.6 downloader to install python, but whenever I try to use Command Prompt it keeps saying ""'python' is not recognized as an internal or external command, operable program or batch file"" as if I have not yet installed it. Unlike answers to previous questions, I have already added "";C:\Python36"" to my Path environment variable, so what am I doing wrong? @@ -47481,7 +47477,11 @@ If you have to use command prompt for some reason, you’re problem is probably 2017-07-26 19:26:01.650,Downloading python 3 on windows,"I am currently trying to figure out how to set up using python 3 on my machine (Windows 10 pro 64-bit), but I keep getting stuck. I used the Python 3.6 downloader to install python, but whenever I try to use Command Prompt it keeps saying ""'python' is not recognized as an internal or external command, operable program or batch file"" as if I have not yet installed it. Unlike answers to previous questions, I have already added "";C:\Python36"" to my Path environment variable, so what am I doing wrong? -I am relatively new to python, but know how to use it on my Mac, so please let me know if I'm just fundamentally confused about something.","Thanks everyone, I ended up uninstalling and then re-downloading python, and selecting the button that says ""add to environment variables."" Previously, I typed the addition to Path myself, so I thought it might make a difference if I included it in the installation process instead. Then, I completely restarted my computer rather than just Command Prompt itself. I'm not sure which of these two things did it, but it works now!",0.0,False,3,5012 +I am relatively new to python, but know how to use it on my Mac, so please let me know if I'm just fundamentally confused about something.","In environmental variables under path, add your python path... you said you already so please ensure is their comma separation between previous path.. +And once added save environment variables tab. And close all command prompt then open it. +Then only command prompt will refresh with your python config.. +Main thing, if you enter python which mean python 2. +For python3 type, python3 then it should work",0.1352210990936997,False,3,5012 2017-07-27 03:50:16.467,python 3.6.2 not giving me option to create or run files or anything of the sort,"I know some basics of Java and C++, and am looking to learn Python I am trying to develop some random stuffs to get a good feel of how it works, but i can only make 1 line scripts that run every time i press enter to go to the next line. I've seen tutorial videos where they can just open up files from a menu and type away until they eventually run the program. @@ -47716,8 +47716,9 @@ error: ModuleNotFoundError: No module named 'pyaudio' Can anyone help me work out this problem? I am not familiar with Ubuntu and it's commands paths etc as I've only been using it a few months. -If you need more information, let me know what, and how. Thanks","Check in the documentation of pyaudio if it is compatible with your python version -Some modules which are not compatible may be installed without issues, yet still won't work when trying to access them",1.2,True,2,5044 +If you need more information, let me know what, and how. Thanks","if you are using windows then these command on the terminal: +pip install pipwin +pipwin install pyaudio",0.0,False,2,5044 2017-08-14 13:57:41.950,ModuleNotFoundError: No module named 'pyaudio',"I ran pip install pyaudio in my terminal and got this error: Command ""/home/oliver/anaconda3/bin/python -u -c ""import setuptools, @@ -47734,9 +47735,8 @@ error: ModuleNotFoundError: No module named 'pyaudio' Can anyone help me work out this problem? I am not familiar with Ubuntu and it's commands paths etc as I've only been using it a few months. -If you need more information, let me know what, and how. Thanks","if you are using windows then these command on the terminal: -pip install pipwin -pipwin install pyaudio",0.0,False,2,5044 +If you need more information, let me know what, and how. Thanks","Check in the documentation of pyaudio if it is compatible with your python version +Some modules which are not compatible may be installed without issues, yet still won't work when trying to access them",1.2,True,2,5044 2017-08-15 07:22:37.923,"Modifying and creating xlsx files with Python, specifically formatting single words of a e.g. sentence in a cell","I'm working a lot with Excel xlsx files which I convert using Python 3 into Pandas dataframes, wrangle the data using Pandas and finally write the modified data into xlsx files again. The files contain also text data which may be formatted. While most modifications (which I have done) have been pretty straight forward, I experience problems when it comes to partly formatted text within a single cell: Example of cell content: ""Medical device whith remote control and a Bluetooth module for communication"" @@ -47980,14 +47980,17 @@ I want my virtualenvs to contain version 3 and anything outside my virtualenvs s Is this even possible. Thanks a lot for any answers.",You can simply apt-get install python3 and then use -p python3 while creating your virtual environment. Installing python3 will not disturb your system python (2.7).,-0.4701041941942874,False,1,5074 2017-09-02 08:08:31.797,How to do superscripts and subscripts in Jupyter Notebook?,"I want to to use numbers to indicate references in footnotes, so I was wondering inside of Jupyter Notebook how can I use superscripts and subscripts?","superscript text also works, and might be better because latex formatting changes the whole line etc.",0.9999997749296758,False,1,5075 +2017-09-02 18:14:43.557,How can I convert '?' to NaN,"I have a dataset and there are missing values which are encoded as ?. My problem is how can I change the missing values, ?, to NaN? So I can drop any row with NaN. Can I just use .replace() ?","You can also do like this, + +df[df == '?'] = np.nan",0.1016881243684853,False,2,5076 2017-09-02 18:14:43.557,How can I convert '?' to NaN,"I have a dataset and there are missing values which are encoded as ?. My problem is how can I change the missing values, ?, to NaN? So I can drop any row with NaN. Can I just use .replace() ?","You can also read the data initially by passing df = pd.read_csv('filename',na_values = '?') It will automatically replace '?' to NaN",0.2012947653214861,False,2,5076 -2017-09-02 18:14:43.557,How can I convert '?' to NaN,"I have a dataset and there are missing values which are encoded as ?. My problem is how can I change the missing values, ?, to NaN? So I can drop any row with NaN. Can I just use .replace() ?","You can also do like this, +2017-09-02 22:37:27.403,Keep Google Cloud Jupyter Notebook Running while computer sleeps,"So I want to run a neural network on Google Cloud instance, but whenever my computer goes to sleep the notebook seems to stop running. Does anyone know how I can keep it running?","In the remote (GCP) SSH client: -df[df == '?'] = np.nan",0.1016881243684853,False,2,5076 -2017-09-02 22:37:27.403,Keep Google Cloud Jupyter Notebook Running while computer sleeps,"So I want to run a neural network on Google Cloud instance, but whenever my computer goes to sleep the notebook seems to stop running. Does anyone know how I can keep it running?","I just discovered this huge oversight in GCP. I don't understand how they could design it this way. This behavior defeats a major point of using the cloud. They want us to pay for this? I use a laptop which sometimes needs to be asleep in a backpack, I can't keep a computer on all day just so a cloud computer can run. -If I can't figure anything else out, we are just going to have to use two cloud computers. Maybe use like a small free cloud computer to keep the big datalab one running. We shouldn't have to resort to this.",0.2655860252697744,False,3,5077 +Install tmux: sudo apt-get install tmux. +Start a new tmux session: tmux new -s ""session"". +Run commands as normal.",0.0,False,3,5077 2017-09-02 22:37:27.403,Keep Google Cloud Jupyter Notebook Running while computer sleeps,"So I want to run a neural network on Google Cloud instance, but whenever my computer goes to sleep the notebook seems to stop running. Does anyone know how I can keep it running?","I know it's an old question but let me give it a shot. When you say Google Cloud instance do you mean their compute engine (virtual machine)? If so, you don't need to keep your laptop running all the time to continue a process on cloud, there is an alternative. You can run your python programs from terminal and use tools like Screen or tmux, which keep running your (training) process even if your GC instance is disconnected. You can even turn your system off. I just finished a 24 hr long Hyperparameter optimization marathon few days back. Allow me to also mention here that sometimes ""Screen"" throws X11 display related errors, so tmux can be used instead. Usage Instructions: @@ -48000,11 +48003,8 @@ attach a session : tmux attach -t ""id_from_above_command_lists"" kill a tmux session : ctrl+shift+d Note: Commands are mentioned based on what I remember, it may have mistakes. Quick search would give you exact syntax. Idea is to show how easy it is to use.",0.0,False,3,5077 -2017-09-02 22:37:27.403,Keep Google Cloud Jupyter Notebook Running while computer sleeps,"So I want to run a neural network on Google Cloud instance, but whenever my computer goes to sleep the notebook seems to stop running. Does anyone know how I can keep it running?","In the remote (GCP) SSH client: - -Install tmux: sudo apt-get install tmux. -Start a new tmux session: tmux new -s ""session"". -Run commands as normal.",0.0,False,3,5077 +2017-09-02 22:37:27.403,Keep Google Cloud Jupyter Notebook Running while computer sleeps,"So I want to run a neural network on Google Cloud instance, but whenever my computer goes to sleep the notebook seems to stop running. Does anyone know how I can keep it running?","I just discovered this huge oversight in GCP. I don't understand how they could design it this way. This behavior defeats a major point of using the cloud. They want us to pay for this? I use a laptop which sometimes needs to be asleep in a backpack, I can't keep a computer on all day just so a cloud computer can run. +If I can't figure anything else out, we are just going to have to use two cloud computers. Maybe use like a small free cloud computer to keep the big datalab one running. We shouldn't have to resort to this.",0.2655860252697744,False,3,5077 2017-09-03 14:34:16.643,I want to make a cronjob such that it runs a python script every second,"I tried making a cronjob to run my script every second, i used */60 * * * * this a parameter to run every second but it didn't worked, pls suggest me how should i run my script every second ?","Well, no. Your argument - */60 * * * * - means ""run every 60 minutes"". And you can't specify a shorter interval than 1 minute, not in standard Unix cron anyway.",1.2,True,1,5078 2017-09-03 21:51:38.560,Making a 32 bit .exe from PyInstaller using PyCharm,"I have a 64 bit PC, and python 3.6.2 (64 bit), python 3.5.4 (32 bit), and python 3.5.4 (64 bit), all installed and added to my path. In Pycharm, I created a virtual environment based off of python 3.5.4 (32 bit) and wrote a project in this env. Each version of python I have installed has an associated virtual env, and all of them have pyinstaller installed on them via Pycharm's installer. @@ -48017,9 +48017,6 @@ It's normally something like python -m pyinstaller {args} but other ones could b I'd recommend using a virtual environment so you're sure what Python interpreter you're using.",1.2,True,1,5079 2017-09-04 13:59:50.270,how to prepare image dataset for training model?,"I have a project that use Deep CNN to classify parking lot. My idea is to classify every space whether there is a car or not. and my question is, how do i prepare my image dataset to train my model ? i have downloaded PKLot dataset for training included negative and positive image. -should i turn all my data training image to grayscale ? should i rezise all my training image to one fix size? (but if i resize my training image to one fixed size, i have landscape and portrait image). Thanks :)","First detect the cars present in the image, and obtain their size and alignment. Then go for segmentation and labeling of the parking lot by fixing a suitable size and alignment.",0.1352210990936997,False,2,5080 -2017-09-04 13:59:50.270,how to prepare image dataset for training model?,"I have a project that use Deep CNN to classify parking lot. My idea is to classify every space whether there is a car or not. and my question is, how do i prepare my image dataset to train my model ? -i have downloaded PKLot dataset for training included negative and positive image. should i turn all my data training image to grayscale ? should i rezise all my training image to one fix size? (but if i resize my training image to one fixed size, i have landscape and portrait image). Thanks :)","as you want use pklot dataset for training your machine and test with real data, the best approach is to make both datasets similar and homological, they must be normalized , fixed sized , gray-scaled and parameterized shapes. then you can use Scale-invariant feature transform (SIFT) for image feature extraction as basic method.the exact definition often depends on the problem or the type of application. Since features are used as the starting point and main primitives for subsequent algorithms, the overall algorithm will often only be as good as its feature detector. you can use these types of image features based on your problem: Corners / interest points @@ -48027,6 +48024,9 @@ Edges Blobs / regions of interest points Ridges ...",0.1352210990936997,False,2,5080 +2017-09-04 13:59:50.270,how to prepare image dataset for training model?,"I have a project that use Deep CNN to classify parking lot. My idea is to classify every space whether there is a car or not. and my question is, how do i prepare my image dataset to train my model ? +i have downloaded PKLot dataset for training included negative and positive image. +should i turn all my data training image to grayscale ? should i rezise all my training image to one fix size? (but if i resize my training image to one fixed size, i have landscape and portrait image). Thanks :)","First detect the cars present in the image, and obtain their size and alignment. Then go for segmentation and labeling of the parking lot by fixing a suitable size and alignment.",0.1352210990936997,False,2,5080 2017-09-05 13:26:03.680,How to install Python using Windows Command Prompt,"Is it possible to install Python from cmd on Windows? If so, how to do it?","For Windows I was unable to find a way to Download python using just CMD but if you have python.exe in your system then you can use the below Method to install it (you can also make .bat file to automate it.) @@ -48060,13 +48060,13 @@ Two notes regarding Accept: Please read up on how to use the Accept header before attempting to implement against it. Here is an actual example from this website: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9. Given this, I would return back HTML. The value of the header can be */*, which basically just says ""whatever"" or ""I don't care"". At that point, the server is allowed to determine the response format.",0.5457054096481145,False,1,5083 -2017-09-07 16:39:20.957,how can i join two users in a telegram chat bot?,"I am going to make a telegram bot in Python 3 which is a random chat bot. As I am new in telegram bots, I don't know how to join two different people in a chat bot. Is there a guide available for this?","I am not sure to understand your question, can you give us what you pretend to do more explained? -You have a few options, creating a group and adding the bot to it. -In private chat you only can talk with a single user at a time.",0.0,False,2,5084 2017-09-07 16:39:20.957,how can i join two users in a telegram chat bot?,"I am going to make a telegram bot in Python 3 which is a random chat bot. As I am new in telegram bots, I don't know how to join two different people in a chat bot. Is there a guide available for this?","You need to make a database with chatID as primary column. and another column as partner. which stores his/her chat partner chatID. now when a user sends a message to you bot you just need to check the database for that user and send the message to her chat partner. after the chat is done you should empty partner fields of both users. And for the picking part. when a user wants to find a new partner, choose a random row from your database WHERE partnerChatID is Null and set them to first users ID and vise versa.",1.2,True,2,5084 +2017-09-07 16:39:20.957,how can i join two users in a telegram chat bot?,"I am going to make a telegram bot in Python 3 which is a random chat bot. As I am new in telegram bots, I don't know how to join two different people in a chat bot. Is there a guide available for this?","I am not sure to understand your question, can you give us what you pretend to do more explained? +You have a few options, creating a group and adding the bot to it. +In private chat you only can talk with a single user at a time.",0.0,False,2,5084 2017-09-08 02:07:39.457,Should I put ntlk.download() in my .py file?,"For some reason, when I put nltk.download() in my .py file after import nltk, it doesn't run correctly in Spyder. It does run with the anaconda prompt though. Should I include it in my .py file? If so, how do I get Spyder to be ok with that? Thanks!","I don't know what you want actually. If you just need the corpus in nltk, you don't have to put nltk.download() in you code but run nltk.download() once in the shell and download the corpus you need. Remind there is another function called nltk.download-gui(). You can try it in spyder or maybe you should change the graphics backend to Qt5 in your spyder settings if that's the problem.",0.0,False,1,5085 2017-09-09 06:47:01.070,python how to define function with optional parameters by square brackets?,"I often find some functions defined like open(name[, mode[, buffering]]) and I know it means optional parameters. @@ -48175,6 +48175,10 @@ The parallel circuit can be controlled manually (for testing) or automatically ( 2017-09-16 09:07:54.803,How to extract reviews from facebook public page without page access token?,"I want to extract reviews from public facebook pages like airline page, hospital page, to perform sentiment analysis. I have app id and app secret id which i generated from facebook graph API using my facebook account, But to extract the reviews I need page access token and as I am not the owner/admin of the page so I can not generate that page access token. Is any one know how to do it or it requires some paid service? Kindly help. Thanks in advance.","Without a Page Token of the Page, it is impossible to get the reviews/ratings. You can only get those for Pages you own. There is no paid service either, you can only ask the Page owners to give you access.",0.3869120172231254,False,1,5101 +2017-09-17 19:14:10.500,"Storing a username and password, then allowing user update. Python","I am trying to create a program that asks the user for, in this example, lets say a username and password, then store this (I assume in a text file). The area I am struggling with is how to allow the user to update this their password stored in the text file? I am writing this in Python.","Is this a single user application that you have? If you can provide more information one where you're struggling +You can read the password file (which has usernames and passwords) +- When user authenticate, match the username and password to the combination in text file +- When user wants to change password, then user provides old and new password. The username and old password combination is compared to the one in text file and if matches, stores the new",-0.2012947653214861,False,2,5102 2017-09-17 19:14:10.500,"Storing a username and password, then allowing user update. Python","I am trying to create a program that asks the user for, in this example, lets say a username and password, then store this (I assume in a text file). The area I am struggling with is how to allow the user to update this their password stored in the text file? I am writing this in Python.","Because you've asked to focus on how to handle the updates in a text file, I've focused on that part of your question. So, in effect I've focused on answering how would you go about having something that changes in a text file when those changes impact the length and structure of the text file. That question is independent of the thing in the text file being a password. There are significant concerns related to whether you should store a password, or whether you should store some quantity that can be used to verify a password. All that depends on what you're trying to do, what your security model is, and on what else your program needs to interact with. You've ruled all that out of scope for your question by asking us to focus on the text file update part of the problem. You might adopt the following pattern to accomplish this task: @@ -48184,10 +48188,6 @@ Ask for the username and password. If it is an update prompt with the old value Write out the text file. Most strategies for updating things stored in text files involve rewriting the text file entirely on every update.",0.0,False,2,5102 -2017-09-17 19:14:10.500,"Storing a username and password, then allowing user update. Python","I am trying to create a program that asks the user for, in this example, lets say a username and password, then store this (I assume in a text file). The area I am struggling with is how to allow the user to update this their password stored in the text file? I am writing this in Python.","Is this a single user application that you have? If you can provide more information one where you're struggling -You can read the password file (which has usernames and passwords) -- When user authenticate, match the username and password to the combination in text file -- When user wants to change password, then user provides old and new password. The username and old password combination is compared to the one in text file and if matches, stores the new",-0.2012947653214861,False,2,5102 2017-09-17 19:41:05.180,How can i execute my webbrowser in Python?,"I need to execute my webbrowser (opera) from python code, how can i get it? Python version 3.6, OS MS Windows 7",You can use Selenium to launch web browser through python.,0.0,False,1,5103 2017-09-18 23:43:24.997,Checking if time-delta value is in range past midnight,"So if I have two timedelta values such as 21:00:00(PM) as start time and 03:00:00 (AM) as end time and I wish to compare 23:00:00 within this range, to see whether it falls between these two, without having the date value, how could I do so? @@ -48220,10 +48220,10 @@ or Ctrl+B",0.580532356600752,False,1,5107 AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY as required settings. If I am using an AWS Instance Profile to provide S3 access instead of a key pair, how do I configure Django-Storages?","The docs now explain this: If AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are not set, boto3 internally looks up IAM credentials.",0.2012947653214861,False,1,5108 -2017-09-19 18:54:10.123,"Completely removing Tensorflow, pip and virtualenv","I am new to all the tensorflow and Python programming and have installed tensorflow through pip and virtualenv but now I read that in order to use Spyder for Python it is best to use Anaconda. I know that tf can be installed through conda as well but how do I go about it now? Do I have to completely remove the existing installations first and if yes, can someone explain in detail which and how I can do it?","Just install Anaconda it will take care of everything. Uninstalling the existing ones is up to you, they wont harm anything.",0.0,False,2,5109 2017-09-19 18:54:10.123,"Completely removing Tensorflow, pip and virtualenv","I am new to all the tensorflow and Python programming and have installed tensorflow through pip and virtualenv but now I read that in order to use Spyder for Python it is best to use Anaconda. I know that tf can be installed through conda as well but how do I go about it now? Do I have to completely remove the existing installations first and if yes, can someone explain in detail which and how I can do it?","Yes, after a short reading into the topic, I simply unistalled tf using sudo pip uninstall tensorflow within my virtualenv and then deactivated the virtualenv. Don't know how to really uninstall the virtualenv as well but I guess that is already enough then and I can proceed with the installation of Anaconda? I also have installed some additional packages like mathplotlib, ipython etc. but I can keep them as well without problems? Thanks",0.0,False,2,5109 +2017-09-19 18:54:10.123,"Completely removing Tensorflow, pip and virtualenv","I am new to all the tensorflow and Python programming and have installed tensorflow through pip and virtualenv but now I read that in order to use Spyder for Python it is best to use Anaconda. I know that tf can be installed through conda as well but how do I go about it now? Do I have to completely remove the existing installations first and if yes, can someone explain in detail which and how I can do it?","Just install Anaconda it will take care of everything. Uninstalling the existing ones is up to you, they wont harm anything.",0.0,False,2,5109 2017-09-20 05:47:20.153,Python: Apple Email Content,"I am developing a program in python that can read emails, my program can now read emails from GMAIL even with attachment but my program can't read the email that was sent from Apple Mail. Unlike the email that I sent from GMAIL when I use Message.get_payload() in apple mail it does not have a value. I'm a newbie on python and this is my first project so please bear with me. Thank you in advance. Note: The email I sent from Apple has attachment on it. @@ -48285,9 +48285,9 @@ By default, Gevent uses libevent to its plumbling. But how do libevent chooses t Is it random? I already had read their docs and had a sight on the sourcecode. Still do not know. Updated: Text changed to recognize that Gevent uses libevent. The question still applies over libevent.","It's underlying dispatch model, is the event loop in libevent, which uses the event base, which monitors for the different events, and reacts to them accordiningly, then from what I gleamed , it will take the greenlets do some fuckery with semaphores, and then dispatch it onto libevent.",0.0,False,1,5119 -2017-09-23 21:55:03.870,How can I create a workspace in Visual Studio Code?,"I have this very beginner question that I happened to install Visual Studio Code on my Mac, and every time I tried to run a simple Python program on that, it said that I need a workspace to run, so how do I create the workspace?","VSCode workspaces are basically just folders. If you open an empty folder in VSCode it will get treated as a workspace, and you can add any scripts you want to it. VSCode will create a new hidden folder in the folder you chose that will hold settings for the workspace. For python, make sure you install the python extension (just grab the one with the most downloads) and follow the instructions there to make sure your python environment is properly configured. If you're using git, you might want to add that hidden folder to the gitignore.",0.0,False,2,5120 2017-09-23 21:55:03.870,How can I create a workspace in Visual Studio Code?,"I have this very beginner question that I happened to install Visual Studio Code on my Mac, and every time I tried to run a simple Python program on that, it said that I need a workspace to run, so how do I create the workspace?","I am not sure how you try to run this program, but you can just go to menu View → Terminal and type python your_program.py in TERMINAL from the folder where your program is located. And please check if you have not accidentally installed Visual Studio instead of Visual Studio Code (those are two completely different programs).",0.3869120172231254,False,2,5120 +2017-09-23 21:55:03.870,How can I create a workspace in Visual Studio Code?,"I have this very beginner question that I happened to install Visual Studio Code on my Mac, and every time I tried to run a simple Python program on that, it said that I need a workspace to run, so how do I create the workspace?","VSCode workspaces are basically just folders. If you open an empty folder in VSCode it will get treated as a workspace, and you can add any scripts you want to it. VSCode will create a new hidden folder in the folder you chose that will hold settings for the workspace. For python, make sure you install the python extension (just grab the one with the most downloads) and follow the instructions there to make sure your python environment is properly configured. If you're using git, you might want to add that hidden folder to the gitignore.",0.0,False,2,5120 2017-09-24 17:04:20.560,Generating Random Numbers Under some constraints,"I happen to have a list y = [y1, y2, ... yn]. I need to generate random numbers ai such that 0<=ai<=c (for some constant c) and sum of all ai*yi = 0. Can anyone help me out on how to code this in python? Even pseudocode/logic works, I am having a conceptual problem here. While the first constraint is easy to satisfy, I cannot get anything for the second constraint. EDIT: Take all yi = +1 or -1, if that helps, but a general solution to this would be interesting.","If you need random integer values between 0 and c use random.randint(0, c). For random floating point values between 0 anc c use random.uniform(0, c).",0.0,False,2,5121 2017-09-24 17:04:20.560,Generating Random Numbers Under some constraints,"I happen to have a list y = [y1, y2, ... yn]. I need to generate random numbers ai such that 0<=ai<=c (for some constant c) and sum of all ai*yi = 0. Can anyone help me out on how to code this in python? Even pseudocode/logic works, I am having a conceptual problem here. While the first constraint is easy to satisfy, I cannot get anything for the second constraint. @@ -48300,11 +48300,11 @@ Also note that multiplying all ai by the same amount k will also satisfy the con Did I miss anything?",0.0,False,2,5121 2017-09-24 21:16:47.430,Is it possible to analyze mp3 file using music21?,"I am looking for python library to find out a key and tempo of the song recorded in MP3 format. I've found the music21 lib that allows doing that. But it seems like it works only with midi files. +Does somebody know how to parse MP3 files using music21 and get the required sound characteristics? If it is impossible, please suggest another library.",There are ways of doing this in music21 (audioSearch module) but it's more of a proof of concept and not for production work. There are much better software packages for analyzing audio (try sonic visualizer or jMIR or a commercial package). Music21's strength is in working with scores.,0.3869120172231254,False,3,5122 +2017-09-24 21:16:47.430,Is it possible to analyze mp3 file using music21?,"I am looking for python library to find out a key and tempo of the song recorded in MP3 format. I've found the music21 lib that allows doing that. But it seems like it works only with midi files. Does somebody know how to parse MP3 files using music21 and get the required sound characteristics? If it is impossible, please suggest another library.","No, this is not possible. Music21 can only process data stored in musical notation data formats, like MIDI, MusicXML, and ABC. Converting a MP3 audio file to notation is a complex task, and isn't something that software can reliably accomplish at this point.",1.2,True,3,5122 2017-09-24 21:16:47.430,Is it possible to analyze mp3 file using music21?,"I am looking for python library to find out a key and tempo of the song recorded in MP3 format. I've found the music21 lib that allows doing that. But it seems like it works only with midi files. -Does somebody know how to parse MP3 files using music21 and get the required sound characteristics? If it is impossible, please suggest another library.",There are ways of doing this in music21 (audioSearch module) but it's more of a proof of concept and not for production work. There are much better software packages for analyzing audio (try sonic visualizer or jMIR or a commercial package). Music21's strength is in working with scores.,0.3869120172231254,False,3,5122 -2017-09-24 21:16:47.430,Is it possible to analyze mp3 file using music21?,"I am looking for python library to find out a key and tempo of the song recorded in MP3 format. I've found the music21 lib that allows doing that. But it seems like it works only with midi files. Does somebody know how to parse MP3 files using music21 and get the required sound characteristics? If it is impossible, please suggest another library.",Check out librosa. It can read mp3s and give some basic info such as tempo.,0.1352210990936997,False,3,5122 2017-09-25 03:36:23.177,remove the profile but the camera always be disabled,"I have a strange problem at my iphone, when I remove the mdm profile, @@ -48371,7 +48371,14 @@ Once the program stops, it can all be erased from memory. From what I've researched so far it seems my best options are to either create a user class, where I store a list and add to the list each time. Or to create a dictionary with a key for each user. But since each user may have a different amount of winning scores, I don't know if I can use dictionaries with that (unless each key is associated with a list maybe?). I don't think I need something like a numpy array, since I want to create very simple statistics without worrying about what score belongs to what user. I need to think about not using an unnecessary amount of memory etc., especially because there may be a hundred winning scores for each user. But I can't really find clear information on what the benefits of dictionaries vs classes are. The programming community is amazingly helpful and full of answers, but unfortunately I often don't understand the answers. -Greatful for any help I can get! And don't be afraid to tell me my ideas are dumb, I want to learn how to think like a programmer.",class is used when there is both state and behavior . dict is used when there's only state. since you have both use class.,0.0,False,2,5133 +Greatful for any help I can get! And don't be afraid to tell me my ideas are dumb, I want to learn how to think like a programmer.","You can use Dictionary as values in dicts can be mutable like a list where you can keep all the scores/winning scores for each user. +{'player1' : [22,33,44,55], +'player2' : [23,34,45], +..... +} + +If this is not an exercise that you will repeat dicts make sense but if it is an exercise that might need to be done again in future Classes are better alternative as explained in other answers by Stuart and Hallsville3. +Hope it helps!",0.0679224682270276,False,2,5133 2017-10-06 05:44:44.957,Beginners python. Best way to store different amount of items for each key?,"I'm a beginner at programming (and also an older person), so I don't really know how to express what I want correctly. I've tried to describe my question as thoroughly as possible, so really appreciate your patience! I would like to store the winning scores associated with each user. @@ -48384,14 +48391,7 @@ Once the program stops, it can all be erased from memory. From what I've researched so far it seems my best options are to either create a user class, where I store a list and add to the list each time. Or to create a dictionary with a key for each user. But since each user may have a different amount of winning scores, I don't know if I can use dictionaries with that (unless each key is associated with a list maybe?). I don't think I need something like a numpy array, since I want to create very simple statistics without worrying about what score belongs to what user. I need to think about not using an unnecessary amount of memory etc., especially because there may be a hundred winning scores for each user. But I can't really find clear information on what the benefits of dictionaries vs classes are. The programming community is amazingly helpful and full of answers, but unfortunately I often don't understand the answers. -Greatful for any help I can get! And don't be afraid to tell me my ideas are dumb, I want to learn how to think like a programmer.","You can use Dictionary as values in dicts can be mutable like a list where you can keep all the scores/winning scores for each user. -{'player1' : [22,33,44,55], -'player2' : [23,34,45], -..... -} - -If this is not an exercise that you will repeat dicts make sense but if it is an exercise that might need to be done again in future Classes are better alternative as explained in other answers by Stuart and Hallsville3. -Hope it helps!",0.0679224682270276,False,2,5133 +Greatful for any help I can get! And don't be afraid to tell me my ideas are dumb, I want to learn how to think like a programmer.",class is used when there is both state and behavior . dict is used when there's only state. since you have both use class.,0.0,False,2,5133 2017-10-06 07:17:10.657,Error installing Spyder in anaconda,"Tried anaconda today , it seems fine but when I tried to launch Spyder each time I get this error: Traceback (most recent call last): File ""C:\ProgramData\Anaconda3\Scripts\spyder-script.py"", line 6, in from spyder.app.start import main @@ -48525,11 +48525,11 @@ The modifications are likely to be the addition of ""Querystring"" and ""JSON"" You would then parse the data as a HTTP req/res stream, ensuring that you can read the contents of the frame correctly. You would then be looking to either modify the contents of the POST body or the GET querystring. Either, depending on how the game designers designed their network system.",0.0,False,1,5150 2017-10-17 04:53:58.117,Why is a tuple containing an unhashable type unhashable?,"For example, the tuple (1,[0,1,2]). I understand why from a design perspective; if the tuple were still hashable, then it would be trivial to make any unhashable type hashable by wrapping it in a tuple, which breaks the correct behavior of hashability, since you can change the value of the object without changing the hash value of the tuple. But if the tuple is not hashable, then I don't understand what makes an object hashable -- I thought it simply had to have __hash__(self) implemented, which tuple does. -Based on other answers I've looked at, and from testing examples, it seems that such an object is not hashable. It seems like sensible behavior would be for tuple.__hash__() to call __hash__ for its component objects, but I don't understand how that would work from an implementation perspective, e.g. I don't know how a dictionary recognizes it as an unhashable type when it is still type tuple and tuple still defines __hash__.","I assume that tuple.__hash__() calls hash(item) for each item in the tuple and then XOR's the results together. If one of the items isn't hashable, then that will raise a TypeError that bubbles up to the original caller.",0.3869120172231254,False,2,5151 -2017-10-17 04:53:58.117,Why is a tuple containing an unhashable type unhashable?,"For example, the tuple (1,[0,1,2]). I understand why from a design perspective; if the tuple were still hashable, then it would be trivial to make any unhashable type hashable by wrapping it in a tuple, which breaks the correct behavior of hashability, since you can change the value of the object without changing the hash value of the tuple. But if the tuple is not hashable, then I don't understand what makes an object hashable -- I thought it simply had to have __hash__(self) implemented, which tuple does. Based on other answers I've looked at, and from testing examples, it seems that such an object is not hashable. It seems like sensible behavior would be for tuple.__hash__() to call __hash__ for its component objects, but I don't understand how that would work from an implementation perspective, e.g. I don't know how a dictionary recognizes it as an unhashable type when it is still type tuple and tuple still defines __hash__.","tuple implements its own hash by computing and combining the hashes of the values it contains. When hashing one of those values fails, it lets the resulting exception propagate unimpeded. Being unhashable just means calling hash() on you triggers a TypeError; one way to do that is to not define a __hash__ method, but it works equally well if, in the course of your __hash__ method you raise a TypeError (or any other error really) by some other means. Basically, tuple is a hashable type (isinstance((), collections.abc.Hashable) is true, as is isinstance(([],), collections.abc.Hashable) because it's a type level check for the existence of __hash__), but if it stores unhashable types, any attempt to compute the hash will raise an exception at time of use, so it behaves like an unhashable type in that scenario.",1.2,True,2,5151 +2017-10-17 04:53:58.117,Why is a tuple containing an unhashable type unhashable?,"For example, the tuple (1,[0,1,2]). I understand why from a design perspective; if the tuple were still hashable, then it would be trivial to make any unhashable type hashable by wrapping it in a tuple, which breaks the correct behavior of hashability, since you can change the value of the object without changing the hash value of the tuple. But if the tuple is not hashable, then I don't understand what makes an object hashable -- I thought it simply had to have __hash__(self) implemented, which tuple does. +Based on other answers I've looked at, and from testing examples, it seems that such an object is not hashable. It seems like sensible behavior would be for tuple.__hash__() to call __hash__ for its component objects, but I don't understand how that would work from an implementation perspective, e.g. I don't know how a dictionary recognizes it as an unhashable type when it is still type tuple and tuple still defines __hash__.","I assume that tuple.__hash__() calls hash(item) for each item in the tuple and then XOR's the results together. If one of the items isn't hashable, then that will raise a TypeError that bubbles up to the original caller.",0.3869120172231254,False,2,5151 2017-10-17 06:23:14.977,How do I make an app available online? [Python],"I wrote a really simple app in Python for a school project. It is for a skillsharing community that our club is trying to start up. Imagine Venmo, but without any money involved. It's essentially a record of favors done for those in the community. The users' info is stored as a dictionary within a dictionary of all users. The dictionary is pickled and the .pkl is updated automatically whenever user info is changed. I want the users to be able to access the information online, by logging in via username and password. It will be used regularly by people and security isn't really a concern since it doesn't store personal info and the users are a small group that are in our club. Anyhow, my issue is that I only know how to do backend stuff and basic tkinter GUIs (which, AFAIK can't be used for my needs). I'm a self-taught and uncommitted novice programmer, so I don't even know how to search for what I'm trying to do. I imagine what I need to do is put the program and the .pkl on the server that will host my website. (I have a domain name, but never figured out how to actually make it a website...) From there, I imagine I have to write some code that will create a login screen and allow users to login and view the attributes associated with their profile as well as send ""payment"" (as favors) to other users. @@ -48725,14 +48725,14 @@ A request to the Telegram API was unsuccessful. The server returned 2017-10-25 20:00:43.330,Overriding Django admin vs creating new templates/views,"I am a total noob with Django, I come from the PHP world and I am used to doing things differently. I'm building an app and I want to change the way the backend looks, I want to use Bootstrap 4 and add a lot of custom stuff e.g. permission based admin views, and I was wondering what is the best practice, or how do more experienced django devs go about it? Do they override all the django.contrib.admin templates, or do they build custom templates and login/register next to it, and use the django.contrib.admin only for the superuser? -What is the django way?","Yes. The admin pages is actually for administering the webpage. For user login and registration you create the templates. However, if you want your backend to look different then you can tweak the template for the admin page, admin login page as well. And you can also have permission based admin views. It's okay to over ride the defaults as long as you know what you're doing. Hope that helped.",0.0,False,2,5169 -2017-10-25 20:00:43.330,Overriding Django admin vs creating new templates/views,"I am a total noob with Django, I come from the PHP world and I am used to doing things differently. -I'm building an app and I want to change the way the backend looks, I want to use Bootstrap 4 and add a lot of custom stuff e.g. permission based admin views, and I was wondering what is the best practice, or how do more experienced django devs go about it? -Do they override all the django.contrib.admin templates, or do they build custom templates and login/register next to it, and use the django.contrib.admin only for the superuser? What is the django way?","Django admin is intended for administration purposes. For all intents and purposes it is a direct interface to your database. While I have seen some people building customer facing interfaces using admin, this is most definitely not the way to make a general Django web application. You should define views for your models. You can use built-in APIs to login and authenticate users. You should most likely restrict access to admin to internal users only. As for templates, the modern way of doing things is to dynamically fetch data using an API and do all the UI logic in Javascript. Django can be used very well to provide an API to a frontend. Look into Django REST Framework. The basic idea is to write serializers for your models and have view functions serve the serialized data to the front end. You could go the old school way and render your pages using templates of course. In that case your views would render templates using data provided by your models.",1.2,True,2,5169 +2017-10-25 20:00:43.330,Overriding Django admin vs creating new templates/views,"I am a total noob with Django, I come from the PHP world and I am used to doing things differently. +I'm building an app and I want to change the way the backend looks, I want to use Bootstrap 4 and add a lot of custom stuff e.g. permission based admin views, and I was wondering what is the best practice, or how do more experienced django devs go about it? +Do they override all the django.contrib.admin templates, or do they build custom templates and login/register next to it, and use the django.contrib.admin only for the superuser? +What is the django way?","Yes. The admin pages is actually for administering the webpage. For user login and registration you create the templates. However, if you want your backend to look different then you can tweak the template for the admin page, admin login page as well. And you can also have permission based admin views. It's okay to over ride the defaults as long as you know what you're doing. Hope that helped.",0.0,False,2,5169 2017-10-29 08:29:36.633,Logistic Regression- Working with categorical variable in Python?,"I have a dataset that includes 7 different covariates and an output variable, the 'success rate'. I'm trying to find the important factors that predict the success rate. One of the covariates in my dataset is a categorical variable that takes on 700 values (0- 700), each representing the ID of the district they're from. How should I deal with this variable while performing logistic regression? @@ -48777,13 +48777,13 @@ My current tactic is to load the datafiles in a numpy array, perform the calcula I don't what to store in settings.py as i will checking this file in my git. Can i do it the same way amazon store AWS ec2 keys. If possible how to do it.",You can set secrets in environment variables and get them in python code as password = os.getenv('ENVNAME').,1.2,True,1,5178 2017-10-31 20:54:29.743,Basic-Auth session using python script,"I am creating python script to configure router settings remotely but recently stumbled on problem how to logout or close session after job is done? -From searching I found that Basic-Authentication doesn´t have option to logout. How to solve it in python script?","Basic auth doesn't have a concept of a logout but your router's page should have some implementation. If not, perhaps it has a timeout and you just leave it. -Since you're using the requests module it may be difficult to do an actual logout if there is no endpoint or parameter for it. I think the best one can do at that point is log in again but with invalid credentials. Studying the structure of the router's pages and the parameters that appear in the urls could give you more options. -If you want to go a different route and use something like a headless web browser you could actually click a logout button if it exists. Something like Selenium can do this.",1.2,True,2,5179 -2017-10-31 20:54:29.743,Basic-Auth session using python script,"I am creating python script to configure router settings remotely but recently stumbled on problem how to logout or close session after job is done? From searching I found that Basic-Authentication doesn´t have option to logout. How to solve it in python script?","with python requests you can open your session, do your job, then logout with: r = requests.get('logouturl', params={...}) the logout action is just an http Get method.",0.0,False,2,5179 +2017-10-31 20:54:29.743,Basic-Auth session using python script,"I am creating python script to configure router settings remotely but recently stumbled on problem how to logout or close session after job is done? +From searching I found that Basic-Authentication doesn´t have option to logout. How to solve it in python script?","Basic auth doesn't have a concept of a logout but your router's page should have some implementation. If not, perhaps it has a timeout and you just leave it. +Since you're using the requests module it may be difficult to do an actual logout if there is no endpoint or parameter for it. I think the best one can do at that point is log in again but with invalid credentials. Studying the structure of the router's pages and the parameters that appear in the urls could give you more options. +If you want to go a different route and use something like a headless web browser you could actually click a logout button if it exists. Something like Selenium can do this.",1.2,True,2,5179 2017-11-01 04:30:58.390,"jupyterlab - change styling - font, font size","I recently updated to the most recent version of JupyterLab (0.28.12). I'm on Windows. I've tried adjusting the variables.css file located in \Lib\site-packages\jupyterlab\themes\@jupyterlab\theme-light-extension of my Miniconda/Anaconda folder. I mainly want to change the font family and size, which I've tried using the variables.css file. However, I can't see any changes. I went to the extreme point of deleting both theme folders, but still I can change themes without a problem through the Lab interface. @@ -48825,15 +48825,15 @@ Implementing this approach should be considerably simpler than triggering events 2017-11-02 18:58:32.550,Managing multiple Python versions on OSX,"What's the best way to manage multiple Python installations (long-term) if I've already installed Python 3 via brew? In the past Python versions were installed here, there, and everywhere, because I used different tools to install various updates. As you can imagine, this eventually became a problem. I once was in a situation where a package used in one of my projects only worked with Python 3.4, but I had recently updated to 3.6. My code no longer ran, and I had to scour the system for Python 3.4 to actually fire up the project. It was a huge PITA. I recently wiped my computer and would like to avoid some of my past mistakes. Perhaps this is naïve, but I'd like to limit version installation to brew. (Unless that's non-sensical — I'm open to other suggestions!) Furthermore, I'd like to know how to resolve my past version management woes (i.e. situations like the one above). I've heard of pyenv, but would that conflict with brew? +Thanks!","I agree to using virtualenv, it allows you to manage different python versions separately for different projects and clients. +This basically allows you to have each project it's own dependencies which are isolated from others.",0.0,False,2,5184 +2017-11-02 18:58:32.550,Managing multiple Python versions on OSX,"What's the best way to manage multiple Python installations (long-term) if I've already installed Python 3 via brew? In the past Python versions were installed here, there, and everywhere, because I used different tools to install various updates. As you can imagine, this eventually became a problem. +I once was in a situation where a package used in one of my projects only worked with Python 3.4, but I had recently updated to 3.6. My code no longer ran, and I had to scour the system for Python 3.4 to actually fire up the project. It was a huge PITA. +I recently wiped my computer and would like to avoid some of my past mistakes. Perhaps this is naïve, but I'd like to limit version installation to brew. (Unless that's non-sensical — I'm open to other suggestions!) Furthermore, I'd like to know how to resolve my past version management woes (i.e. situations like the one above). I've heard of pyenv, but would that conflict with brew? Thanks!","Use virtualenvs to reduce package clash between independent projects. After activating the venv use pip to install packages. This way each project has an independent view of the package space. I use brew to install both Python 2.7 and 3.6. The venv utility from each of these will build a 2 or 3 venv respectively. I also have pyenv installed from brew which I use if I want a specific version that is not the latest in brew. After activating a specific version in a directory, I will then create a venv and use this to manage the package isolation. I can't really say what is best. Let's see what other folks say.",1.2,True,2,5184 -2017-11-02 18:58:32.550,Managing multiple Python versions on OSX,"What's the best way to manage multiple Python installations (long-term) if I've already installed Python 3 via brew? In the past Python versions were installed here, there, and everywhere, because I used different tools to install various updates. As you can imagine, this eventually became a problem. -I once was in a situation where a package used in one of my projects only worked with Python 3.4, but I had recently updated to 3.6. My code no longer ran, and I had to scour the system for Python 3.4 to actually fire up the project. It was a huge PITA. -I recently wiped my computer and would like to avoid some of my past mistakes. Perhaps this is naïve, but I'd like to limit version installation to brew. (Unless that's non-sensical — I'm open to other suggestions!) Furthermore, I'd like to know how to resolve my past version management woes (i.e. situations like the one above). I've heard of pyenv, but would that conflict with brew? -Thanks!","I agree to using virtualenv, it allows you to manage different python versions separately for different projects and clients. -This basically allows you to have each project it's own dependencies which are isolated from others.",0.0,False,2,5184 2017-11-03 12:44:11.697,How to protect my Python code before distribution?,"I have written a python code which takes an input data file, performs some processing on the data and writes another data file as output. I should distribute my code now but the users should not see the source code but be able to just giving the input and getting the output! I have never done this before. @@ -48929,8 +48929,8 @@ I think the problem may be related with system path because python cannot find t ['', '/home/jeoker/anaconda3/lib/python36.zip', '/home/jeoker/anaconda3/lib/python3.6', '/home/jeoker/anaconda3/lib/python3.6/lib-dynload', '/home/jeoker/anaconda3/lib/python3.6/site-packages'] But when I do conda list, the result always show the files in /home/jeoker/anaconda2. I tried sudo pip3 install tensorflow, but it gived me this: Requiement already satisfied. It seems that the path where the libraries are installed is not the same as where python is looking into. Does anyone know how can I fix this problem? thanks in advance!!","Well, since no one is answering this question, I have to close the question. What I did to overcome the issue was just to uninstall the whole WSL and reinstall it.",1.2,True,1,5198 -2017-11-13 17:42:13.033,How can you write/delete/read a file in a different user account with the same ip address with python?,"Recently, I learnt how to write/delete/read a file in Python (I am a beginner). However, something has got me thinking: is it possible to write/delete/read a file in a different user account from the same network (i.e same ip address)? If so, how? Don't worry, I'll just try it at home. ;)","If you can remove the file without Python, then you can remove it with Python. Otherwise, the answer is ""no"".",0.0,False,2,5199 2017-11-13 17:42:13.033,How can you write/delete/read a file in a different user account with the same ip address with python?,"Recently, I learnt how to write/delete/read a file in Python (I am a beginner). However, something has got me thinking: is it possible to write/delete/read a file in a different user account from the same network (i.e same ip address)? If so, how? Don't worry, I'll just try it at home. ;)",This is running into more of an OS question. The answer is if you have permission to do so then yes you can but if you do not have permissions over the file then you cannot.,0.0,False,2,5199 +2017-11-13 17:42:13.033,How can you write/delete/read a file in a different user account with the same ip address with python?,"Recently, I learnt how to write/delete/read a file in Python (I am a beginner). However, something has got me thinking: is it possible to write/delete/read a file in a different user account from the same network (i.e same ip address)? If so, how? Don't worry, I'll just try it at home. ;)","If you can remove the file without Python, then you can remove it with Python. Otherwise, the answer is ""no"".",0.0,False,2,5199 2017-11-14 03:49:07.433,cv2 running optical flow on particular rectangles,"I am using OpenCV's Optical Flow module. I understand the examples in the documentation but those take the entire image and then get the optical flow over the image. I only want to pass it over some parts of an image. Is it possible to do that? If yes, how do I go about it? Thanks!","Yes, it's possible. cv2.calcOpticalFlowPyrLK() will be the optical flow function you need. Before you make that function call, you will have to create an image mask. I did a similar project, but in C++, though I can outline the steps for you: @@ -48995,6 +48995,19 @@ package is not showing them. I can see only SGD and SGDMomentun learners in C# there. Any thoughts, how to get and set other learners in C#. Do I need to install any additional package to get these learners? +Appreciate your help.",Download the NCCL 2 app to configure in c# www.nvidia. com or google NCCL download,0.0,False,2,5205 +2017-11-16 08:07:59.413,Learners in CNTK C# API,"I am using C# CNTK 2.2.0 API for training. +I have installed Nuget package CNTK.CPUOnly and CNTK.GPU. +I am looking for following learners in C#. +1. AdaDelta +2. Adam +3. AdaGrad +4. Neterov +Looks like Python supports these learners but C# +package is not showing them. +I can see only SGD and SGDMomentun learners in C# there. +Any thoughts, how to get and set other learners in C#. +Do I need to install any additional package to get these learners? Appreciate your help.","Checked that CNTKLib is providing those learners in CPUOnly package. Nestrov is missing in there but present in python. There is a difference while creating the trainer object @@ -49010,19 +49023,6 @@ ParameterVector pv = new ParameterVector () pv.Add(weightParameter) pv.Add(biasParameter) Thanks everyone for your answers.",0.0,False,2,5205 -2017-11-16 08:07:59.413,Learners in CNTK C# API,"I am using C# CNTK 2.2.0 API for training. -I have installed Nuget package CNTK.CPUOnly and CNTK.GPU. -I am looking for following learners in C#. -1. AdaDelta -2. Adam -3. AdaGrad -4. Neterov -Looks like Python supports these learners but C# -package is not showing them. -I can see only SGD and SGDMomentun learners in C# there. -Any thoughts, how to get and set other learners in C#. -Do I need to install any additional package to get these learners? -Appreciate your help.",Download the NCCL 2 app to configure in c# www.nvidia. com or google NCCL download,0.0,False,2,5205 2017-11-16 16:08:52.893,Error reported while running pyomo optimization with cbc solver and using timelimit,"I am trying to solve Optimisation problem with pyomo (Pyomo 5.3 (CPython 2.7.13 on Linux 3.10.0-514.26.2.el7.x86_64)) using CBC solver (Version: 2.9.8) and specifying a time limit in solver of 60 sec. The solver is getting a feasible solution (-1415.8392) but apparently not yet optimal (-1415.84) as you can see below. After time limit ends model seemingly exits with an error code. I want to print or get values of all variables of feasible solution using CBC in specified time limit. Or is there any other way by which I can set, if Model gets 99% value of an Optimal solution, to exit and print the feasible solution. The error code is posted below. @@ -49185,11 +49185,11 @@ EDIT: I tried widget.winfo_height() and widget.geometry(), but all these functions return height defined in number of characters. I think it would be possible to create the same widget in a frame and then write frame.winfo_height() which would return size in pixels, but this is not so elegant solution.","Ok, I figured it out. We must call widget.update() first before calling widget.winfo_height().",0.9997532108480276,False,1,5224 2017-11-27 11:34:52.067,How to handle android runtime permission with kivy,"I found that kivy is very nice framework to build cross platform application and I am very interested in kivy just to do android application as I think is easy and comfortable in kivy. After trying few examples, I am interested to know how should handle android run time permission for the kivy app. -Actually I had searched on google, but no single working example out there. Should I go back to android / java or it possible with kivy and some other python libs.","python-for-android doesn't have any code for handling runtime permissions. I expect to look at it sooner rather than later, but there's no ETA for it. -You can probably add the code for it yourself if you're interested and know how. If you'd like to try it, such contributions would be very welcome.",0.1016881243684853,False,2,5225 +Actually I had searched on google, but no single working example out there. Should I go back to android / java or it possible with kivy and some other python libs.","i know this answer is a little late, but to get permissions you have to specify them before the build. E.g buildozer uses a buildozer.spec. In this file you can specify the permissions you need.",0.1016881243684853,False,2,5225 2017-11-27 11:34:52.067,How to handle android runtime permission with kivy,"I found that kivy is very nice framework to build cross platform application and I am very interested in kivy just to do android application as I think is easy and comfortable in kivy. After trying few examples, I am interested to know how should handle android run time permission for the kivy app. -Actually I had searched on google, but no single working example out there. Should I go back to android / java or it possible with kivy and some other python libs.","i know this answer is a little late, but to get permissions you have to specify them before the build. E.g buildozer uses a buildozer.spec. In this file you can specify the permissions you need.",0.1016881243684853,False,2,5225 +Actually I had searched on google, but no single working example out there. Should I go back to android / java or it possible with kivy and some other python libs.","python-for-android doesn't have any code for handling runtime permissions. I expect to look at it sooner rather than later, but there's no ETA for it. +You can probably add the code for it yourself if you're interested and know how. If you'd like to try it, such contributions would be very welcome.",0.1016881243684853,False,2,5225 2017-11-27 13:53:55.847,Pycharm shows interpretor version of 2.7 but I have downloaded 3.6?,"I'm a complete newbie trying to use pycharm with python but my interpretor shows a version of 2.7 when i have installed 3.6. Totally confused and need help! On pycharm I do the following steps: Preferences > Python Console > Python Interpretor @@ -49291,6 +49291,7 @@ For now i can only get the organizer's name by typing ""item.subject"" where ""i Conversely, is it possible to get the account's name (the complete name: ""Michael JORDAN"" for example) which I could compare with the meeting organizer's name. Thank you !",The meeting organizer is available on CalendarItem objects as item.organizer.,1.2,True,1,5238 2017-12-06 00:45:48.063,How to disable stopOnEntry for files that are opened without a workspace?,"When I open a python file without a workspace and start debugging it, the debugger breaks on the first line. I would like to change this behaviour, but I don't know how to do it for files that are opened without a workspace.","Open launch.json (gear icon when on debugger tab). Find the section for the python debugger you are using. Change ""stopOnEntry"" from true to false. Save.",0.0,False,1,5239 +2017-12-06 09:37:29.177,How to convert Python project into executable,"I have a Python project that I want to convert into an executable. I have installed Pyinstaller. I only know how to convert one single script into .exe, but I have multiple packages with multiple python scripts.","Converting the main script into .exe should solve the problem, use -onefile to convert it to one exe and rest of the .py files should be included.",-0.1352210990936997,False,2,5240 2017-12-06 09:37:29.177,How to convert Python project into executable,"I have a Python project that I want to convert into an executable. I have installed Pyinstaller. I only know how to convert one single script into .exe, but I have multiple packages with multiple python scripts.","1) Open the command prompt 2) Install pyinstaller Pip install pyinstaller @@ -49303,7 +49304,6 @@ Notice we have passed “–onefile” as a argument which tell pyinstaller to c 5) Go to directory and navigate to the dist folder. Prerequisite : Install PyQt5 to avoid error. pip install PyQt5",-0.1352210990936997,False,2,5240 -2017-12-06 09:37:29.177,How to convert Python project into executable,"I have a Python project that I want to convert into an executable. I have installed Pyinstaller. I only know how to convert one single script into .exe, but I have multiple packages with multiple python scripts.","Converting the main script into .exe should solve the problem, use -onefile to convert it to one exe and rest of the .py files should be included.",-0.1352210990936997,False,2,5240 2017-12-08 07:09:49.293,Getting a Linux terminal output of a CLI tool and displaying in Web page,"I am trying to create a web application using python which has a HTML form and the form data is used as a command line input to start an application. I know how to initiate the CLI tool from web app, but want a way to get the output of the CLI tool from Linux terminal real time and show it in the web application. The CLI tool will run for a day and the terminal output will change in real time. Is there a way to display the changing Linux terminal output in to the web application. Information about any web terminal or way to get and store the real-time screen output of a linux application will be helpful. When ever the screen O/P of the application running in linux changes then the web application should also be updated with the change. @@ -49446,6 +49446,11 @@ Thanks in advance!",Messagebird have a feature of forward incoming sms data thro 2017-12-20 22:01:51.590,How to access Anaconda command prompt in Windows 10 (64-bit),"I had to install the 64-bit version of Anaconda with python 3.5 in Windows 10. I followed the default settings (AppData/Continuum/Anaconda3). However, after installation, I am unsure how to access the Anaconda command prompt so that I can use conda to install packages. I also attempted to install Anaconda 64 bit in C:/Program Files, but several of the python script did not like the space and it failed to install. What can I do to access the Anaconda prompt?","Go with the mouse to the Windows Icon (lower left) and start typing ""Anaconda"". There should show up some matching entries. Select ""Anaconda Prompt"". A new command window, named ""Anaconda Prompt"" will open. Now, you can work from there with Python, conda and other tools.",0.9999995616229148,False,4,5258 2017-12-20 22:01:51.590,How to access Anaconda command prompt in Windows 10 (64-bit),"I had to install the 64-bit version of Anaconda with python 3.5 in Windows 10. I followed the default settings (AppData/Continuum/Anaconda3). However, after installation, I am unsure how to access the Anaconda command prompt so that I can use conda to install packages. I also attempted to install Anaconda 64 bit in C:/Program Files, but several of the python script did not like the space and it failed to install. +What can I do to access the Anaconda prompt?","If Anaconda Prompt is missing, you can create it by creating a shortcut file of Command Prompt (cmd.exe) and change its target to: +%windir%\System32\cmd.exe ""/K"" \anaconda3\Scripts\activate.bat +Example: +%windir%\system32\cmd.exe ""/K"" C:\Users\user_1\AppData\Local\Continuum\anaconda3\Scripts\activate.bat",0.2655860252697744,False,4,5258 +2017-12-20 22:01:51.590,How to access Anaconda command prompt in Windows 10 (64-bit),"I had to install the 64-bit version of Anaconda with python 3.5 in Windows 10. I followed the default settings (AppData/Continuum/Anaconda3). However, after installation, I am unsure how to access the Anaconda command prompt so that I can use conda to install packages. I also attempted to install Anaconda 64 bit in C:/Program Files, but several of the python script did not like the space and it failed to install. What can I do to access the Anaconda prompt?","I added ""\Anaconda3_64\"" and ""\Anaconda3_64\Scripts\"" to the PATH variable. Then I can use conda from powershell or command prompt.",0.5916962662253621,False,4,5258 2017-12-20 22:01:51.590,How to access Anaconda command prompt in Windows 10 (64-bit),"I had to install the 64-bit version of Anaconda with python 3.5 in Windows 10. I followed the default settings (AppData/Continuum/Anaconda3). However, after installation, I am unsure how to access the Anaconda command prompt so that I can use conda to install packages. I also attempted to install Anaconda 64 bit in C:/Program Files, but several of the python script did not like the space and it failed to install. What can I do to access the Anaconda prompt?","To run Anaconda Prompt using an icon, I made an icon and put: @@ -49455,11 +49460,6 @@ I see %HOMEPATH% at icon -> right click -> Property -> Start in Test environment    OS: Windows 10    Library: Anaconda 10 (64 bit)",0.9903904942256808,False,4,5258 -2017-12-20 22:01:51.590,How to access Anaconda command prompt in Windows 10 (64-bit),"I had to install the 64-bit version of Anaconda with python 3.5 in Windows 10. I followed the default settings (AppData/Continuum/Anaconda3). However, after installation, I am unsure how to access the Anaconda command prompt so that I can use conda to install packages. I also attempted to install Anaconda 64 bit in C:/Program Files, but several of the python script did not like the space and it failed to install. -What can I do to access the Anaconda prompt?","If Anaconda Prompt is missing, you can create it by creating a shortcut file of Command Prompt (cmd.exe) and change its target to: -%windir%\System32\cmd.exe ""/K"" \anaconda3\Scripts\activate.bat -Example: -%windir%\system32\cmd.exe ""/K"" C:\Users\user_1\AppData\Local\Continuum\anaconda3\Scripts\activate.bat",0.2655860252697744,False,4,5258 2017-12-21 13:06:03.023,The best way to read a lot of messages from RabbitMQ queue?,"I'm writing Python script cron-job, which is periodically get updates from RabbitMQ and process them. Every time I process them I need only to get current snapshot of RMQ queue. I use queue_declare to get number of messages in it. I know how to get messages one by one with basic_get. Also, I can use basic_consume/start_consuming and get messages in background, store them in some list and periodically get from that list, but what if script will fail with some error? I will lost all read messages in list. Also, I can use few consumers (pool of connections to RMQ) and get messages one by one. Maybe there is some other approach to do it? So, my question is - what is the best (i.e. secure and fast) way to get current messages from RabbiMQ queue?","The best way to consume the messages is using basic_consume. @@ -49472,25 +49472,12 @@ It then takes me back to the main window where it shows the path in the project Cannot Save Settings please use a different SDK name It doesn't matter which interpreter I choose, I get the same message. Has anyone else come up with the same problem and how do I fix this? -Interestingly my old projects still work correctly.","In my case, I moved my project to a different location and PyCharm started complaining about Cannot Save Settings please use a different SDK name. At the top of the main editor, it asks me to Configure Project Interpreter. I clicked it, and then ... -My solution - -Remove all existing interpreters that are marked as invalid in the preference. -Select the interpreter in the moved venv subfolder in my project. - -Without doing both, I kept getting the same ""SDK name"" error. It seemed that the project thinks that it already has an interpreter called ""python.exe"", if you don't actively remove all ""invalid"" ones.",0.0,False,6,5260 -2017-12-21 21:08:18.767,"Configuring interpreter in PyCharm: ""please use a different SDK name""","I have been using Pycharm for years and have never had any problem. However, after my most recent PyCharm update I can no longer configure the interpreter. -Also each time I create a new project it creates a vent directory under my project. When I go to File/Default Settings/Project Interpreter, I am provided with new options. -In this window it allows you to configure a virtual environment, the conda environment, and the system interpreter. I am assuming that I should configure the system interpreter. From there I point PyCharm to the interpreter on my Mac at /usr/local/Cellar/python3/3.6.3/bin/python3 and hit OK. -It then takes me back to the main window where it shows the path in the project interpreter. At this point I hit apply and get a message: +Interestingly my old projects still work correctly.","I had the same problem while setting up the virtual environment for my project and no matter if I create a new virtual environment or select an existing one, I get the warning: -Cannot Save Settings please use a different SDK name +""Cannot Save Settings please use a different SDK name"" -It doesn't matter which interpreter I choose, I get the same message. Has anyone else come up with the same problem and how do I fix this? -Interestingly my old projects still work correctly.","You cannot have 2 or more virtual environments with same name. Even if you have projects with same name stored at 2 different places, please give unique name to its venv. This will solve your problem. -To check all the virtual environments: -Go to File >> Settings >> Project: your_project_name >> Project Interpreter -And rename the venv name.",0.0407936753323291,False,6,5260 +Finally I found the solution: +Click on the project interpreter dropdown and select show all.... There you might be having multiple virtual environments with same name. Now here is the conflict you need to fix manually by renaming them so every item has the unique name.",0.9981778976111988,False,6,5260 2017-12-21 21:08:18.767,"Configuring interpreter in PyCharm: ""please use a different SDK name""","I have been using Pycharm for years and have never had any problem. However, after my most recent PyCharm update I can no longer configure the interpreter. Also each time I create a new project it creates a vent directory under my project. When I go to File/Default Settings/Project Interpreter, I am provided with new options. In this window it allows you to configure a virtual environment, the conda environment, and the system interpreter. I am assuming that I should configure the system interpreter. From there I point PyCharm to the interpreter on my Mac at /usr/local/Cellar/python3/3.6.3/bin/python3 and hit OK. @@ -49512,12 +49499,13 @@ It then takes me back to the main window where it shows the path in the project Cannot Save Settings please use a different SDK name It doesn't matter which interpreter I choose, I get the same message. Has anyone else come up with the same problem and how do I fix this? -Interestingly my old projects still work correctly.","I had the same problem while setting up the virtual environment for my project and no matter if I create a new virtual environment or select an existing one, I get the warning: +Interestingly my old projects still work correctly.","In my case, I moved my project to a different location and PyCharm started complaining about Cannot Save Settings please use a different SDK name. At the top of the main editor, it asks me to Configure Project Interpreter. I clicked it, and then ... +My solution -""Cannot Save Settings please use a different SDK name"" +Remove all existing interpreters that are marked as invalid in the preference. +Select the interpreter in the moved venv subfolder in my project. -Finally I found the solution: -Click on the project interpreter dropdown and select show all.... There you might be having multiple virtual environments with same name. Now here is the conflict you need to fix manually by renaming them so every item has the unique name.",0.9981778976111988,False,6,5260 +Without doing both, I kept getting the same ""SDK name"" error. It seemed that the project thinks that it already has an interpreter called ""python.exe"", if you don't actively remove all ""invalid"" ones.",0.0,False,6,5260 2017-12-21 21:08:18.767,"Configuring interpreter in PyCharm: ""please use a different SDK name""","I have been using Pycharm for years and have never had any problem. However, after my most recent PyCharm update I can no longer configure the interpreter. Also each time I create a new project it creates a vent directory under my project. When I go to File/Default Settings/Project Interpreter, I am provided with new options. In this window it allows you to configure a virtual environment, the conda environment, and the system interpreter. I am assuming that I should configure the system interpreter. From there I point PyCharm to the interpreter on my Mac at /usr/local/Cellar/python3/3.6.3/bin/python3 and hit OK. @@ -49543,6 +49531,18 @@ Cannot Save Settings please use a different SDK name It doesn't matter which interpreter I choose, I get the same message. Has anyone else come up with the same problem and how do I fix this? Interestingly my old projects still work correctly.","Go to Project > Project Interpreter > Select the dropdown menu > ""Show All"". For me, there were several Python environments, two of which were red with an tag. Remove the envs that are red / have an tag, select the remaining valid one, and re-apply settings.",0.0407936753323291,False,6,5260 +2017-12-21 21:08:18.767,"Configuring interpreter in PyCharm: ""please use a different SDK name""","I have been using Pycharm for years and have never had any problem. However, after my most recent PyCharm update I can no longer configure the interpreter. +Also each time I create a new project it creates a vent directory under my project. When I go to File/Default Settings/Project Interpreter, I am provided with new options. +In this window it allows you to configure a virtual environment, the conda environment, and the system interpreter. I am assuming that I should configure the system interpreter. From there I point PyCharm to the interpreter on my Mac at /usr/local/Cellar/python3/3.6.3/bin/python3 and hit OK. +It then takes me back to the main window where it shows the path in the project interpreter. At this point I hit apply and get a message: + +Cannot Save Settings please use a different SDK name + +It doesn't matter which interpreter I choose, I get the same message. Has anyone else come up with the same problem and how do I fix this? +Interestingly my old projects still work correctly.","You cannot have 2 or more virtual environments with same name. Even if you have projects with same name stored at 2 different places, please give unique name to its venv. This will solve your problem. +To check all the virtual environments: +Go to File >> Settings >> Project: your_project_name >> Project Interpreter +And rename the venv name.",0.0407936753323291,False,6,5260 2017-12-22 12:06:23.863,Able to fetch text with their locations from an image...How can I form sentence?,"I am using online library and able to fetch words from an image with their locations. Now I want to form sentences exactly like which are in image. Any idea how can I do that? @@ -49729,11 +49729,11 @@ the user enters the answer in the result field and submits the form in your view, determine whether num1 + num2 == result redirect to a success page if the answer is correct, otherwise redisplay the form",1.2,True,1,5281 2017-12-31 10:03:50.110,pyinstaller -- script not found.,"I'm trying to learn how to use pyinstaller to make an executable. I wrote a little script in 2.7 as a test. Print 'test"" and named it test-print. When I click on the executable in the Build folder a cmd screen flashes, and that all she wrote. I tried adding a x = raw_input('input something: ') hoping that would cause the cmd screen, or some kind of screen to persist, but to no avail. I know this is basic stuff, but a voice of experience would be most helpful. +F","In pyinstaller the actual executable is located in the dist folder. I assume you did not use pyinstallers ""--onefile"" switch so once you finish compiling, navigate to dist then test-print. Afterwards look for test-print.exe in that folder. That is your executable.",0.0,False,2,5282 +2017-12-31 10:03:50.110,pyinstaller -- script not found.,"I'm trying to learn how to use pyinstaller to make an executable. I wrote a little script in 2.7 as a test. Print 'test"" and named it test-print. When I click on the executable in the Build folder a cmd screen flashes, and that all she wrote. I tried adding a x = raw_input('input something: ') hoping that would cause the cmd screen, or some kind of screen to persist, but to no avail. I know this is basic stuff, but a voice of experience would be most helpful. F","First try running the command from a command line (terminal) so you can see what happens. Not from inside any IDE. If you created the script in a MSWindows environment, be sure your PATH includes the executable (or explicitly give the path to the script). In Linux/Unix, be sure to enable execute permission for the script. chmod +x scriptname",0.0,False,2,5282 -2017-12-31 10:03:50.110,pyinstaller -- script not found.,"I'm trying to learn how to use pyinstaller to make an executable. I wrote a little script in 2.7 as a test. Print 'test"" and named it test-print. When I click on the executable in the Build folder a cmd screen flashes, and that all she wrote. I tried adding a x = raw_input('input something: ') hoping that would cause the cmd screen, or some kind of screen to persist, but to no avail. I know this is basic stuff, but a voice of experience would be most helpful. -F","In pyinstaller the actual executable is located in the dist folder. I assume you did not use pyinstallers ""--onefile"" switch so once you finish compiling, navigate to dist then test-print. Afterwards look for test-print.exe in that folder. That is your executable.",0.0,False,2,5282 2017-12-31 11:13:44.060,Making a x86 .exe on a x64 machine,"and thank you for your answer in advance. I am making a python program to automate something for my friend, and converted it into a .exe file with cx_Freeze so I could give it to him. But I have a x64 machine and he has a x86 machine. Can anyone please tell me how to make a x86 .exe file on my PC. I'm using Win 10 x64 and Python 3.6","The .exe output actually depends on the installation you are using (I'm assuming x64) so if you used an x86bit or x32bit Python installation it will output the bit version your installation is (I know both will run on x64 computers) and just freeze in the normal way. Bear in mind that x32 works on x86, x64 as well so you might do best with that bit version.",0.0,False,1,5283 2017-12-31 14:20:36.053,"Using 32-bit and 64-bit Python - ""NameError: global name 'numpy' etc. is not defined""","I was having a memory error in Python with a program, I found out I had to upgrade my Python to 64 bit. I did that. I then copied all the files from the Lib/site-packages folder of the Python 32 bit and pasted it in the 64 bit folder. I did this so I wouldn't have to install the modules again for my program. @@ -49743,8 +49743,11 @@ NameError: name 'numpy' is not defined And yes, I had import numpy in the program I think the problem is that I have to actually pip install numpy inside of the 64 bit Python (even though I copied the exact same Lib/site-packages from 32 bit to 64 bit) using cmd. If that is the problem, how do I specifically pip install inside of the 64 bit Python folder rather than the default 32 bit folder? -Otherwise, any suggestions?","For windows Shift-Right-Click on your 64-bit installation folder that has python.exe and select Open command window here. Then type python.exe -m pip install numpy in there and press Enter. -What this does is that it calls 64-bit python's pip to install numpy instead.",0.0,False,3,5284 +Otherwise, any suggestions?","In Windows I use always this: + +Rename the pip.exe to pip64.exe for example +Add python folder to Sys path if not exists. +You can use ""pip64 install package_name""",0.0,False,3,5284 2017-12-31 14:20:36.053,"Using 32-bit and 64-bit Python - ""NameError: global name 'numpy' etc. is not defined""","I was having a memory error in Python with a program, I found out I had to upgrade my Python to 64 bit. I did that. I then copied all the files from the Lib/site-packages folder of the Python 32 bit and pasted it in the 64 bit folder. I did this so I wouldn't have to install the modules again for my program. I ran the program and got the following error: @@ -49765,11 +49768,8 @@ NameError: name 'numpy' is not defined And yes, I had import numpy in the program I think the problem is that I have to actually pip install numpy inside of the 64 bit Python (even though I copied the exact same Lib/site-packages from 32 bit to 64 bit) using cmd. If that is the problem, how do I specifically pip install inside of the 64 bit Python folder rather than the default 32 bit folder? -Otherwise, any suggestions?","In Windows I use always this: - -Rename the pip.exe to pip64.exe for example -Add python folder to Sys path if not exists. -You can use ""pip64 install package_name""",0.0,False,3,5284 +Otherwise, any suggestions?","For windows Shift-Right-Click on your 64-bit installation folder that has python.exe and select Open command window here. Then type python.exe -m pip install numpy in there and press Enter. +What this does is that it calls 64-bit python's pip to install numpy instead.",0.0,False,3,5284 2018-01-03 21:28:09.170,Plotly - How to remove the rangeslider,"By default, candlestick and ohlc charts display a rangeslider. It seems like there's no parameter to change the setting. So I've looked at javascript code in html file but was not able to find a clue to remove it. Can someone explain how to remove the rangeslider from candlestick chart?","I found the solution.. @@ -50347,12 +50347,17 @@ Copied an activate script from the virtualenv (an identical one for which the en Added the anaconda folders to the path None of these worked. -I can manually activate the environment without a problem once the terminal is open, but how do I do it automatically?","Found a solution. Problem is we have been creating conda environments from within Pycharm while starting a new project. -This is created at the location /Users//.conda/envs/. -e.g. /Users/taponidhi/.conda/envs/py38. -Instead create environments from terminal using conda create --name py38. -This will create the environment at /opt/anaconda3/envs/. -After this, when starting a new project, select this environment from existing environments. Everything works fine.",0.0313868613919487,False,3,5365 +I can manually activate the environment without a problem once the terminal is open, but how do I do it automatically?","Solution for Windows +Go to Settings -> Tools -> Terminal +set Shell path to: + +For powershell (I recommend this): +powershell.exe -ExecutionPolicy ByPass -NoExit -Command ""& 'C:\tools\miniconda3\shell\condabin\conda-hook.ps1' +For cmd.exe: +cmd.exe ""C:\tools\miniconda3\Scripts\activate.bat"" + +PyCharm will change environment automatically in the terminal +PS: I'm using my paths to miniconda, so replace it with yours",0.1249325528793103,False,3,5365 2018-02-22 10:14:57.343,PyCharm terminal doesn't activate conda environment,"I have a conda environment at the default location for windows, which is C:\ProgramData\Anaconda2\envs\myenv. Also, as recommended, the conda scripts and executables are not in the %PATH% environment variable. I opened a project in pycharm and pointed the python interpreter to C:\ProgramData\Anaconda2\envs\myenv\python.exe @@ -50366,11 +50371,12 @@ Copied an activate script from the virtualenv (an identical one for which the en Added the anaconda folders to the path None of these worked. -I can manually activate the environment without a problem once the terminal is open, but how do I do it automatically?","I am using OSX and zshell has become the default shell in 2020. -I faced the same problem: my conda environment was not working inside pycharm's terminal. -File -> Settings -> Tools -> Terminal. the default shell path was configured as /bin/zsh --login -I tested on a separate OSX terminal that /bin/zsh --login somehow messes up $PATH variable. conda activate keep adding conda env path at the end instead of at the beginning. So the default python (2.7) always took precedence because of messed up PATH string. This issue had nothing to do with pycharm (just how zshell behaved with --login), -I removed --login part from the script path; just /bin/zsh works (I had to restart pycharm after this change!)",0.0,False,3,5365 +I can manually activate the environment without a problem once the terminal is open, but how do I do it automatically?","Found a solution. Problem is we have been creating conda environments from within Pycharm while starting a new project. +This is created at the location /Users//.conda/envs/. +e.g. /Users/taponidhi/.conda/envs/py38. +Instead create environments from terminal using conda create --name py38. +This will create the environment at /opt/anaconda3/envs/. +After this, when starting a new project, select this environment from existing environments. Everything works fine.",0.0313868613919487,False,3,5365 2018-02-22 10:14:57.343,PyCharm terminal doesn't activate conda environment,"I have a conda environment at the default location for windows, which is C:\ProgramData\Anaconda2\envs\myenv. Also, as recommended, the conda scripts and executables are not in the %PATH% environment variable. I opened a project in pycharm and pointed the python interpreter to C:\ProgramData\Anaconda2\envs\myenv\python.exe @@ -50384,17 +50390,11 @@ Copied an activate script from the virtualenv (an identical one for which the en Added the anaconda folders to the path None of these worked. -I can manually activate the environment without a problem once the terminal is open, but how do I do it automatically?","Solution for Windows -Go to Settings -> Tools -> Terminal -set Shell path to: - -For powershell (I recommend this): -powershell.exe -ExecutionPolicy ByPass -NoExit -Command ""& 'C:\tools\miniconda3\shell\condabin\conda-hook.ps1' -For cmd.exe: -cmd.exe ""C:\tools\miniconda3\Scripts\activate.bat"" - -PyCharm will change environment automatically in the terminal -PS: I'm using my paths to miniconda, so replace it with yours",0.1249325528793103,False,3,5365 +I can manually activate the environment without a problem once the terminal is open, but how do I do it automatically?","I am using OSX and zshell has become the default shell in 2020. +I faced the same problem: my conda environment was not working inside pycharm's terminal. +File -> Settings -> Tools -> Terminal. the default shell path was configured as /bin/zsh --login +I tested on a separate OSX terminal that /bin/zsh --login somehow messes up $PATH variable. conda activate keep adding conda env path at the end instead of at the beginning. So the default python (2.7) always took precedence because of messed up PATH string. This issue had nothing to do with pycharm (just how zshell behaved with --login), +I removed --login part from the script path; just /bin/zsh works (I had to restart pycharm after this change!)",0.0,False,3,5365 2018-02-22 10:29:28.120,Choosing subset of farthest points in given set of points,"Imagine you are given set S of n points in 3 dimensions. Distance between any 2 points is simple Euclidean distance. You want to chose subset Q of k points from this set such that they are farthest from each other. In other words there is no other subset Q’ of k points exists such that min of all pair wise distances in Q is less than that in Q’. If n is approximately 16 million and k is about 300, how do we efficiently do this? My guess is that this NP-hard so may be we just want to focus on approximation. One idea I can think of is using Multidimensional scaling to sort these points in a line and then use version of binary search to get points that are furthest apart on this line.","Find the maximum extent of all points. Split into 7x7x7 voxels. For all points in a voxel find the point closest to its centre. Return these 7x7x7 points. Some voxels may contain no points, hopefully not too many.",0.0,False,2,5366 @@ -50469,10 +50469,6 @@ In a prod app you'll likely need something in between depending on your needs",0 2018-02-28 14:31:41.907,Django OAuth Toolkit - Register a user,"I've gone through the docs of Provider and Resource of Django OAuth Toolkit, but all I'm able to find is how to 'authenticate' a user, not how to register a user. I'm able to set up everything on my machine, but not sure how to register a user using username & password. I know I'm missing something very subtle. How do I exactly register a user and get an access token in return to talk to my resource servers. OR -Is it like that I've to first register the user using normal Django mechanism and then get the token of the same?","You have to create the user using normal Django mechanism (For example, you can add new users from admin or from django shell). However, to get access token, OAuth consumer should send a request to OAuth server where user will authorize it, once the server validates the authorization, it will return the access token.",0.5457054096481145,False,2,5375 -2018-02-28 14:31:41.907,Django OAuth Toolkit - Register a user,"I've gone through the docs of Provider and Resource of Django OAuth Toolkit, but all I'm able to find is how to 'authenticate' a user, not how to register a user. -I'm able to set up everything on my machine, but not sure how to register a user using username & password. I know I'm missing something very subtle. How do I exactly register a user and get an access token in return to talk to my resource servers. -OR Is it like that I've to first register the user using normal Django mechanism and then get the token of the same?","I'm registering user with regular django mechanism combined with django-oauth-toolkit's application client details (client id and client secret key). I have separate UserRegisterApiView which is not restricted with token authentication but it checks for client id and client secret key while making post request to register a new user. In this way we are restricting register url access to only registered OAuth clients. Here is the registration workflow: @@ -50481,6 +50477,10 @@ User registration request from React/Angular/View app with client_id and client_ Django will check if client_id and client_secret are valid if not respond 401 unauthorized. If valid and register user data is valid, register the user. On successful response redirect user to login page.",0.1016881243684853,False,2,5375 +2018-02-28 14:31:41.907,Django OAuth Toolkit - Register a user,"I've gone through the docs of Provider and Resource of Django OAuth Toolkit, but all I'm able to find is how to 'authenticate' a user, not how to register a user. +I'm able to set up everything on my machine, but not sure how to register a user using username & password. I know I'm missing something very subtle. How do I exactly register a user and get an access token in return to talk to my resource servers. +OR +Is it like that I've to first register the user using normal Django mechanism and then get the token of the same?","You have to create the user using normal Django mechanism (For example, you can add new users from admin or from django shell). However, to get access token, OAuth consumer should send a request to OAuth server where user will authorize it, once the server validates the authorization, it will return the access token.",0.5457054096481145,False,2,5375 2018-03-01 09:10:26.110,Is there a way to put a kanban element to the bottom in odoo,At the moment i am working on an odoo project and i have a kanban view. My question is how do i put a kanban element to the bottom via xml or python. Is there an index for the elements or something like that?,I solved it myself. I just added _order = 'finished asc' to the class. finished is a record of type Boolean and tells me if the Task is finished or not.,0.0,False,1,5376 2018-03-02 17:30:56.393,How to install mod_wsgi to specific python version in Ubuntu?,I'm trying to install the mod_wsgi module in apache in my Ubuntu server but I need it to be specifically for version 2.7.13 in Python.For whatever reason every time I run sudo apt-get install libapache2-mod-wsgi it installs the mod_wsgi module for Python 2.7.12.I'm doing all of this because I'm running into a weird python version issue.When I run one of my python Scripts in my server terminal it works perfectly with version 2.7.13.In Apache however the script doesn't work.I managed to figure out that my Apache is running version 2.7.12 and I think this is the issue.Still can't figure out how to change that apache python version yet though.,Eventually Figured it out.The problem was that I had 2 versions of Python 2.7 installed in my server(2.7.12 and 2.7.13) so the definitions of one were conflicting with the other.Solved it when I completely removed Python 2.7.13 from the server.,1.2,True,1,5377 2018-03-03 11:28:05.170,How can I pre-load or cache images with Python 2.7 and Kivy,"This may be a basic question, but I'm still learning Kivy and I'm not sure how to do this. @@ -50522,9 +50522,9 @@ For both cases I simply saved the file by df.to_hdf. Does anybody have a clue how to go about this?","Not exactly a solution but more of a workaround. I simply read the files in their corresponding Python versions and saved them as a CSV file, which can then be read any version of Python.",1.2,True,1,5382 2018-03-05 14:41:39.273,Two django project on the same ip address (server),"Is it possible to set two different django projects on the same IP address/server (Linode in this case)? For exmaple, django1_project running on www.example.com and django2_project on django2.example.com. This is preferable, but if this is not possible then how to make two djangos, i.e. one running on www.example.com/django1 and the second on www.example.com/django2? Do I need to adapt the settings.py, wsgi.py files or apache files (at /etc/apache2/sites-available) or something else? -Thank you in advance for your help!","Yes that's possible to host several Python powered sites with Apache + mod_wsgi from one host / Apache instance. The only constraint : all apps / sites must be powered by the same Python version, though each app may have (or not) its own virtualenv (which is strongly recommended). It is also recommended to use mod_wsgi daemon mode and have each Django site run in separate daemon process group.",0.3869120172231254,False,2,5383 -2018-03-05 14:41:39.273,Two django project on the same ip address (server),"Is it possible to set two different django projects on the same IP address/server (Linode in this case)? For exmaple, django1_project running on www.example.com and django2_project on django2.example.com. This is preferable, but if this is not possible then how to make two djangos, i.e. one running on www.example.com/django1 and the second on www.example.com/django2? Do I need to adapt the settings.py, wsgi.py files or apache files (at /etc/apache2/sites-available) or something else? Thank you in advance for your help!","I'm not familiar with Linode restrictions, but if you have control over your Apache files then you could certainly do it with name-based virtual hosting. Set up two VirtualHost containers with the same IP address and port (and this assumes that both www.example.com and django2.example.com resolve to that IP address) and then differentiate requests using the ServerName setting in the container. In Apache 2.4 name-based virtual hosting is automatic. In Apache 2.2 you need the NameVirtualHost directive.",0.0,False,2,5383 +2018-03-05 14:41:39.273,Two django project on the same ip address (server),"Is it possible to set two different django projects on the same IP address/server (Linode in this case)? For exmaple, django1_project running on www.example.com and django2_project on django2.example.com. This is preferable, but if this is not possible then how to make two djangos, i.e. one running on www.example.com/django1 and the second on www.example.com/django2? Do I need to adapt the settings.py, wsgi.py files or apache files (at /etc/apache2/sites-available) or something else? +Thank you in advance for your help!","Yes that's possible to host several Python powered sites with Apache + mod_wsgi from one host / Apache instance. The only constraint : all apps / sites must be powered by the same Python version, though each app may have (or not) its own virtualenv (which is strongly recommended). It is also recommended to use mod_wsgi daemon mode and have each Django site run in separate daemon process group.",0.3869120172231254,False,2,5383 2018-03-05 21:29:54.990,Understanding Python Concurrency with Asyncio,"I was wondering how concurrency works in python 3.6 with asyncio. My understanding is that when the interpreter executing await statement, it will leave it there until the awaiting process is complete and then move on to execute the other coroutine task. But what I see here in the code below is not like that. The program runs synchronously, executing task one by one. What is wrong with my understanding and my impletementation code? @@ -50562,8 +50562,7 @@ What is wrong with my understanding and my impletementation code? loop = asyncio.get_event_loop() loop.run_until_complete(main()) print(""All Tasks Completed"") - loop.close()","Invoking a blocking call such as time.sleep in an asyncio coroutine blocks the whole event loop, defeating the purpose of using asyncio. -Change time.sleep(10) to await asyncio.sleep(10), and the code will behave like you expect.",1.2,True,2,5384 + loop.close()","asyncio use a loop to run everything, await would yield back the control to the loop so it can arrange the next coroutine to run.",0.0,False,2,5384 2018-03-05 21:29:54.990,Understanding Python Concurrency with Asyncio,"I was wondering how concurrency works in python 3.6 with asyncio. My understanding is that when the interpreter executing await statement, it will leave it there until the awaiting process is complete and then move on to execute the other coroutine task. But what I see here in the code below is not like that. The program runs synchronously, executing task one by one. What is wrong with my understanding and my impletementation code? @@ -50601,7 +50600,8 @@ What is wrong with my understanding and my impletementation code? loop = asyncio.get_event_loop() loop.run_until_complete(main()) print(""All Tasks Completed"") - loop.close()","asyncio use a loop to run everything, await would yield back the control to the loop so it can arrange the next coroutine to run.",0.0,False,2,5384 + loop.close()","Invoking a blocking call such as time.sleep in an asyncio coroutine blocks the whole event loop, defeating the purpose of using asyncio. +Change time.sleep(10) to await asyncio.sleep(10), and the code will behave like you expect.",1.2,True,2,5384 2018-03-06 11:12:40.463,how to use ws(websocket) via ngrok,"I want to share my local WebSocket on the internet but ngrok only support HTTP but my ws.py address is ws://localhost:8000/ it is good working on localhost buy is not know how to use this on the internet?","You can use ngrok http 8000 to access it. It will work. Although, ws is altogether a different protocol than http but ngrok handles it internally.",0.3869120172231254,False,1,5385 2018-03-07 18:09:25.337,How do I rewrite python file with a python script,"file2.py is just variables @@ -50750,8 +50750,7 @@ python3.6 mysql1.py import mysql.connector ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package -can any one know how to resolve","You must not name your script mysql.py — in that case Python tries to import mysql from the script — and fails. -Rename your script /root/Python_environment/my_Scripts/mysql.py to something else.",0.2012947653214861,False,2,5402 +can any one know how to resolve",This is the problem I faced in Environment created by python.Outside the python environment i am able to run the script.Its running succefully.In python environment i am not able run script i am working on it.if any body know can give suggestion on this,1.2,True,2,5402 2018-03-13 04:47:18.973,Mysql Connector issue in Python,"I have installed MySQL connector for python 3.6 in centos 7 If I search for installed modules with below command @@ -50777,7 +50776,8 @@ python3.6 mysql1.py import mysql.connector ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package -can any one know how to resolve",This is the problem I faced in Environment created by python.Outside the python environment i am able to run the script.Its running succefully.In python environment i am not able run script i am working on it.if any body know can give suggestion on this,1.2,True,2,5402 +can any one know how to resolve","You must not name your script mysql.py — in that case Python tries to import mysql from the script — and fails. +Rename your script /root/Python_environment/my_Scripts/mysql.py to something else.",0.2012947653214861,False,2,5402 2018-03-13 10:42:26.920,PyQt QTabWidget Multiple Corner WIdgets,"I want to remove the actual Close, minimize and maximize buttons of a window and create my own custom buttons, just like in chrome. I therefore want to add corner widgets to my tabwidget. Is there a way so that I can add three buttons as corner widgets of a QTabWidget? Is it somehow possible to achieve using the QHBoxLayout ? The setCornerWidget function just takes one widget as its input.","Add a generic QWidget as the corner widget. @@ -50863,11 +50863,6 @@ node = cmds.createNode('blinn', name='yipikai')",1.2,True,1,5412 I would like to use Spyder as my IDE. I have installed Spyder3 in my Python3 environment, but when I open Spyder 3 (from within my Python 3 env), then it opens Spyder for python 2.7 and not python 3.5 as I would've hoped for.). I don't know why. I have done TOOLS--Preferences--Python Interpreter -- Use the following Python interpreter: C:\Users\16082834\AppData\Local\Continuum\Anaconda2\envs\Python3\python.exe, but this didn't work either. Many of us are running multiple python environments; I am sure some of you might have managed to use Spyder for these different environments. -Please tell me how I can get Python 3 using this method.",One possible way is to run activate Python3 and then run pip install Spyder.,0.3869120172231254,False,2,5413 -2018-03-21 13:47:00.707,How to install Spyder for Python 2 and Python 3 and get Python 3 in my Spyder env?,"I have Python 2.7 installed (as default in Windows 7 64bit) and also have Python 3 installed in an environment (called Python3). -I would like to use Spyder as my IDE. I have installed Spyder3 in my Python3 environment, but when I open Spyder 3 (from within my Python 3 env), then it opens Spyder for python 2.7 and not python 3.5 as I would've hoped for.). I don't know why. -I have done TOOLS--Preferences--Python Interpreter -- Use the following Python interpreter: C:\Users\16082834\AppData\Local\Continuum\Anaconda2\envs\Python3\python.exe, but this didn't work either. -Many of us are running multiple python environments; I am sure some of you might have managed to use Spyder for these different environments. Please tell me how I can get Python 3 using this method.","So, when you create a new environment with: conda create --name python36 python=3.6 anaconda This will create an env. called python36 and the package to be installed is anaconda (which basically contains everything you'll need for python). Be sure that your new env. actually is running the ecorrect python version by doing the following: @@ -50880,6 +50875,11 @@ then type: spyder It will automatically open spyder3 for python3. My initial issue was therefore that even though i created a python3 environment, it was still running python2.7. But after removing the old python3 environment and creating a new python3 env. and installing the desired libraries/packages it now works perfect. I have a 2.7 and 3.6 environment which can both be edited with spyder2 and spyder3 IDE",0.2012947653214861,False,2,5413 +2018-03-21 13:47:00.707,How to install Spyder for Python 2 and Python 3 and get Python 3 in my Spyder env?,"I have Python 2.7 installed (as default in Windows 7 64bit) and also have Python 3 installed in an environment (called Python3). +I would like to use Spyder as my IDE. I have installed Spyder3 in my Python3 environment, but when I open Spyder 3 (from within my Python 3 env), then it opens Spyder for python 2.7 and not python 3.5 as I would've hoped for.). I don't know why. +I have done TOOLS--Preferences--Python Interpreter -- Use the following Python interpreter: C:\Users\16082834\AppData\Local\Continuum\Anaconda2\envs\Python3\python.exe, but this didn't work either. +Many of us are running multiple python environments; I am sure some of you might have managed to use Spyder for these different environments. +Please tell me how I can get Python 3 using this method.",One possible way is to run activate Python3 and then run pip install Spyder.,0.3869120172231254,False,2,5413 2018-03-22 01:28:29.740,Find pid using python by grepping two variables,"I am trying to find pid of a oracle process by using below command ps -ef | grep pmon | grep orcl | grep -v grep When trying to use python @@ -50974,3 +50974,11130 @@ Or, if you don't need the services to be coupled in that way, you could certainl For a monophonic wav file read() returns an 1-D array of integers. What do these integers represent? Are they the frequencies? If not how do I use them to get the frequencies?","wavfile.read() returns two things: data: This is the data from your wav file which is the amplitude of the audio taken at even intervals of time. sample rate: How many of those intervals make up one second of audio.",1.2,True,1,5419 +2018-03-26 05:57:47.947,Text Categorization Test NLTK python,"I have using nltk packages and train a model using Naive Bayes. I have save the model to a file using pickle package. Now i wonder how can i use this model to test like a random text not in the dataset and the model will tell if the sentence belong to which categorize? +Like my idea is i have a sentence : "" Ronaldo have scored 2 goals against Egypt"" And pass it to the model file and return categorize ""sport"".","Just saving the model will not help. You should also save your VectorModel (like tfidfvectorizer or countvectorizer what ever you have used for fitting the train data). You can save those the same way using pickle. Also save all those models you used for pre-processing the train data like normalization/scaling models, etc. For the test data repeat the same steps by loading the pickle models that you saved and transform the test data in train data format that you used for model building and then you will be able to classify.",1.2,True,1,5420 +2018-03-26 12:36:28.430,"How does Python internally distinguish ""from package import module"" between ""from module import function""","If I understand correctly, the python syntax from ... import ... can be used in two ways + +from package-name import module-name +from module-name import function-name + +I would like to know a bit of how Python internally treats the two different forms. Imagine, for example, that the interpreter gets ""from A import B"", does the interpreter actually try to determine whether A is a package-name/ module-name, or does it internally treat packages and modules as the same class of objects (something like Linux treats files and directories very similarly)?","First of all, a module is a python file that contains classes and functions. when you say From A Import B python searches for A(a module) in the standard python library and then imports B(the function or class) which is the module if it finds A. If it doesn't it goes out and starts searching in the directory were packages are stored and searches for the package name( A ) and then if it finds it, it imports the Module name(B). If it fails in the past 2 processes it returns an error. +Hope this helps.",-0.3869120172231254,False,1,5421 +2018-03-26 14:38:24.260,What is a good crawling speed rate?,I'm crawling web pages to create a search engine and have been able to crawl close to 9300 pages in 1 hour using Scrapy. I'd like to know how much more can I improve and what value is considered as a 'good' crawling speed.,It really depends but you can always check your crawling benchmarks for your hardware by typing scrapy bench on your command line,0.0,False,2,5422 +2018-03-26 14:38:24.260,What is a good crawling speed rate?,I'm crawling web pages to create a search engine and have been able to crawl close to 9300 pages in 1 hour using Scrapy. I'd like to know how much more can I improve and what value is considered as a 'good' crawling speed.,"I'm no expert but I would say that your speed is pretty slow. I just went to google, typed in the word ""hats"", pressed enter and: about 650,000,000 results (0.63 seconds). That's gonna be tough to compete with. I'd say that there's plenty of room to improve.",-0.1352210990936997,False,2,5422 +2018-03-27 05:06:56.187,Verify mountpoint in the remote server,"os.path.ismount() will verify whether the given path is mounted on the local linux machine. Now I want to verify whether the path is mounted on the remote machine. Could you please help me how to achieve this. +For example: my dev machine is : xx:xx:xxx +I want to verify whether the '/path' is mounted on yy:yy:yyy. +How can achieve this by using os.path.ismount() function","If you have access to both machines, then one way could be to leverage python's sockets. The client on the local machine would send a request to the server on the remote machine, then the server would do os.path.ismount('/path') and send back the return value to the client.",0.0,False,1,5423 +2018-03-27 22:23:28.003,How to parse a c/c++ header with llvmlite in python,"I'd like to parse a c and/or c++ header file in python using llvmlite. Is this possible? And if so, how do I create an IR representation of the header's contents?","llvmlite is a python binding for LLVM, which is independent from C or C++ or any other language. To parse C or C++, one option is to use the python binding for libclang.",0.0,False,1,5424 +2018-03-28 05:18:16.253,Are framework and libraries the more important bit of coding?,"Coding is entirely new to me. +Right now, I am teaching myself Python. As of now, I am only going over algorithms. I watched a few crash courses online about the language. Based on that, I don't feel like I am able to code any sort of website or software which leads me wonder if the libraries and frameworks of any programming language are the most important bit? +Should I spend more time teaching myself how to code with frameworks and libraries? +Thanks","First of all, you should try to be comfortable with every Python mechanisms (classes, recursion, functions... everything you usually find in any book or complete tutorial). It could be useful for any problem you want to solve. +Then, you should start your own project using the suitable libraries and frameworks. You must set a clear goal, do you want to build a website or a software ? You won't use the same libraries/framework for any purpose. Some of them are really often used so you could start by reading their documentation. +Anyhow, to answer your question, framework and libraries are not the most important bit of coding. They are just your tools, whereas the way you think to solve problems and build your algorithms is your art. +The most important thing to be a painter is not knowing how to use a brush (even if, of course, it's really useful)",1.2,True,1,5425 +2018-03-29 07:20:01.590,Keras rename model and layers,"1) I try to rename a model and the layers in Keras with TF backend, since I am using multiple models in one script. +Class Model seem to have the property model.name, but when changing it I get ""AttributeError: can't set attribute"". +What is the Problem here? +2) Additionally, I am using sequential API and I want to give a name to layers, which seems to be possibile with Functional API, but I found no solution for sequential API. Does anonye know how to do it for sequential API? +UPDATE TO 2): Naming the layers works, although it seems to be not documented. Just add the argument name, e.g. model.add(Dense(...,...,name=""hiddenLayer1""). Watch out, Layers with same name share weights!","To rename a keras model in TF2.2.0: +model._name = ""newname"" +I have no idea if this is a bad idea - they don't seem to want you to do it, but it does work. To confirm, call model.summary() and you should see the new name.",0.4247838355242418,False,2,5426 +2018-03-29 07:20:01.590,Keras rename model and layers,"1) I try to rename a model and the layers in Keras with TF backend, since I am using multiple models in one script. +Class Model seem to have the property model.name, but when changing it I get ""AttributeError: can't set attribute"". +What is the Problem here? +2) Additionally, I am using sequential API and I want to give a name to layers, which seems to be possibile with Functional API, but I found no solution for sequential API. Does anonye know how to do it for sequential API? +UPDATE TO 2): Naming the layers works, although it seems to be not documented. Just add the argument name, e.g. model.add(Dense(...,...,name=""hiddenLayer1""). Watch out, Layers with same name share weights!","for 1), I think you may build another model with right name and same structure with the exist one. then set weights from layers of the exist model to layers of the new model.",-0.1794418372930847,False,2,5426 +2018-03-29 16:33:58.400,Heroku Python import local functions,"I'm developing a chatbot using heroku and python. I have a file fetchWelcome.py in which I have written a function. I need to import the function from fetchWelcome into my main file. +I wrote ""from fetchWelcome import fetchWelcome"" in main file. But because we need to mention all the dependencies in the requirement file, it shows error. I don't know how to mention user defined requirement. +How can I import the function from another file into the main file ? Both the files ( main.py and fetchWelcome.py ) are in the same folder.","If we need to import function from fileName into main.py, write ""from .fileName import functionName"". Thus we don't need to write any dependency in requirement file.",0.0,False,1,5427 +2018-03-29 17:21:53.613,How to choose RandomState in train_test_split?,"I understand how random state is used to randomly split data into training and test set. As Expected, my algorithm gives different accuracy each time I change it. Now I have to submit a report in my university and I am unable to understand the final accuracy to mention there. Should I choose the maximum accuracy I get? Or should I run it with different RandomStates and then take its average? Or something else?","For me personally, I set random_state to a specific number (usually 42) so if I see variation in my programs accuracy I know it was not caused by how the data was split. +However, this can lead to my network over fitting on that specific split. I.E. I tune my network so it works well with that split, but not necessarily on a different split. Because of this, I think it's best to use a random seed when you submit your code so the reviewer knows you haven't over fit to that particular state. +To do this with sklearn.train_test_split you can simply not provide a random_state and it will pick one randomly using np.random.",0.2012947653214861,False,1,5428 +2018-03-30 10:14:52.273,"Python application freezes, only CTRL-C helps","I have a Python app that uses websockets and gevent. It's quite a big application in my personal experience. +I've encountered a problem with it: when I run it on Windows (with 'pipenv run python myapp'), it can (suddenly but very rarily) freeze, and stop accepting messages. If I then enter CTRL+C in cmd, it starts reacting to all the messages, that were issued when it was hanging. +I understand, that it might block somewhere, but I don't know how to debug theses types of errors, because I don't see anything in the code, that could do it. And it happens very rarily on completely different stages of the application's runtime. +What is the best way to debug it? And to actually see what goes behind the scenes? My logs show no indication of a problem. +Could it be an error with cmd and not my app?","Your answer may be as simple as adding timeouts to some of your spawns or gevent calls. Gevent is still single threaded, and so if an IO bound resource hangs, it can't context switch until it's been received. Setting a timeout might help bypass these issues and move your app forward?",0.0,False,1,5429 +2018-03-30 14:45:10.337,How to compare date (yyyy-mm-dd) with year-Quarter (yyyyQQ) in python,"I am writing a sql query using pandas within python. In the where clause I need to compare a date column (say review date 2016-10-21) with this value '2016Q4'. In other words if the review dates fall in or after Q4 in 2016 then they will be selected. Now how do I convert the review date to something comparable to 'yyyyQ4' format. Is there any python function for that ? If not, how so I go about writing one for this purpose ?","Once you are able to get the month out into a variable: mon +you can use the following code to get the quarter information: +for mon in range(1, 13): + print (mon-1)//3 + 1, +print +which would return: + +for months 1 - 3 : 1 +for months 4 - 6 : 2 +for months 7 - 9 : 3 +for months 10 - 12 : 4",1.2,True,1,5430 +2018-03-31 04:10:29.847,Measurement for intersection of 2 irregular shaped 3d object,"I am trying to implement an objective function that minimize the overlap of 2 irregular shaped 3d objects. While the most accurate measurement of the overlap is the intersection volume, it's too computationally expensive as I am dealing with complex objects with 1000+ faces and are not convex. +I am wondering if there are other measurements of intersection between 3d objects that are much faster to compute? 2 requirements for the measurement are: 1. When the measurement is 0, there should be no overlap; 2. The measurement should be a scalar(not a boolean value) indicating the degree of overlapping, but this value doesn't need to be very accurate. +Possible measurements I am considering include some sort of 2D surface area of intersection, or 1D penetration depth. Alternatively I can estimate volume with a sample based method that sample points inside one object and test the percentage of points that exist in another object. But I don't know how computational expensive it is to sample points inside a complex 3d shape as well as to test if a point is enclosed by such a shape. +I will really appreciate any advices, codes, or equations on this matter. Also if you can suggest any libraries (preferably python library) that accept .obj, .ply...etc files and perform 3D geometry computation that will be great! I will also post here if I find out a good method. +Update: +I found a good python library called Trimesh that performs all the computations mentioned by me and others in this post. It computes the exact intersection volume with the Blender backend; it can voxelize meshes and compute the volume of the co-occupied voxels; it can also perform surface and volumetric points sampling within one mesh and test points containment within another mesh. I found surface point sampling and containment testing(sort of surface intersection) and the grid approach to be the fastest.","A sample-based approach is what I'd try first. Generate a bunch of points in the unioned bounding AABB, and divide the number of points in A and B by the number of points in A or B. (You can adapt this measure to your use case -- it doesn't work very well when A and B have very different volumes.) To check whether a given point is in a given volume, use a crossing number test, which Google. There are acceleration structures that can help with this test, but my guess is that the number of samples that'll give you reasonable accuracy is lower than the number of samples necessary to benefit overall from building the acceleration structure. +As a variant of this, you can check line intersection instead of point intersection: Generate a random (axis-aligned, for efficiency) line, and measure how much of it is contained in A, in B, and in both A and B. This requires more bookkeeping than point-in-polyhedron, but will give you better per-sample information and thus reduce the number of times you end up iterating through all the faces.",1.2,True,2,5431 +2018-03-31 04:10:29.847,Measurement for intersection of 2 irregular shaped 3d object,"I am trying to implement an objective function that minimize the overlap of 2 irregular shaped 3d objects. While the most accurate measurement of the overlap is the intersection volume, it's too computationally expensive as I am dealing with complex objects with 1000+ faces and are not convex. +I am wondering if there are other measurements of intersection between 3d objects that are much faster to compute? 2 requirements for the measurement are: 1. When the measurement is 0, there should be no overlap; 2. The measurement should be a scalar(not a boolean value) indicating the degree of overlapping, but this value doesn't need to be very accurate. +Possible measurements I am considering include some sort of 2D surface area of intersection, or 1D penetration depth. Alternatively I can estimate volume with a sample based method that sample points inside one object and test the percentage of points that exist in another object. But I don't know how computational expensive it is to sample points inside a complex 3d shape as well as to test if a point is enclosed by such a shape. +I will really appreciate any advices, codes, or equations on this matter. Also if you can suggest any libraries (preferably python library) that accept .obj, .ply...etc files and perform 3D geometry computation that will be great! I will also post here if I find out a good method. +Update: +I found a good python library called Trimesh that performs all the computations mentioned by me and others in this post. It computes the exact intersection volume with the Blender backend; it can voxelize meshes and compute the volume of the co-occupied voxels; it can also perform surface and volumetric points sampling within one mesh and test points containment within another mesh. I found surface point sampling and containment testing(sort of surface intersection) and the grid approach to be the fastest.","By straight voxelization: +If the faces are of similar size (if needed triangulate the large ones), you can use a gridding approach: define a regular 3D grid with a spacing size larger than the longest edge and store one bit per voxel. +Then for every vertex of the mesh, set the bit of the cell it is included in (this just takes a truncation of the coordinates). By doing this, you will obtain the boundary of the object as a connected surface. You will obtain an estimate of the volume by means of a 3D flood filling algorithm, either from an inside or an outside pixel. (Outside will be easier but be sure to leave a one voxel margin around the object.) +Estimating the volumes of both objects as well as intersection or union is straightforward with this machinery. The cost will depend on the number of faces and the number of voxels.",0.0,False,2,5431 +2018-03-31 08:19:33.750,How executed code block Science mode in Pycharm,"Like Spyder, you can execute code block. how can i do in Pycharm in science mode. in spyder you use +# In[] +How can i do this in pycharm","you can just import numpy to actvate science mode. +import numpy as np",0.2012947653214861,False,2,5432 +2018-03-31 08:19:33.750,How executed code block Science mode in Pycharm,"Like Spyder, you can execute code block. how can i do in Pycharm in science mode. in spyder you use +# In[] +How can i do this in pycharm","pycharm use code cell. you can do with this +'#%% '",1.2,True,2,5432 +2018-03-31 10:41:21.540,Building WSN topology integrated with SDN controller (mininet-wifi),"In mininet-wifi examples, I found a sample (6LowPAN.py) that creates a simple topology contains 3 nodes. +Now, I intend to create another topology as follows: + +1- Two groups of sensor nodes such that each group connects to a 'Sink + node' +2- Connect each 'Sink node' to an 'ovSwitch' +3- Connect the two switches to a 'Controller' + +Is that doable using mininet-wifi? Any tips how to do it?? +Many thanks in advance :)","Yes, you can do this with 6LowPAN.py. You then add switches and controller into the topology with their links.",0.3869120172231254,False,1,5433 +2018-04-01 01:28:54.353,Neural Network - Input Normalization,"It is a common practice to normalize input values (to a neural network) to speed up the learning process, especially if features have very large scales. +In its theory, normalization is easy to understand. But I wonder how this is done if the training data set is very large, say for 1 million training examples..? If # features per training example is large as well (say, 100 features per training example), 2 problems pop up all of a sudden: +- It will take some time to normalize all training samples +- Normalized training examples need to be saved somewhere, so that we need to double the necessary disk space (especially if we do not want to overwrite the original data). +How is input normalization solved in practice, especially if the data set is very large? +One option maybe is to normalize inputs dynamically in the memory per mini batch while training.. But normalization results will then be changing from one mini batch to another. Would it be tolerable then? +There is maybe someone in this platform having hands on experience on this question. I would really appreciate if you could share your experiences. +Thank you in advance.","A large number of features makes it easier to parallelize the normalization of the dataset. This is not really an issue. Normalization on large datasets would be easily GPU accelerated, and it would be quite fast. Even for large datasets like you are describing. One of my frameworks that I have written can normalize the entire MNIST dataset in under 10 seconds on a 4-core 4-thread CPU. A GPU could easily do it in under 2 seconds. Computation is not the problem. While for smaller datasets, you can hold the entire normalized dataset in memory, for larger datasets, like you mentioned, you will need to swap out to disk if you normalize the entire dataset. However, if you are doing reasonably large batch sizes, about 128 or higher, your minimums and maximums will not fluctuate that much, depending upon the dataset. This allows you to normalize the mini-batch right before you train the network on it, but again this depends upon the network. I would recommend experimenting based on your datasets, and choosing the best method.",1.2,True,1,5434 +2018-04-01 15:08:50.007,Finding the eyeD3 executable,"I just installed the abcde CD utility but it's complaining that it can't find eyeD3, the Python ID3 program. This appears to be a well-known and unresolved deficiency in the abcde dependencies, and I'm not a Python programmer, so I'm clueless. +I have the Python 2.7.12 came with Mint 18, and something called python3 (3.5.2). If I try to install eyeD3 with pip (presumably acting against 2.7.12), it says it's already installed (in /usr/lib/python2.7/dist-packages/eyeD3). I don't know how to force pip to install under python3. +If I do a find / -name eyeD3, the only other thing it turns up is /usr/share/pyshared/eyeD3. But both of those are only directories, and both just contain Python libraries, not executables. +There isn't any other file called eyeD3 anywhere on disk. +Does anyone know what it's supposed to be called, where it's supposed to live, and how I can install it? +P","Gave up...waste of my time and everyone else's sorry. +What I apparently needed was the eyed3 (lowercase 'd') non-python utility.",0.0,False,2,5435 +2018-04-01 15:08:50.007,Finding the eyeD3 executable,"I just installed the abcde CD utility but it's complaining that it can't find eyeD3, the Python ID3 program. This appears to be a well-known and unresolved deficiency in the abcde dependencies, and I'm not a Python programmer, so I'm clueless. +I have the Python 2.7.12 came with Mint 18, and something called python3 (3.5.2). If I try to install eyeD3 with pip (presumably acting against 2.7.12), it says it's already installed (in /usr/lib/python2.7/dist-packages/eyeD3). I don't know how to force pip to install under python3. +If I do a find / -name eyeD3, the only other thing it turns up is /usr/share/pyshared/eyeD3. But both of those are only directories, and both just contain Python libraries, not executables. +There isn't any other file called eyeD3 anywhere on disk. +Does anyone know what it's supposed to be called, where it's supposed to live, and how I can install it? +P","I don't know how to force pip to install under python3. + +python3 -m pip install eyeD3 will install it for Python3.",0.2012947653214861,False,2,5435 +2018-04-02 22:28:00.080,python pair multiple field entries from csv,"Trying to take data from a csv like this: +col1 col2 +eggs sara +bacon john +ham betty +The number of items in each column can vary and may not be the same. Col1 may have 25 and col2 may have 3. Or the reverse, more or less. +And loop through each entry so its output into a text file like this +breakfast_1 +breakfast_item eggs +person sara +breakfast_2 +breakfast_item bacon +person sara +breakfast_3 +breakfast_item ham +person sara +breakfast_4 +breakfast_item eggs +person john +breakfast_5 +breakfast_item bacon +person john +breakfast_6 +breakfast_item ham +person john +breakfast_7 +breakfast_item eggs +person betty +breakfast_8 +breakfast_item bacon +person betty +breakfast_9 +breakfast_item ham +person betty +So the script would need to add the ""breakfast"" number and loop through each breakfast_item and person. +I know how to create one combo but not how to pair up each in a loop? +Any tips on how to do this would be very helpful.","First, get a distinct of all breakfast items. +A pseudo code like below +Iterate through each line +Collect item and person in 2 different lists +Do a set on those 2 lists +Say persons, items + +Counter = 1 +for person in persons: + for item in items: + Print ""breafastitem"", Counter + Print person, item",0.0,False,1,5436 +2018-04-03 07:25:09.530,How to find out Windows network interface name in Python?,"Windows command netsh interface show interface shows all network connections and their names. A name could be Wireless Network Connection, Local Area Network or Ethernet etc. +I would like to change an IP address with netsh interface ip set address ""Wireless Network Connection"" static 192.168.1.3 255.255.255.0 192.168.1.1 1 with Python script, but I need a network interface name. +Is it possible to have this information like we can have a hostname with socket.gethostname()? Or I can change an IP address with Python in other way?","I don't know of a Python netsh API. But it should not be hard to do with a pair of subprocess calls. First issue netsh interface show interface, parse the output you get back, then issue your set address command. +Or am I missing the point?",0.6730655149877884,False,1,5437 +2018-04-03 11:57:26.050,how do I install my modual onto my local copy of python on windows?,"I'm reading headfirst python and have just completed the section where I created a module for printing nested list items, I've created the code and the setup file and placed them in a file labeled ""Nester"" that is sitting on my desktop. The book is now asking for me to install this module onto my local copy of Python. The thing is, in the example he is using the mac terminal, and I'm on windows. I tried to google it but I'm still a novice and a lot of the explanations just go over my head. Can someone give me clear thorough guide?.","On Windows systems, third-party modules (single files containing one or more functions or classes) and third-party packages (a folder [a.k.a. directory] that contains more than one module (and sometimes other folders/directories) are usually kept in one of two places: c:\\Program Files\\Python\\Lib\\site-packages\\ and c:\\Users\\[you]\\AppData\\Roaming\\Python\\. +The location in Program Files is usually not accessible to normal users, so when PIP installs new modules/packages on Windows it places them in the user-accessible folder in the Users location indicated above. You have direct access to that, though by default the AppData folder is ""hidden""--not displayed in the File Explorer list unless you set FE to show hidden items (which is a good thing to do anyway, IMHO). You can put the module you're working on in the AppData\\Roaming\\Python\\ folder. +You still need to make sure the folder you put it in is in the PATH environment variable. PATH is a string that tells Windows (and Python) where to look for needed files, in this case the module you're working on. Google ""set windows path"" to find how to check and set your path variable, then just go ahead and put your module in a folder that's listed in your path. +Of course, since you can add any folder/directory you want to PATH, you could put your module anywhere you wanted--including leaving it on the Desktop--as long as the location is included in PATH. You could, for instance, have a folder such as Documents\\Programming\\Python\\Lib to put your personal modules in, and use Documents\\Programming\\Python\\Source for your Python programs. You'd just need to include those in the PATH variable. +FYI: Personally, I don't like the way python is (by default) installed on Windows (because I don't have easy access to c:\\Program Files), so I installed Python in a folder off the drive root: c:\Python36. In this way, I have direct access to the \\Lib\\site-packages\\ folder.",0.0,False,1,5438 +2018-04-03 19:38:45.600,Django : how to give user/group permission to view model instances for a specified period of time,"I am fairly new to Django and could not figure out by reading the docs or by looking at existing questions. I looked into Django permissions and authentication but could not find a solution. +Let's say I have a Detail View listing all instances of a Model called Item. For each Item, I want to control which User can view it, and for how long. In other words, for each User having access to the Item, I want the right/permission to view it to expire after a specified period of time. After that period of time, the Item would disapear from the list and the User could not access the url detailing the Item. +The logic to implement is pretty simple, I know, but the ""per user / per object"" part confuses me. Help would be much appreciated!","Information about UserItemExpiryDate has to be stored in a separate table (Model). I would recommend using your coding in Django. +There are few scenarios to consider: +1) A new user is created, and he/she should have access to items. +In this case, you add entries to UserItemExpiry with new User<>Item combination (as key) and expiry date. Then, for logged in user you look for items from Items that has User<>Item in UserItemExpiry in the future. +2) A new item is created, and it has to be added to existing users. +In such case, you add entries to UserItemExpiry with ALL users<> new Item combination (as key) and expiry date. And logic for ""selecting"" valid items is the same as in point 1. +Best of luck, +Radek Szwarc",1.2,True,1,5439 +2018-04-04 13:46:20.373,how to read text from excel file in python pandas?,"I am working on a excel file with large text data. 2 columns have lot of text data. Like descriptions, job duties. +When i import my file in python df=pd.read_excel(""form1.xlsx""). It shows the columns with text data as NaN. +How do I import all the text in the columns ? +I want to do analysis on job title , description and job duties. Descriptions and Job Title are long text. I have over 150 rows.","Try converting the file from .xlsx to .CSV +I had the same problem with text columns so i tried converting to CSV (Comma Delimited) and it worked. Not very helpful, but worth a try.",0.2012947653214861,False,1,5440 +2018-04-04 17:20:14.923,make a web server in localhost with flask,"I want to know that if I can make a web server with Flask in my pc like xampp apache (php) for after I can access this page in others places across the internet. Or even in my local network trough the wifi connection or lan ethernet. Is it possible ? I saw some ways to do this, like using ""uwsgi"".. something like this... but I colud never do it. +OBS: I have a complete application in Flask already complete, with databases and all things working. The only problem is that I don't know how to start the server and access by the others pc's.","Yes, you can. +Just like you said, you can use uwsgi to run your site efficiently. There are other web servers like uwsgi: I usually use Gunicorn. But note that Flask can run without any of these, it will simply be less efficient (but if it is just for you then it should not be a problem). +You can find tutorials on the net with a few keywords like ""serving flask app"". +If you want to access your site from the internet (outside of your local network), you will need to configure your firewall and router/modem to accept connections on port 80 (HTTP) or 443 (HTTPS). +Good luck :)",0.3869120172231254,False,1,5441 +2018-04-04 18:48:40.377,Python - How do I make a window along with widgets without using modules like Tkinter?,"I have been wanting to know how to make a GUI without using a module on Python, I have looked into GUI's in Python but everything leads to Tkinter or other Python GUI modules. The reason I do not want to use Tkinter is because I want to understand how to do it myself. I have looked at the Tkinter modules files but it imports like 4 other Modules. +I don't mind the modules like system, os or math just not modules which I will use and not understand. If you do decide to answer my question please include as much detail and information on the matter. Thanks -- Darrian Penman","For the same reason that you can't write to a database without using a database module, you can't create GUIs without a GUI module. There simply is no way to draw directly on the screen in a cross-platform way without a module. +Writing GUIs is very complex. These modules exist to reduce the complexity.",0.2012947653214861,False,2,5442 +2018-04-04 18:48:40.377,Python - How do I make a window along with widgets without using modules like Tkinter?,"I have been wanting to know how to make a GUI without using a module on Python, I have looked into GUI's in Python but everything leads to Tkinter or other Python GUI modules. The reason I do not want to use Tkinter is because I want to understand how to do it myself. I have looked at the Tkinter modules files but it imports like 4 other Modules. +I don't mind the modules like system, os or math just not modules which I will use and not understand. If you do decide to answer my question please include as much detail and information on the matter. Thanks -- Darrian Penman","You cannot write a GUI in Python without importing either a GUI module or importing ctypes. The latter would require calling OS-specific graphics primitives, and would be far worse than doing the same thing in C. (EDIT: see Roland comment below for X11 systems.) +The python-coded tkinter mainly imports the C-coded _tkinter, which interfaces to the tcl- and C- coded tk GUI package. There are separate versions of tcl/tk for Windows, *nix, and MacOS.",1.2,True,2,5442 +2018-04-04 21:19:39.857,Regular Expression in python how to find paired words,"I'm doing the cipher for python. I'm confused on how to use Regular Expression to find a paired word in a text dictionary. +For example, there is dictionary.txt with many English words in it. I need to find word paired with ""th"" at the beginning. Like they, them, the, their ..... +What kind of Regular Expression should I use to find ""th"" at the beginning? +Thank you!","^(th\w*) + +gives you all results where the string begins with th . If there is more than one word in the string you will only get the first. + +(^|\s)(th\w*) + +wil give you all the words begining with th even if there is more than one word begining with th",0.0,False,1,5443 +2018-04-04 22:36:48.643,pycharm ctrl+v copies the item in console instead paste when highlighted,"This has been a very annoying problem for me and I couldn't find any keymaps or settings that could cause this behavior. +Setup: + +Pycharm Professional 2018.1 installed on redhat linux +I remote into the linux machine using mobaX and launch pycharm with window forwarding + +Scenario 1: +I open a browser on windows, copy some text, go to editor or console, paste it somewhere without highlighting any text, hit ctrl+v, it pastes fine +Scenario 2: +I open a browser on windows, copy some text, go to editor or console, highlight some text there, hit ctrl+v in attempt to replace the highlighted text with what's in my clipboard. The text didn't change. I leave pycharm and paste somewhere else, the text in clipboard has now become the text I highlighted. +Edit: +ok I just realized this: as soon as I highlight the text, it gets copied...I've turned this feature off for terminal, but couldn't find a global settings for the editor etc. Anyone know how?","I figured it out: it's caused by the copy-on-select setting of my linux system. To turn it off, go to mobax-settings-configurations-x11-clipboard-disable 'copy on select'",1.2,True,1,5444 +2018-04-05 01:37:04.467,"In Keras, how to send each item in a batch through a model?","I have a model that starts with a Conv2D layer and so it must take input of shape (samples, rows, cols, channels) (and the model must ultimately output a shape of (1)). However, for my purposes one full unit of input needs to be some (fixed) number of samples, so the overall input shape sent into this model when given a batch of input ends up being (batch_size, samples, rows, cols, channels) (which is expected and correct, but...). How do I send each item in the batch through this model so that I end up with an output of shape (batch_size, 1)? +What I have tried so far: +I tried creating an inner model containing the Conv2D layer et al then wrapping the entire thing in a TimeDistributed wrapper, followed by a Dense(units=1) layer. This compiled, but resulted in an output shape of (batch_size, samples, 1). I feel like I am missing something simple...","At the moment you are returning a 3D array. +Add a Flatten() layer to convert the array to 2D, and then add a Dense(1). This should output (batch_size, 1).",0.1352210990936997,False,1,5445 +2018-04-05 06:45:15.460,How to add report_tensor_allocations_upon_oom to RunOptions in Keras,"I'm trying to train a neural net on a GPU using Keras and am getting a ""Resource exhausted: OOM when allocating tensor"" error. The specific tensor it's trying to allocate isn't very big, so I assume some previous tensor consumed almost all the VRAM. The error message comes with a hint that suggests this: + +Hint: If you want to see a list of allocated tensors when OOM happens, add report_tensor_allocations_upon_oom to RunOptions for current allocation info. + +That sounds good, but how do I do it? RunOptions appears to be a Tensorflow thing, and what little documentation I can find for it associates it with a ""session"". I'm using Keras, so Tensorflow is hidden under a layer of abstraction and its sessions under another layer below that. +How do I dig underneath everything to set this option in such a way that it will take effect?","OOM means out of memory. May be it is using more memory at that time. +Decrease batch_size significantly. I set to 16, then it worked fine",0.2012947653214861,False,1,5446 +2018-04-05 12:22:11.997,Django multilanguage text and saving it on mysql,"I have a problem with multilanguage and multi character encoded text. +Project use OpenGraph and it will save in mysql database some information from websites. But database have problem with character encoding. I tryed encoding them to byte. That is problem, becouse in admin panel text show us bute and it is not readable. +Please help me. How can i save multilanguage text in database and if i need encode to byte them how can i correctly decode them in admin panel and in views",You should encode all data as UTF-8 which is unicode.,0.0,False,1,5447 +2018-04-05 18:38:56.977,How to Install requests[security] in virtualenv in IntelliJ,I'm using python 2.7.10 virtualenv when running python codes in IntelliJ. I need to install requests[security] package. However I'm not sure how to add that [security] option/config when installing requests package using the Package installer in File > Project Structure settings window.,"Was able to install it by doing: + +Activating the virtualenv in the 'Terminal' tool window: +source /bin/activate +Executing a pip install requests[security]",0.0,False,1,5448 +2018-04-06 07:42:50.770,Use HermiT in Python,"We have an ontology but we need to use the reasoner HermiT to infer the sentiment of a given expression. We have no idea how to use and implement a reasoner in python and we could not find a good explanation on the internet. We found that we can use sync_reasoner() for this, but what does this do exactly? And do we have to call the reasoner manually everytime or does it happen automatically?","You do not need to implement the reasoner. The sync_reasoner() function already calls HermiT internally and does the reasoning for you. +A reasoner will reclassify individuals and classes for you which means it creates a parent-child hierarchy of classes and individuals. When you load an ontology only explicit parent-child relations are represented. However, when you call the reasoner, the parent-child hierarchy is updated to include inferred relations as well. +An example of this is provided in Owlready2-0.5/doc/intro.rst. Before calling sync_reasoner() calling test_pizza.__class__ prints onto.Pizza, which is explicit information. However, after calling sync_reasoner() calling test_pizza.__class__ prints onto.NonVegetarianPizza, which is the inferred information.",1.2,True,1,5449 +2018-04-06 17:50:58.693,Saving data to MacOS python application,"I am using Pyinstaller to create my Python app from a set of scripts. This script uses a library that saves downloaded data to the '~/' directory (using the os.join function). +I was wondering how to edit the code in the library so that when it runs, it saves data to inside the app (like in the package, the Contents/Resources maybe)?","I was wondering how to edit the code in the library so that when it runs, it saves data to inside the app + +Don't do that. This isn't a standard practice in macOS applications, and will fail in some standard system configurations. For example, it will fail if the application is used by a non-administrator user, or if the application is run from a read-only disk image or network share. +More importantly, it'll also make it difficult or impossible to sign the application bundle with a developer certificate.",1.2,True,1,5450 +2018-04-09 02:59:03.377,How are PyTorch's tensors implemented?,"I am building my own Tensor class in Rust, and I am trying to make it like PyTorch's implementation. +What is the most efficient way to store tensors programmatically, but, specifically, in a strongly typed language like Rust? Are there any resources that provide good insights into how this is done? +I am currently building a contiguous array, so that, given dimensions of 3 x 3 x 3, my array would just have 3^3 elements in it, which would represent the tensor. However, this does make some of the mathematical operations and manipulations of the array harder. +The dimension of the tensor should be dynamic, so that I could have a tensor with n dimensions.","Contiguous array +The commonly used way to store such data is in a single array that is laid out as a single, contiguous block within memory. More concretely, a 3x3x3 tensor would be stored simply as a single array of 27 values, one after the other. +The only place where the dimensions are used is to calculate the mapping between the (many) coordinates and the offset within that array. For example, to fetch the item [3, 1, 1] you would need to know if it is a 3x3x3 matrix, a 9x3x1 matrix, or a 27x1x1 matrix - in all cases the ""storage"" would be 27 items long, but the interpretation of ""coordinates"" would be different. If you use zero-based indexing, the calculation is trivial, but you need to know the length of each dimension. +This does mean that resizing and similar operations may require copying the whole array, but that's ok, you trade off the performance of those (rare) operations to gain performance for the much more common operations, e.g. sequential reads.",1.2,True,1,5451 +2018-04-10 09:23:35.627,Pycharm - Cannot find declaration to go to,"I changed my project code from python 2.7 to 3.x. +After these changes i get a message ""cannot find declaration to go to"" when hover over any method and press ctrl +I'm tryinig update pycharm from 2017.3 to 18.1, remove directory .idea but my issue still exist. +Do you have any idea how can i fix it?","I had same issue and invalidating cache or reinstalling the app didn't help. +As it turned out the problem was next: for some reasons *.py files were registered as a text files, not python ones. After I changed it, code completion and other IDE features started to work again. +To change file type go Preferences -> Editor -> File types",0.3869120172231254,False,5,5452 +2018-04-10 09:23:35.627,Pycharm - Cannot find declaration to go to,"I changed my project code from python 2.7 to 3.x. +After these changes i get a message ""cannot find declaration to go to"" when hover over any method and press ctrl +I'm tryinig update pycharm from 2017.3 to 18.1, remove directory .idea but my issue still exist. +Do you have any idea how can i fix it?","The solution for me: remember to add an interpreter to the project, it usually says in the bottom right corner if one is set up or not. Just an alternate solution than the others. +This happened after reinstalling PyCharm and not fully setting up the ide.",0.0814518047658113,False,5,5452 +2018-04-10 09:23:35.627,Pycharm - Cannot find declaration to go to,"I changed my project code from python 2.7 to 3.x. +After these changes i get a message ""cannot find declaration to go to"" when hover over any method and press ctrl +I'm tryinig update pycharm from 2017.3 to 18.1, remove directory .idea but my issue still exist. +Do you have any idea how can i fix it?",What worked for me was right-click on the folder that has the manage.py > Mark Directory as > Source Root.,0.3869120172231254,False,5,5452 +2018-04-10 09:23:35.627,Pycharm - Cannot find declaration to go to,"I changed my project code from python 2.7 to 3.x. +After these changes i get a message ""cannot find declaration to go to"" when hover over any method and press ctrl +I'm tryinig update pycharm from 2017.3 to 18.1, remove directory .idea but my issue still exist. +Do you have any idea how can i fix it?","I had a case where the method was implemented in a base class and Pycharm couldn't find it. +I solved it by importing the base class into the module I was having trouble with.",0.0814518047658113,False,5,5452 +2018-04-10 09:23:35.627,Pycharm - Cannot find declaration to go to,"I changed my project code from python 2.7 to 3.x. +After these changes i get a message ""cannot find declaration to go to"" when hover over any method and press ctrl +I'm tryinig update pycharm from 2017.3 to 18.1, remove directory .idea but my issue still exist. +Do you have any idea how can i fix it?","Right click on the folders where you believe relevant code is located ->Mark Directory as-> Sources Root +Note that the menu's wording ""Sources Root"" is misleading: the indexing process is not recursive. You need to mark all the relevant folders.",1.2,True,5,5452 +2018-04-11 09:36:40.700,VScode run code selection,"I just made the transition from Spyder to VScode for my python endeavours. Is there a way to run individual lines of code? That's how I used to do my on-the-spot debugging, but I can't find an option for it in VScode and really don't want to keep setting and removing breakpoints. +Thanks.","I'm still trying to figure out how to make vscode do what I need (interactive python plots), but I can offer a more complete answer to the question at hand than what has been given so far: +1- Evaluate current selection in debug terminal is an option that is not enabled by default, so you may want to bind the 'editor.debug.action.selectionToRepl' action to whatever keyboard shortcut you choose (I'm using F9). As of today, there still appears to be no option to evaluate current line while debugging, only current selection. +2- Evaluate current line or selection in python terminal is enabled by default, but I'm on Windows where this isn't doing what I would expect - it evaluates in a new runtime, which does no good if you're trying to debug an existing runtime. So I can't say much about how useful this option is, or even if it is necessary since anytime you'd want to evaluate line-by-line, you'll be in debug mode anyway and sending to debug console as in 1 above. The Windows issue might have something to do with the settings.json entry +""terminal.integrated.inheritEnv"": true, +not having an affect in Windows as of yet, per vscode documentation.",0.0,False,2,5453 +2018-04-11 09:36:40.700,VScode run code selection,"I just made the transition from Spyder to VScode for my python endeavours. Is there a way to run individual lines of code? That's how I used to do my on-the-spot debugging, but I can't find an option for it in VScode and really don't want to keep setting and removing breakpoints. +Thanks.","In my ver of VSCode (1.25), shift+enter will run selection. Note that you will want to have your integrated terminal running python.",0.2401167094949473,False,2,5453 +2018-04-11 12:21:36.483,How to run a django project without manage.py,"Basically I downloaded django project from SCM, Usually I run the project with with these steps + +git clone repository +extract +change directory to project folder +python manage.py runserver + +But this project does not contains manage.py , how to run this project in my local machine??? +br","Most likely, this is not supposed to be a complete project, but a plugin application. You should create your own project in the normal way with django-admin.py startproject and add the downloaded app to INSTALLED_APPS.",0.4701041941942874,False,1,5454 +2018-04-11 21:08:57.980,Python - Subtracting the Elements of Two Arrays,"I am new to Python programming and stumbled across this feature of subtracting in python that I can't figure out. I have two 0/1 arrays, both of size 400. I want to subtract each element of array one from its corresponding element in array 2. +For example say you have two arrays A = [0, 1, 1, 0, 0] and B = [1, 1, 1, 0, 1]. +Then I would expect A - B = [0 - 1, 1 - 1, 1 - 1, 0 - 0, 0 - 1] = [-1, 0, 0, 0, -1] +However in python I get [255, 0, 0, 0, 255]. +Where does this 255 come from and how do I get -1 instead? +Here's some additional information: +The real variables I'm working with are Y and LR_predictions. +Y = array([[0, 0, 0, ..., 1, 1, 1]], dtype=uint8) +LR_predictions = array([0, 1, 1, ..., 0, 1, 0], dtype=uint8) +When I use either Y - LR_predictions or numpy.subtract(Y, LR_predictions) +I get: array([[ 0, 255, 255, ..., 1, 0, 1]], dtype=uint8) +Thanks",I can't replicate this but it looks like the numbers are 8 bit and wrapping some how,0.0,False,1,5455 +2018-04-12 00:14:16.700,"How do I save a text file in python, to my File Explorer?","I've been using Python for a few months, but I'm sort of new to Files. I would like to know how to save text files into my Documents, using "".txt"".",If you do not like to overwrite existing file then use a or a+ mode. This just appends to existing file. a+ is able to read the file as well,0.0,False,1,5456 +2018-04-12 19:41:16.037,Send data from Python backend to Highcharts while escaping quotes for date,"I would highly appreciate any help on this. I'm constructing dynamic highcharts at the backend and would like to send the data along with html to the frontend. +In highcharts, there is a specific field to accept Date such as: +x:Date.UTC(2018,01,01) +or x:2018-01-01. However, when I send dates from the backend, it is always surrounded by quotes,so it becomes: x:'Date.UTC(2018,01,01)' +and x:'2018-01-01', which does not render the chart. Any suggestions on how to escape these quotes?","Highcharts expects the values on datetime axes to be timestamps (number of miliseconds from 01.01.1970). Date.UTC is a JS function that returns a timestamp as Number. Values surrounded by apostrophes are Strings. +I'd rather suggest to return a timestamp as a String from backend (e.g. '1514764800000') and then convert it to Number in JS (you can use parseInt function for that.)",0.0,False,1,5457 +2018-04-13 03:56:24.947,Google Cloud - What products for time series data cleaning?,"I have around 20TB of time series data stored in big query. +The current pipeline I have is: +raw data in big query => joins in big query to create more big query datasets => store them in buckets +Then I download a subset of the files in the bucket: +Work on interpolation/resampling of data using Python/SFrame, because some of the time series data have missing times and they are not evenly sampled. +However, it takes a long time on a local PC, and I'm guessing it will take days to go through that 20TB of data. + +Since the data are already in buckets, I'm wondering what would the best Google tools for interpolation and resampling? +After resampling and interpolation I might use Facebook's Prophet or Auto ARIMA to create some forecasts. But that would be done locally. + +There's a few services from Google that seems are like good options. + +Cloud DataFlow: I have no experience in Apache Beam, but it looks like the Python API with Apache Beam have missing functions compared to the Java version? I know how to write Java, but I'd like to use one programming language for this task. +Cloud DataProc: I know how to write PySpark, but I don't really need any real time processing or stream processing, however spark has time series interpolation, so this might be the only option? +Cloud Dataprep: Looks like a GUI for cleaning data, but it's in beta. Not sure if it can do time series resampling/interpolation. + +Does anyone have any idea which might best fit my use case? +Thanks","I would use PySpark on Dataproc, since Spark is not just realtime/streaming but also for batch processing. +You can choose the size of your cluster (and use some preemptibles to save costs) and run this cluster only for the time you actually need to process this data. Afterwards kill the cluster. +Spark also works very nicely with Python (not as nice as Scala) but for all effects and purposes the main difference is performance, not reduced API functionality. +Even with the batch processing you can use the WindowSpec for effective time serie interpolation +To be fair: I don't have a lot of experience with DataFlow or DataPrep, but that's because out use case is somewhat similar to yours and Dataproc works well for that",1.2,True,1,5458 +2018-04-16 06:29:31.313,Nested list comprehension to flatten nested list,"I'm quite new to Python, and was wondering how I flatten the following nested list using list comprehension, and also use conditional logic. +nested_list = [[1,2,3], [4,5,6], [7,8,9]] +The following returns a nested list, but when I try to flatten the list by removing the inner square brackets I get errors. +odds_evens = [['odd' if n % 2 != 0 else 'even' for n in l] for l in nested_list]","To create a flat list, you need to have one set of brackets in comprehension code. Try the below code: +odds_evens = ['odd' if n%2!=0 else 'even' for n in l for l in nested_list] +Output: +['odd', 'odd', 'odd', 'even', 'even', 'even', 'odd', 'odd', 'odd']",-0.1016881243684853,False,1,5459 +2018-04-17 09:44:50.407,Password protect a Python Script that is Scheduled to run daily,"I have a python script that is scheduled to run at a fixed time daily +If I am not around my colleague will be able to access my computer to run the script if there is any error with the windows task scheduler +I like to allow him to run my windows task scheduler but also to protect my source code in the script... is there any good way to do this, please? +(I have read methods to use C code to hide it but I am only familiar with Python) +Thank you","Compile the source to the .pyc bytecode, and then move the source somewhere inaccessible. + +Open a terminal window in the directory containing your script +Run python -m py-compile (you should get a yourfile.pyc file) +Move somewhere secure +your script can now be run as python + +Note that is is not necessarily secure as such - there are ways to decompile the bytecode - but it does obfuscate it, if that is your requirement.",1.2,True,1,5460 +2018-04-18 09:29:24.593,Scrapy - order of crawled urls,"I've got an issue with scrapy and python. +I have several links. I crawl data from each of them in one script with the use of loop. But the order of crawled data is random or at least doesn't match to the link. +So I can't match url of each subpage with the outputed data. +Like: crawled url, data1, data2, data3. +Data 1, data2, data3 => It's ok, because it comes from one loop, but how can I add to the loop current url or can I set the order of link's list? Like first from the list is crawled as first, second is crawled as second...","Ok, It seems that the solution is in settings.py file in scrapy. +DOWNLOAD_DELAY = 3 +Between requests. +It should be uncommented. Defaultly it's commented.",-0.1352210990936997,False,2,5461 +2018-04-18 09:29:24.593,Scrapy - order of crawled urls,"I've got an issue with scrapy and python. +I have several links. I crawl data from each of them in one script with the use of loop. But the order of crawled data is random or at least doesn't match to the link. +So I can't match url of each subpage with the outputed data. +Like: crawled url, data1, data2, data3. +Data 1, data2, data3 => It's ok, because it comes from one loop, but how can I add to the loop current url or can I set the order of link's list? Like first from the list is crawled as first, second is crawled as second...",time.sleep() - would it be a solution?,0.0,False,2,5461 +2018-04-18 20:24:57.843,gcc error when installing pyodbc,"I am installing pyodbc on Redhat 6.5. Python 2.6 and 2.7.4 are installed. I get the following error below even though the header files needed for gcc are in the /usr/include/python2.6. +I have updated every dev package: yum groupinstall -y 'development tools' +Any ideas on how to resolve this issue would be greatly appreciated??? +Installing pyodbc... +Processing ./pyodbc-3.0.10.tar.gz +Installing collected packages: pyodbc + Running setup.py install for pyodbc ... error + Complete output from command /opt/rh/python27/root/usr/bin/python -u -c ""import setuptools, tokenize;file='/tmp/pip-JAGZDD-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))"" install --record /tmp/pip-QJasL0-record/install-record.txt --single-version-externally-managed --compile: + running install + running build + running build_ext + building 'pyodbc' extension + creating build + creating build/temp.linux-x86_64-2.7 + creating build/temp.linux-x86_64-2.7/tmp + creating build/temp.linux-x86_64-2.7/tmp/pip-JAGZDD-build + creating build/temp.linux-x86_64-2.7/tmp/pip-JAGZDD-build/src + gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -DPYODBC_VERSION=3.0.10 -DPYODBC_UNICODE_WIDTH=4 -DSQL_WCHART_CONVERT=1 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include -I/opt/rh/python27/root/usr/include/python2.7 -c /tmp/pip-JAGZDD-build/src/cnxninfo.cpp -o build/temp.linux-x86_64-2.7/tmp/pip-JAGZDD-build/src/cnxninfo.o -Wno-write-strings + In file included from /tmp/pip-JAGZDD-build/src/cnxninfo.cpp:8: + ** +**/tmp/pip-JAGZDD-build/src/pyodbc.h:41:20: error: Python.h: No such file or directory /tmp/pip-JAGZDD-build/src/pyodbc.h:42:25: error: floatobject.h: No such file or directory /tmp/pip-JAGZDD-build/src/pyodbc.h:43:24: error: longobject.h: No such file or directory /tmp/pip-JAGZDD-build/src/pyodbc.h:44:24: error: boolobject.h: No such file or directory /tmp/pip-JAGZDD-build/src/pyodbc.h:45:27: error: unicodeobject.h: No such file or directory /tmp/pip-JAGZDD-build/src/pyodbc.h:46:26: error: structmember.h: No such file or directory +** + In file included from /tmp/pip-JAGZDD-build/src/pyodbc.h:137, + from /tmp/pip-JAGZDD-build/src/cnxninfo.cpp:8: + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:61:28: error: stringobject.h: No such file or directory + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:62:25: error: intobject.h: No such file or directory + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:63:28: error: bufferobject.h: No such file or directory + In file included from /tmp/pip-JAGZDD-build/src/cnxninfo.cpp:8: + /tmp/pip-JAGZDD-build/src/pyodbc.h: In function ‘void _strlwr(char*)’: + /tmp/pip-JAGZDD-build/src/pyodbc.h:92: error: ‘tolower’ was not declared in this scope + In file included from /tmp/pip-JAGZDD-build/src/pyodbc.h:137, + from /tmp/pip-JAGZDD-build/src/cnxninfo.cpp:8: + /tmp/pip-JAGZDD-build/src/pyodbccompat.h: At global scope: + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:71: error: expected initializer before ‘*’ token + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:81: error: ‘Text_Buffer’ declared as an ‘inline’ variable + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:81: error: ‘PyObject’ was not declared in this scope + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:81: error: ‘o’ was not declared in this scope + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:82: error: expected ‘,’ or ‘;’ before ‘{’ token + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:93: error: ‘Text_Check’ declared as an ‘inline’ variable + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:93: error: ‘PyObject’ was not declared in this scope + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:93: error: ‘o’ was not declared in this scope + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:94: error: expected ‘,’ or ‘;’ before ‘{’ token + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:104: error: ‘PyObject’ was not declared in this scope + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:104: error: ‘lhs’ was not declared in this scope + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:104: error: expected primary-expression before ‘const’ + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:104: error: initializer expression list treated as compound expression + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:109: error: ‘Text_Size’ declared as an ‘inline’ variable + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:109: error: ‘PyObject’ was not declared in this scope + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:109: error: ‘o’ was not declared in this scope + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:110: error: expected ‘,’ or ‘;’ before ‘{’ token + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:118: error: ‘TextCopyToUnicode’ declared as an ‘inline’ variable + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:118: error: ‘Py_UNICODE’ was not declared in this scope + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:118: error: ‘buffer’ was not declared in this scope + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:118: error: ‘PyObject’ was not declared in this scope + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:118: error: ‘o’ was not declared in this scope + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:118: error: initializer expression list treated as compound expression + /tmp/pip-JAGZDD-build/src/pyodbccompat.h:119: error: expected ‘,’ or ‘;’ before ‘{’ token + error: command 'gcc' failed with exit status 1",The resolution was to re-install Python2.7,0.0,False,1,5462 +2018-04-18 21:14:22.503,Count number of nodes per level in a binary tree,"I've been searching for a bit now and haven't been able to find anything similar to my question. Maybe i'm just not searching correctly. Anyways this is a question from my exam review. Given a binary tree, I need to output a list such that each item in the list is the number of nodes on a level in a binary tree at the items list index. What I mean, lst = [1,2,1] and the 0th index is the 0th level in the tree and the 1 is how many nodes are in that level. lst[1] will represent the number of nodes (2) in that binary tree at level 1. The tree isn't guaranteed to be balanced. We've only been taught preorder,inorder and postorder traversals, and I don't see how they would be useful in this question. I'm not asking for specific code, just an idea on how I could figure this out or the logic behind it. Any help is appreciated.","The search ordering doesn't really matter as long as you only count each node once. A depth-first search solution with recursion would be: + +Create a map counters to store a counter for each level. E.g. counters[i] is the number of nodes found so far at level i. Let's say level 0 is the root. +Define a recursive function count_subtree(node, level): Increment counters[level] once. Then for each child of the given node, call count_subtree(child, level + 1) (the child is at a 1-deeper level). +Call count_subtree(root_node, 0) to count starting at the root. This will result in count_subtree being run exactly once on each node because each node only has one parent, so counters[level] will be incremented once per node. A leaf node is the base case (no children to call the recursive function on). +Build your final list from the values of counters, ordered by their keys ascending. + +This would work with any kind of tree, not just binary. Running time is O(number of nodes in tree). Side note: The depth-first search solution would be easier to divide and run on parallel processors or machines than a similar breadth-first search solution.",0.3869120172231254,False,1,5463 +2018-04-19 08:06:38.817,Going back to previous line in Spyder,"I am using the Spyder editor and I have to go back and forth from the piece of code that I am writing to the definition of the functions I am calling. I am looking for shortcuts to move given this issue. I know how to go to the function definition (using Ctrl + g), but I don't know how to go back to the piece of code that I am writing. Is there an easy way to do this?","(Spyder maintainer here) You can use the shortcuts Ctrl+Alt+Left and Ctrl+Alt+Right to move to the previous/next cursor position, respectively.",1.2,True,1,5464 +2018-04-19 12:15:18.167,clean up python versions mac osx,"I tried to run a python script on my mac computer, but I ended up in troubles as it needed to install pandas as a dependency. +I tried to get this dependency, but to do so I installed different components like brew, pip, wget and others including different versions of python using brew, .pkg package downloaded from python.org. +In the end, I was not able to run the script anyway. +Now I would like to sort out the things and have only one version of python (3 probably) working correctly. +Can you suggest me the way how to get the overview what I have installed on my computer and how can I clean it up? +Thank you in advance","Use brew list to see what you've installed with Brew. And Brew Uninstall as needed. Likewise, review the logs from wget to see where it installed things. Keep in mind that MacOS uses Python 2.7 for system critical tasks; it's baked-into the OS so don't touch it. +Anything you installed with pip is saved to the /site-packages directory of the Python version in which you installed it so it will disappear when you remove that version of Python. +The .pkg files installed directly into your Applications folder and can be deleted safely like any normal app.",0.999329299739067,False,1,5465 +2018-04-19 20:49:21.823,Python/Flask: only one user can call a endpoint at one time,"I have a API build using Python/Flask, and I have a endpoint called /build-task that called by the system, and this endpoint takes about 30 minutes to run. +My question is that how do I lock the /build-task endpoint when it's started and running already? So so other user, or system CANNOT call this endpoint.","You have some approaches for this problem: +1 - You can create a session object, save a flag in the object and check if the endpoint is already running and respond accordingly. +2 - Flag on the database, check if the endpoint is already running and respond accordingly.",0.3869120172231254,False,1,5466 +2018-04-19 22:13:32.410,"After delay() is called on a celery task, it takes more than 5 to 10 seconds for the tasks to even start executing with redis as the server","I have Redis as my Cache Server. When I call delay() on a task,it takes more than 10 tasks to even start executing. Any idea how to reduce this unnecessary lag? +Should I replace Redis with RabbitMQ?","It's very difficult to say what the cause of the delay is without being able to inspect your application and server logs, but I can reassure you that the delay is not normal and not an effect specific to either Celery or using Redis as the broker. I've used this combination a lot in the past and execution of tasks happens in a number of milliseconds. +I'd start by ensuring there are no network related issues between your client creating the tasks, your broker (Redis) and your task consumers (celery workers). +Good luck!",1.2,True,1,5467 +2018-04-21 12:34:46.780,add +1 hour to datetime.time() django on forloop,"I have code like this, I want to check in the time range that has overtime and sum it. +currently, am trying out.hour+1 with this code, but didn't work. + + + overtime_all = 5 + overtime_total_hours = 0 + out = datetime.time(14, 30) + + while overtime_all > 0: + overtime200 = object.filter(time__range=(out, out.hour+1)).count() + overtime_total_hours = overtime_total_hours + overtime200 + overtime_all -=1 + + print overtime_total_hours + + +how to add 1 hour every loop?...","I found the solution now, and this is work. + + + overtime_all = 5 + overtime_total_hours = 0 + out = datetime.time(14, 30) + + while overtime_all > 0: + overtime200 = object.filter(time__range=(out,datetime.time(out.hour+1, 30))).count() + overtime_total_hours = overtime_total_hours + overtime200 + overtime_all -=1 + + print overtime_total_hours + +i do change out.hour+1 to datetime.time(out.hour+1, 30) its work fine now, but i dont know maybe there more compact/best solution. +thank you guys for your answer.",0.2012947653214861,False,2,5468 +2018-04-21 12:34:46.780,add +1 hour to datetime.time() django on forloop,"I have code like this, I want to check in the time range that has overtime and sum it. +currently, am trying out.hour+1 with this code, but didn't work. + + + overtime_all = 5 + overtime_total_hours = 0 + out = datetime.time(14, 30) + + while overtime_all > 0: + overtime200 = object.filter(time__range=(out, out.hour+1)).count() + overtime_total_hours = overtime_total_hours + overtime200 + overtime_all -=1 + + print overtime_total_hours + + +how to add 1 hour every loop?...","Timedelta (from datetime) can be used to increment or decrement a datatime objects. Unfortunately, it cannot be directly combined with datetime.time objects. +If the values that are stored in your time column are datetime objects, you can use them (e.g.: my_datetime + timedelta(hours=1)). If they are time objects, you'll need to think if they represent a moment in time (in that case, they should be converted to datetime objects) or a duration (in that case, it's probably easier to store it as an integer representing the total amount of minutes, and to perform all operations on integers).",1.2,True,2,5468 +2018-04-22 02:32:28.877,k-means clustering multi column data in python,"I Have data-set for which consist 2000 lines in a text file. +Each line represents x,y,z (3D coordinates location) of 20 skeleton joint points of human body (eg: head, shoulder center, shoulder left, shoulder right,......, elbow left, elbow right). I want to do k-means clustering of this data. +Data is separated by 'spaces ', each joint is represented by 3 values (Which represents x,y,z coordinates). Like head and shoulder center represented by +.0255... .01556600 1.3000... .0243333 .010000 .1.3102000 .... +So basically I have 60 columns in each row, which which represents 20 joints and each joins consist of three points. +My question is how do I format or use this data for k-means clustering,","You don't need to reformat anything. +Each row is a 60 dimensional vector of continous values with a comparable scale (coordinates), as needed for k-means. +You can just run k-means on this. +But assuming that the measurements were taken in sequence, you may observe a strong correlation between rows, so I wouldn't expect the data to cluster extremely well, unless you set up the use to do and hold certain poses.",1.2,True,1,5469 +2018-04-22 11:28:39.070,How to get the quantity of products in specified date in odoo 10,"I want to create table in odoo 10 with the following columns: quantity_in_the_first_day_of_month,input_quantity,output_quantity,quantity_in_the_last_day_of_the_month. +but i don't know how to get the quantity of the specified date","You can join the sale order and sale order line to get specified date. +select + sum(sol.product_uom_qty) +from + sale_order s,sale_order_line sol +where + sol.order_id=s.id and + DATE(s.date_order) = '2018-01-01'",0.0,False,1,5470 +2018-04-24 04:53:51.450,How do CPU cores get allocated to python processes in multiprocessing?,"Let's say I am running multiple python processes(not threads) on a multi core CPU (say 4). GIL is process level so GIL within a particular process won't affect other processes. +My question here is if the GIL within one process will take hold of only single core out of 4 cores or will it take hold of all 4 cores? +If one process locks all cores at once, then multiprocessing should not be any better than multi threading in python. If not how do the cores get allocated to various processes? + +As an observation, in my system which is 8 cores (4*2 because of + hyperthreading), when I run a single CPU bound process, the CPU usage + of 4 out of 8 cores goes up. + +Simplifying this: +4 python threads (in one process) running on a 4 core CPU will take more time than single thread doing same work (considering the work is fully CPU bound). Will 4 different process doing that amount of work reduce the time taken by a factor of near 4?",Process to CPU/CPU core allocation is handled by the Operating System.,0.0,False,1,5471 +2018-04-24 13:49:41.587,"How to read back the ""random-seed"" from a saved model of Dynet","I have a model already trained by dynet library. But i forget the --dynet-seed parameter when training this model. +Does anyone know how to read back this parameter from the saved model? +Thank you in advance for any feedback.","You can't read back the seed parameter. Dynet model does not save the seed parameter. The obvious reason is, it is not required at testing time. Seed is only used to set fixed initial weights, random shuffling etc. for different experimental runs. At testing time no parameter initialisation or shuffling is required. So, no need to save seed parameter. +To the best of my knowledge, none of the other libraries like tensorflow, pytorch etc. save the seed parameter as well.",1.2,True,1,5472 +2018-04-24 20:57:16.490,Django/Python - Serial line concurrency,"I'm currently working on gateway with an embedded Linux and a Webserver. The goal of the gateway is to retrieve data from electrical devices through a RS485/Modbus line, and to display them on a server. +I'm using Nginx and Django, and the web front-end is delivered by ""static"" files. Repeatedly, a Javascript script file makes AJAX calls that send CGI requests to Nginx. These CGI requests are answered with JSON responses thanks to Django. The responses are mostly data that as been read on the appropriate Modbus device. +The exact path is the following : +Randomly timed CGI call -> urls.py -> ModbusCGI.py (import an other script ModbusComm.py)-> ModbusComm.py create a Modbus client and instantly try to read with it. +Next to that, I wanted to implement a Datalogger, to store data in a DB at regular intervals. I made a script that also import the ModbusComm.py script, but it doesn't work : sometime multiple Modbus frames are sent at the same time (datalogger and cgi scripts call the same function in ModbusComm.py ""files"" at the same time) which results in an error. +I'm sure this problem would also occur if there are a lot of users on the server (CGI requests sent at the same time). Or not ? (queue system already managed for CGI requests? I'm a bit lost) +So my goal would be to make a queue system that could handle calls from several python scripts => make them wait while it's not their turn => call a function with the right arguments when it's their turn (actually using the modbus line), and send back the response to the python script so it can generate the JSON response. +I really don't know how to achieve that, and I'm sure there are better way to do this. +If I'm not clear enough, don't hesitate to make me aware of it :)","I had the same problem when I had to allow multiple processes to read some Modbus (and not only Modbus) data through a serial port. I ended up with a standalone process (“serial port server”) that exclusively works with a serial port. All other processes work with that port through that standalone process via some inter processes communication mechanism (we used Unix sockets). +This way when an application wants to read a Modbus register it connects to the “serial port server”, sends its request and receives the response. All the actual serial port communication is done by the “serial port server” in sequential way to ensure consistency.",0.0,False,1,5473 +2018-04-24 22:23:26.923,Make Python 3 default on Mac OS?,"I would like to ask if it is possible to make Python 3 a default interpreter on Mac OS 10 when typing python right away from the terminal? If so, can somebody help how to do it? I'm avoiding switching between the environments. +Cheers","You can do that by changing alias, typing in something like $ alias python=python3 in the terminal. +If you want the change to persist open ~/.bash_profile using nano and then add alias python=python3. CTRL+O to save and CTRL+X to close. +Then type $ source ~./bash_profile in the terminal.",0.2012947653214861,False,1,5474 +2018-04-25 00:38:39.330,can't import more than 50 contacts from csv file to telegram using Python3,"Trying to Import 200 contacts from CSV file to telegram using Python3 Code. It's working with first 50 contacts and then stop and showing below: +telethon.errors.rpc_error_list.FloodWaitError: A wait of 101 seconds is required +Any idea how I can import all list without waiting?? Thanks!!","You can not import a large number of people in sequential. ُThe telegram finds you're sperm. +As a result, you must use ‍sleep between your requests",0.0,False,1,5475 +2018-04-25 07:54:39.583,Grouping tests in pytest: Classes vs plain functions,"I'm using pytest to test my app. +pytest supports 2 approaches (that I'm aware of) of how to write tests: + +In classes: + + +test_feature.py -> class TestFeature -> def test_feature_sanity + + +In functions: + + +test_feature.py -> def test_feature_sanity + +Is the approach of grouping tests in a class needed? Is it allowed to backport unittest builtin module? +Which approach would you say is better and why?","Typically in unit testing, the object of our tests is a single function. That is, a single function gives rise to multiple tests. In reading through test code, it's useful to have tests for a single unit be grouped together in some way (which also allows us to e.g. run all tests for a specific function), so this leaves us with two options: + +Put all tests for each function in a dedicated module +Put all tests for each function in a class + +In the first approach we would still be interested in grouping all tests related to a source module (e.g. utils.py) in some way. Now, since we are already using modules to group tests for a function, this means that we should like to use a package to group tests for a source module. +The result is one source function maps to one test module, and one source module maps to one test package. +In the second approach, we would instead have one source function map to one test class (e.g. my_function() -> TestMyFunction), and one source module map to one test module (e.g. utils.py -> test_utils.py). +It depends on the situation, perhaps, but the second approach, i.e. a class of tests for each function you are testing, seems more clear to me. Additionally, if we are testing source classes/methods, then we could simply use an inheritance hierarchy of test classes, and still retain the one source module -> one test module mapping. +Finally, another benefit to either approach over just a flat file containing tests for multiple functions, is that with classes/modules already identifying which function is being tested, you can have better names for the actual tests, e.g. test_does_x and test_handles_y instead of test_my_function_does_x and test_my_function_handles_y.",0.9999092042625952,False,2,5476 +2018-04-25 07:54:39.583,Grouping tests in pytest: Classes vs plain functions,"I'm using pytest to test my app. +pytest supports 2 approaches (that I'm aware of) of how to write tests: + +In classes: + + +test_feature.py -> class TestFeature -> def test_feature_sanity + + +In functions: + + +test_feature.py -> def test_feature_sanity + +Is the approach of grouping tests in a class needed? Is it allowed to backport unittest builtin module? +Which approach would you say is better and why?","There are no strict rules regarding organizing tests into modules vs classes. It is a matter of personal preference. Initially I tried organizing tests into classes, after some time I realized I had no use for another level of organization. Nowadays I just collect test functions into modules (files). +I could see a valid use case when some tests could be logically organized into same file, but still have additional level of organization into classes (for instance to make use of class scoped fixture). But this can also be done just splitting into multiple modules.",1.2,True,2,5476 +2018-04-25 08:16:18.483,How to calculate a 95 credible region for a 2D joint distribution?,"Suppose we have a joint distribution p(x_1,x_2), and we know x_1,x_2,p. Both are discrete, (x_1,x_2) is scatter, its contour could be drawn, marginal as well. I would like to show the area of 95% quantile (a scale of 95% data will be contained) of the joint distribution, how can I do that?","As the other points out, there are infinitely many solutions to this problem. A practical one is to find the approximate center of the point cloud and extend a circle from there until it contains approximately 95% of the data. Then, find the convex hull of the selected points and compute its area. +Of course, this will only work if the data is sort of concentrated in a single area. This won't work if there are several clusters.",0.2012947653214861,False,2,5477 +2018-04-25 08:16:18.483,How to calculate a 95 credible region for a 2D joint distribution?,"Suppose we have a joint distribution p(x_1,x_2), and we know x_1,x_2,p. Both are discrete, (x_1,x_2) is scatter, its contour could be drawn, marginal as well. I would like to show the area of 95% quantile (a scale of 95% data will be contained) of the joint distribution, how can I do that?","If you are interested in finding a pair x_1, x_2 of real numbers such that +P(X_1<=x_1, X_2<=x_2) = 0.95 and your distribution is continuous then there will be infinitely many of these pairs. You might be better of just fixing one of them and then finding the other",0.0,False,2,5477 +2018-04-25 12:20:28.077,queires and advanced operations in influxdb,"Recently started working on influxDB, can't find how to add new measurements or make a table of data from separate measurements, like in SQL we have to join table or so. +The influxdb docs aren't that clear. I'm currently using the terminal for everything and wouldn't mind switching to python but most of it is about HTTP post schemes in the docs, is there any other alternative? +I would prefer influxDB in python if the community support is good","The InfluxDB query language does not support joins across measurements. +It instead needs to be done client side after querying data. Querying, without join, data from multiple measurements can be done with one query.",1.2,True,1,5478 +2018-04-26 22:40:24.603,Run external python file with Mininet,"I try to write a defense system by using mininet + pox. +I have l3_edited file to calculate entropy. I understand when a host attacked. +I have my myTopo.py file that create a topo with Mininet. +Now my question: +I want to change hosts' ips when l3_edited detect an attack. Where should I do it? +I believe I should write program and run it in mininet. (not like custom topo but run it after create mininet, in command line). If it's true, how can I get hosts' objest? If I can get it, I can change their IPs. +Or should I do it on my myTopo.py ??? Then, how can I run my defense code, when I detect an attack?","If someone looking for answer... +You can use your custom topology file to do other task. Multithread solved my problem.",1.2,True,1,5479 +2018-04-27 12:58:39.440,Select columns periodically on pandas DataFrame,"I'm working on a Dataframe with 1116 columns, how could I select just the columns in a period of 17 ? +More clearly select the 12th, 29th,46th,63rd... columns","df.iloc[:,[i*17 for i in range(0,65)]]",0.0,False,1,5480 +2018-04-27 15:23:38.983,How to create different Python Wheel distributions for Ubuntu and RedHat,"I have a Cython-based package which depends on other C++ SO libraries. Those libraries are binary different between Ubuntu (dev) and RedHat (prod). So the SO file generated by Cython has to be different as well. If I use Wheel to package it the file name is same for both environments: +package-version-cp27-cp27mu-linux_x86_64.whl +So if I upload it to pypi it will conflict with RedHat based distribution of the same package. I have to upload it to pypi because the project is then PEX-ed (via Pants) and PEX tries to download from pypi and fails if it does not find it with the following exception. +Exception caught: 'pex.resolver.Unsatisfiable' +Any ideas how to resolve it? +Thx.","I found a solution by using a different PyPi instance. So our DEV Ubuntu environment and PROD RedHat just use two different PyPi sources. +To do that I had to make two configurations ~/.pypic and ~/.pip/pip.conf to upload.",0.0,False,1,5481 +2018-04-28 20:06:07.330,Why use zappa/chalice in serverless python apps?,"I am new to python and thought it would be great to have my very first python project running on AWS infrastructure. Given my previous node.js experience with lambdas, I thought that every function would have its own code and the app is only glued together by the persistence layer, everything else are decoupled separate functions. +In Python lambdas there are serverless microframeworks like Chalice or Zappa that seem to be an accepted practice. For me though it feels like they are hacking around the concept of serverless approach. You still have a full-blown app build on let's say Flask, or even Django, and that app is served through lambda. There is still one application that has all the routing, configs, boilerplate code, etc instead of small independent functions that just do their job. I currently do not see how and if this makes like any easier. + +What is the benefit / reason for having the whole code base served through lambdas as opposed to individual functions? +Is there an execution time penalty if using flask/django/whatever else with serverless apps? +If this depends on the particular project, what would be the guidance when to use framework, and when to use individual functions?","Benefits. You can use known concept, and adopt it in serverless. +Performance. The smaller code is the less ram it takes. It must be loaded, processed, and so on. Just to process single request? For me that was always too much. +Let's say you have diango project, that is working on elastic beanstalk, and you need some lamdas to deal with limited problems. Now. Do you want to have two separate configurations? What about common functions? + +Serverless looks nice, but... let's assume that you have permissions, so your app, for every call will pull that stuff. Perhaps you have it cached - in redis, as a hole permissions for user... Other option is dynamodb, which is even more expensive. Yes there is nice SLA, but API is quite strange, also if you plan keeping more data there... the more data you have the slower it work - for same money. In other words - if you put more data, fetching will cost more - if you want same speed.",0.0,False,1,5482 +2018-04-29 13:47:46.340,How to preprocess audio data for input into a Neural Network,"I'm currently developing a keyword-spotting system that recognizes digits from 0 to 9 using deep neural networks. I have a dataset of people saying the numbers(namely the TIDIGITS dataset, collected at Texas Instruments, Inc), however the data is not prepared to be fed into a neural network, because not all the audio data have the same audio length, plus some of the files contain several digits being spoken in sequence, like ""one two three"". +Can anyone tell me how would I transform these wav files into 1 second wav files containing only the sound of one digit? Is there any way to automatically do this? Preparing the audio files individually would be time expensive. +Thank you in advance!","I would split each wav by the areas of silence. Trim the silence from beginning and end. Then I'd run each one through a FFT for different sections. Smaller ones at the beginning of the sound. Then I'd normalise the frequencies against the fundamental. Then I'd feed the results into the NN as a 3d array of volumes, frequencies and times.",0.2012947653214861,False,1,5483 +2018-04-29 20:58:03.330,How would i generate a random number in python without duplicating numbers,"I was wondering how to generate a random 4 digit number that has no duplicates in python 3.6 +I could generate 0000-9999 but that would give me a number with a duplicate like 3445, Anyone have any ideas +thanks in advance","Generate a random number +check if there are any duplicates, if so go back to 1 +you have a number with no duplicates + +OR +Generate it one digit at a time from a list, removing the digit from the list at each iteration. + +Generate a list with numbers 0 to 9 in it. +Create two variables, the result holding value 0, and multiplier holding 1. +Remove a random element from the list, multiply it by the multiplier variable, add it to the result. +multiply the multiplier by 10 +go to step 3 and repeat for the next digit (up to the desired digits) +you now have a random number with no repeats.",-0.3869120172231254,False,1,5484 +2018-04-30 15:12:36.730,Keras Neural Network. Preprocessing,"I have this doubt when I fit a neural network in a regression problem. I preprocessed the predictors (features) of my train and test data using the methods of Imputers and Scale from sklearn.preprocessing,but I did not preprocessed the class or target of my train data or test data. +In the architecture of my neural network all the layers has relu as activation function except the last layer that has the sigmoid function. I have choosen the sigmoid function for the last layer because the values of the predictions are between 0 and 1. +tl;dr: In summary, my question is: should I deprocess the output of my neuralnet? If I don't use the sigmoid function, the values of my output are < 0 and > 1. In this case, how should I do it? +Thanks","Usually, if you are doing regression you should use a linear' activation in the last layer. A sigmoid function will 'favor' values closer to 0 and 1, so it would be harder for your model to output intermediate values. +If the distribution of your targets is gaussian or uniform I would go with a linear output layer. De-processing shouldn't be necessary unless you have very large targets.",0.0,False,1,5485 +2018-05-01 02:43:55.537,How to calculate the HMAC(hsa256) of a text using a public certificate (.pem) as key,"I'm working on Json Web Tokens and wanted to reproduce it using python, but I'm struggling on how to calculate the HMAC_SHA256 of the texts using a public certificate (pem file) as a key. +Does anyone know how I can accomplish that!? +Tks","In case any one found this question. The answer provided by the host works, but the idea is wrong. You don't use any RSA keys with HMAC method. The RSA key pair (public and private) are used for asymmetric algorithm while HMAC is symmetric algorithm. +In HMAC, the two sides of the communication keep the same secret text(bytes) as the key. It can be a public_cert.pem as long as you keep it secretly. But a public.pem is usually shared publicly, which makes it unsafe.",0.3869120172231254,False,1,5486 +2018-05-01 05:40:22.107,How to auto scale in JES,"I'm coding watermarking images in JES and I was wondering how to Watermark a picture by automatically scaling a watermark image? +If anyone can help me that would be great. +Thanks.","Ill start by giving you a quote from the INFT1004 assignment you are asking for help with. +""In particular, you should try not to use code or algorithms from external sources, and not to obtain help from people other than your instructors, as this can prevent you from mastering these concepts"" +It specifically says in this assignment that you should not ask people online or use code you find or request online, and is a breach of the University of Newcastle academic integrity code - you know the thing you did a module on before you started the course. A copy of this post will be sent along to the course instructor.",0.0,False,1,5487 +2018-05-01 13:33:54.250,Multi-label classification methods for large dataset,"I realize there's another question with a similar title, but my dataset is very different. +I have nearly 40 million rows and about 3 thousand labels. Running a simply sklearn train_test_split takes nearly 20 minutes. +I initially was using multi-class classification models as that's all I had experience with, and realized that since I needed to come up with all the possible labels a particular record could be tied to, I should be using a multi-label classification method. +I'm looking for recommendations on how to do this efficiently. I tried binary relevance, which took nearly 4 hours to train. Classifier chains errored out with a memory error after 22 hours. I'm afraid to try a label powerset as I've read they don't work well with a ton of data. Lastly, I've got adapted algorithm, MlkNN and then ensemble approaches (which I'm also worried about performance wise). +Does anyone else have experience with this type of problem and volume of data? In addition to suggested models, I'm also hoping for advice on best training methods, like train_test_split ratios or different/better methods.","20 minutes for this size of a job doesn't seem that long, neither does 4 hours for training. +I would really try vowpal wabbit. It excels at this sort of multilabel problem and will probably give unmatched performance if that's what you're after. It requires significant tuning and will still require quality training data, but it's well worth it. This is essentially just a binary classification problem. An ensemble will of course take longer so consider whether or not it's necessary given your accuracy requirements.",1.2,True,1,5488 +2018-05-01 20:23:34.880,PULP: Check variable setting against constraints,"I'm looking to set up a constraint-check in Python using PULP. Suppose I had variables A1,..,Xn and a constraint (AffineExpression) A1X1 + ... + AnXn <= B, where A1,..,An and B are all constants. +Given an assignment for X (e.g. X1=1, X2=4,...Xn=2), how can I check if the constraints are satisfied? I know how to do this with matrices using Numpy, but wondering if it's possible to do using PULP to let the library handle the work. +My hope here is that I can check specific variable assignments. I do not want to run an optimization algorithm on the problem (e.g. prob.solve()). +Can PULP do this? Is there a different Python library that would be better? I've thought about Google's OR-Tools but have found the documentation is a little bit harder to parse through than PULP's.","It looks like this is possible doing the following: + +Define PULP variables and constraints and add them to an LpProblem +Make a dictionary of your assignments in the form {'variable name': value} +Use LpProblem.assignVarsVals(your_assignment_dict) to assign those values +Run LpProblem.valid() to check that your assignment meets all constraints and variable restrictions + +Note that this will almost certainly be slower than using numpy and Ax <= b. Formulating the problem might be easier, but performance will suffer due to how PULP runs these checks.",1.2,True,1,5489 +2018-05-02 15:18:32.357,How to find if there are wrong values in a pandas dataframe?,"I am quite new in Python coding, and I am dealing with a big dataframe for my internship. +I had an issue as sometimes there are wrong values in my dataframe. For example I find string type values (""broken leaf"") instead of integer type values as (""120 cm"") or (NaN). +I know there is the df.replace() function, but therefore you need to know that there are wrong values. So how do I find if there are any wrong values inside my dataframe? +Thank you in advance","""120 cm"" is a string, not an integer, so that's a confusing example. Some ways to find ""unexpected"" values include: +Use ""describe"" to examine the range of numerical values, to see if there are any far outside of your expected range. +Use ""unique"" to see the set of all values for cases where you expect a small number of permitted values, like a gender field. +Look at the datatypes of columns to see whether there are strings creeping in to fields that are supposed to be numerical. +Use regexps if valid values for a particular column follow a predictable pattern.",0.0,False,1,5490 +2018-05-03 09:34:04.367,Read raw ethernet packet using python on Raspberry,"I have a device which is sending packet with its own specific construction (header, data, crc) through its ethernet port. +What I would like to do is to communicate with this device using a Raspberry and Python 3.x. +I am already able to send Raw ethernet packet using the ""socket"" Library, I've checked with wireshark on my computer and everything seems to be transmitted as expected. +But now I would like to read incoming raw packet sent by the device and store it somewhere on my RPI to use it later. +I don't know how to use the ""socket"" Library to read raw packet (I mean layer 2 packet), I only find tutorials to read higher level packet like TCP/IP. +What I would like to do is Something similar to what wireshark does on my computer, that is to say read all raw packet going through the ethernet port. +Thanks, +Alban","Did you try using ettercap package (ettercap-graphical)? +It should be available with apt. +Alternatively you can try using TCPDump (Java tool) or even check ip tables",0.0,False,1,5491 +2018-05-04 02:07:04.457,Host command and ifconfig giving different ips,"I am using server(server_name.corp.com) inside a corporate company. On the server i am running a flask server to listen on 0.0.0.0:5000. +servers are not exposed to outside world but accessible via vpns. +Now when i run host server_name.corp.com in the box i get some ip1(10.*.*.*) +When i run ifconfig in the box it gives me ip2(10.*.*.*). +Also if i run ping server_name.corp.com in same box i get ip2. +Also i can ssh into server with ip1 not ip2 +I am able to access the flask server at ip1:5000 but not on ip2:5000. +I am not into networking so fully confused on why there are 2 different ips and why i can access ip1:5000 from browser not ip2:5000. +Also what is equivalent of host command in python ( how to get ip1 from python. I am using socktet.gethostbyname(server_name.corp.com) which gives me ip2)","Not quite clear about the network status by your statements, I can only tell that if you want to get ip1 by python, you could use standard lib subprocess, which usually be used to execute os command. (See subprocess.Popen)",0.0,False,1,5492 +2018-05-05 02:23:02.700,how to use python to check if subdomain exists?,"Does anyone know how to check if a subdomain exists on a website? +I am doing a sign up form and everyone gets there own subdomain, I have some javascript written on the front end but I need to find a way to check on the backend.","Do a curl or http request on subdomain which you want to verify, if you get 404 that means it doesn't exists, if you get 200 it definitely exists",0.2012947653214861,False,2,5493 +2018-05-05 02:23:02.700,how to use python to check if subdomain exists?,"Does anyone know how to check if a subdomain exists on a website? +I am doing a sign up form and everyone gets there own subdomain, I have some javascript written on the front end but I need to find a way to check on the backend.","Put the assigned subdomain in a database table within unique indexed column. It will be easier to check from python (sqlalchemy, pymysql ect...) if subdomain has already been used + will automatically prevent duplicates to be assigned/inserted.",0.0,False,2,5493 +2018-05-05 14:24:30.920,How to use visual studio code >after< installing anaconda,"If you have never installed anaconda, it seems to be rather simple. In the installation process of Anaconda, you choose to install visual studio code and that is it. +But I would like some help in my situation: +My objective: I want to use visual studio code with anaconda + +I have a mac with anaconda 1.5.1 installed. +I installed visual studio code. +I updated anaconda (from the terminal) now it is 1.6.9 + +From there, I don't know how to proceed. +any help please","You need to select the correct python interpreter. When you are in a .py file, there's a blue bar in the bottom of the window (if you have the dark theme), there you can select the anaconda python interpreter. +Else you can open the command window with ctrl+p or command+p and type '>' for running vscode commands and search '> Python Interpreter'. +If you don't see anaconda there google how to add a new python interpreter to vscode",0.3869120172231254,False,1,5494 +2018-05-05 16:40:27.703,Calling Python scripts from Java. Should I use Docker?,"We have a Java application in our project and what we want is to call some Python script and return results from it. What is the best way to do this? +We want to isolate Python execution to avoid affecting Java application at all. Probably, Dockerizing Python is the best solution. I don't know any other way. +Then, a question is how to call it from Java. +As far as I understand there are several ways: + +start some web-server inside Docker which accepts REST calls from Java App and runs Python scripts and returns results to Java via REST too. +handle request and response via Docker CLI somehow. +use Java Docker API to send REST request to Docker which then converted by Docker to Stdin/Stdout of Python script inside Docker. + +What is the most effective and correct way to connect Java App with Python, running inside Docker?","You don’t need docker for this. There are a couple of options, you should choose depending on what your Java application is doing. + +If the Java application is a client - based on swing, weblaunch, or providing UI directly - you will want to turn the python functionality to be wrapped in REST/HTTP calls. +If the Java application is a server/webapp - executing within Tomcat, JBoss or other application container - you should simply wrap the python scrip inside a exec call. See the Java Runtime and ProcessBuilder API for this purpose.",1.2,True,1,5495 +2018-05-05 21:56:31.143,Unintuitive solidity contract return values in ethereum python,"I'm playing around with ethereum and python and I'm running into some weird behavior I can't make sense of. I'm having trouble understanding how return values work when calling a contract function with the python w3 client. Here's a minimal example which is confusing me in several different ways: +Contract: + +pragma solidity ^0.4.0; + +contract test { + function test(){ + + } + + function return_true() public returns (bool) { + return true; + } + + function return_address() public returns (address) { + return 0x111111111111111111111111111111111111111; + } +} + +Python unittest code + +from web3 import Web3, EthereumTesterProvider +from solc import compile_source +from web3.contract import ConciseContract +import unittest +import os + + +def get_contract_source(file_name): + with open(file_name) as f: + return f.read() + + +class TestContract(unittest.TestCase): + CONTRACT_FILE_PATH = ""test.sol"" + DEFAULT_PROPOSAL_ADDRESS = ""0x1111111111111111111111111111111111111111"" + + def setUp(self): + # copied from https://github.com/ethereum/web3.py/tree/1802e0f6c7871d921e6c5f6e43db6bf2ef06d8d1 with MIT licence + # has slight modifications to work with this unittest + contract_source_code = get_contract_source(self.CONTRACT_FILE_PATH) + compiled_sol = compile_source(contract_source_code) # Compiled source code + contract_interface = compiled_sol[':test'] + # web3.py instance + self.w3 = Web3(EthereumTesterProvider()) + # Instantiate and deploy contract + self.contract = self.w3.eth.contract(abi=contract_interface['abi'], bytecode=contract_interface['bin']) + # Get transaction hash from deployed contract + tx_hash = self.contract.constructor().transact({'from': self.w3.eth.accounts[0]}) + # Get tx receipt to get contract address + tx_receipt = self.w3.eth.getTransactionReceipt(tx_hash) + self.contract_address = tx_receipt['contractAddress'] + # Contract instance in concise mode + abi = contract_interface['abi'] + self.contract_instance = self.w3.eth.contract(address=self.contract_address, abi=abi, + ContractFactoryClass=ConciseContract) + + def test_return_true_with_gas(self): + # Fails with HexBytes('0xd302f7841b5d7c1b6dcff6fca0cd039666dbd0cba6e8827e72edb4d06bbab38f') != True + self.assertEqual(True, self.contract_instance.return_true(transact={""from"": self.w3.eth.accounts[0]})) + + def test_return_true_no_gas(self): + # passes + self.assertEqual(True, self.contract_instance.return_true()) + + def test_return_address(self): + # fails with AssertionError: '0x1111111111111111111111111111111111111111' != '0x0111111111111111111111111111111111111111' + self.assertEqual(self.DEFAULT_PROPOSAL_ADDRESS, self.contract_instance.return_address()) + +I have three methods performing tests on the functions in the contract. In one of them, a non-True value is returned and instead HexBytes are returned. In another, the contract functions returns an address constant but python sees a different value from what's expected. In yet another case I call the return_true contract function without gas and the True constant is seen by python. + +Why does calling return_true with transact={""from"": self.w3.eth.accounts[0]} cause the return value of the function to be HexBytes(...)? +Why does the address returned by return_address differ from what I expect? + +I think I have some sort of fundamental misunderstanding of how gas affects function calls.","The returned value is the transaction hash on the blockchain. When transacting (i.e., when using ""transact"" rather than ""call"") the blockchain gets modified, and the library you are using returns the transaction hash. During that process you must have paid ether in order to be able to modify the blockchain. However, operating in read-only mode costs no ether at all, so there is no need to specify gas. +Discounting the ""0x"" at the beginning, ethereum addresses have a length of 40, but in your test you are using a 39-character-long address, so there is a missing a ""1"" there. Meaning, tests are correct, you have an error in your input. + +Offtopic, both return_true and return_address should be marked as view in Solidity, since they are not actually modifying the state. I'm pretty sure you get a warning in remix. Once you do that, there is no need to access both methods using ""transact"" and paying ether, and you can do it using ""call"" for free. +EDIT +Forgot to mention: in case you need to access the transaction hash after using transact you can do so calling the .hex() method on the returned HexBytes object. That'll give you the transaction hash as a string, which is usually way more useful than as a HexBytes. +I hope it helps!",0.6730655149877884,False,1,5496 +2018-05-05 22:40:06.727,Colaboratory: How to install and use on local machine?,"Google Colab is awesome to work with, but I wish I can run Colab Notebooks completely locally and offline, just like Jupyter notebooks served from the local? +How do I do this? Is there a Colab package which I can install? + +EDIT: Some previous answers to the question seem to give methods to access Colab hosted by Google. But that's not what I'm looking for. +My question is how do I pip install colab so I can run it locally like jupyter after pip install jupyter. Colab package doesn't seem to exist, so if I want it, what do I do to install it from the source?","Google Colab is a cloud computer,it only runs through Internet,you can design your Python script,and run the Python script through Colab,run Python will use Google Colab hardware,Google will allocate CPU, RAM, GPU and etc for your Python script,your local computer just submit Python code to Google Colab,and run,then Google Colab return the result to your local computer,cloud computation is stronger than local +computation if your local computer hardware is limited,see this question link will inspire you,asked by me,https://stackoverflow.com/questions/48879495/how-to-apply-googlecolab-stronger-cpu-and-more-ram/48922199#48922199",-0.4961739557460144,False,1,5497 +2018-05-06 09:13:56.887,Predicting binary classification,"I have been self-learning machine learning lately, and I am now trying to solve a binary classification problem (i.e: one label which can either be true or false). I was representing this as a single column which can be 1 or 0 (true or false). +Nonetheless, I was researching and read about how categorical variables can reduce the effectiveness of an algorithm, and how one should one-hot encode them or translate into a dummy variable thus ending with 2 labels (variable_true, variable_false). +Which is the correct way to go about this? Should one predict a single variable with two possible values or 2 simultaneous variables with a fixed unique value? +As an example, let's say we want to predict whether a person is a male or female: +Should we have a single label Gender and predict 1 or 0 for that variable, or Gender_Male and Gender_Female?","it's basically the same, when talking about binary classification, you can think of a final layer for each model that adapt the output to other model +e.g if the model output 0 or 1 than the final layer will translate it to vector like [1,0] or [0,1] and vise-versa by a threshold criteria, usually is >= 0.5 +a nice byproduct of 2 nodes in the final layer is the confidence level of the model in it's predictions [0.80, 0.20] and [0.55, 0.45] will both yield [1,0] classification but the first prediction has more confidence +this can be also extrapolate from 1 node output by the distance of the output from the fringes 1 and 0 so 0.1 will be considered with more confidence than 0.3 as a 0 prediction",1.2,True,1,5498 +2018-05-06 21:22:33.530,Does gRPC have the ability to add a maximum retry for call?,"I haven't found any examples how to add a retry logic on some rpc call. Does gRPC have the ability to add a maximum retry for call? +If so, is it a built-in function?",Retries are not a feature of gRPC Python at this time.,1.2,True,1,5499 +2018-05-07 02:06:48.980,Tensorflow How can I make a classifier from a CSV file using TensorFlow?,"I need to create a classifier to identify some aphids. +My project has two parts, one with a computer vision (OpenCV), which I already conclude. The second part is with Machine Learning using TensorFlow. But I have no idea how to do it. +I have these data below that have been removed starting from the use of OpenCV, are HuMoments (I believe that is the path I must follow), each line is the HuMoments of an aphid (insect), I have 500 more data lines that I passed to one CSV file. +How can I make a classifier from a CSV file using TensorFlow? + +HuMoments (in CSV file): + 0.27356047,0.04652453,0.00084231,7.79486673,-1.4484489,-1.4727380,-1.3752532 + 0.27455502,0.04913969,3.91102408,1.35705980,3.08570234,2.71530819,-5.0277362 + 0.20708829,0.01563241,3.20141907,9.45211423,1.53559373,1.08038279,-5.8776765 + 0.23454372,0.02820523,5.91665789,6.96682467,1.02919203,7.58756583,-9.7028848","You can start with this tutorial, and try it first without changing anything; I strongly suggest this unless you are already familiar with Tensorflow so that you gain some familiarity with it. +Now you can modify the input layer of this network to match the dimensions of the HuMoments. Next, you can give a numeric label to each type of aphid that you want to recognize, and adjust the size of the output layer to match them. +You can now read the CSV file using python, and remove any text like ""HuMoments"". If your file has names of aphids, remove them and replace them with numerical class labels. Replace the training data of the code in the above link, with these data. +Now you can train the network according to the description under the title ""Train the Model"". +One more note. Unless it is essential to use Tensorflow to match your project requirements, I suggest using Keras. Keras is a higher level library that is much easier to learn than Tensorflow, and you have more sample code online.",0.0,False,1,5500 +2018-05-07 23:22:30.577,How can you fill in an open dialog box in headless chrome in Python and Selenium?,"I'm working with Python and Selenium to do some automation in the office, and I need to fill in an ""upload file"" dialog box (a windows ""open"" dialog box), which was invoked from a site using a headless chrome browser. Does anyone have any idea on how this could be done? +If I wasn't using a headless browser, Pywinauto could be used with a line similar to the following, for example, but this doesn't appear to be an option in headless chrome: +app.pane.open.ComboBox.Edit.type_keys(uploadfilename + ""{ENTER}"") +Thank you in advance!","This turned out to not be possible. I ended up running the code on a VM and setting a registry key to allow automation to be run while the VM was minimized, disconnected, or otherwise not being interacted with by users.",0.0,False,1,5501 +2018-05-08 10:55:31.387,"How to ""compile"" a python script to an ""exe"" file in a way it would be run as background process?","I know how to run a python script as a background process, but is there any way to compile a python script into exe file using pyinstaller or other tools so it could have no console or window ?","If you want to run it in background without ""console and ""window"" you have to run it as a service.",0.0,False,1,5502 +2018-05-08 12:08:02.053,(Django) Running asynchronous server task continously in the background,"I want to let a class run on my server, which contains a connected bluetooth socket and continously checks for incoming data, which can then by interpreted. In principle the class structure would look like this: +Interpreter: +-> connect (initializes the class and starts the loop) +-> loop (runs continously in the background) +-> disconnect (stops the loop) +This class should be initiated at some point and then run continously in the background, from time to time a http request would perhaps need data from the attributes of the class, but it should run on its own. +I don't know how to accomplish this and don't want to get a description on how to do it, but would like to know where I should start, like how this kind of process is called.","Django on its own doesn't support any background processes - everything is request-response cycle based. +I don't know if what you're trying to do even has a dedicated name. But most certainly - it's possible. But don't tie yourself to Django with this solution. +The way I would accomplish this is I'd run a separate Python process, that would be responsible for keeping the connection to the device and upon request return the required data in some way. +The only difficulty you'd have is determining how to communicate with that process from Django. Since, like I said, django is request based, that secondary app could expose some data to your Django app - it could do any of the following: + +Expose a dead-simple HTTP Rest API +Expose an UNIX socket that would just return data immediatelly after connection +Continuously dump data to some file/database/mmap/queue that Django could read",1.2,True,1,5503 +2018-05-08 18:49:32.583,Replace character with a absolute value,"When searching my db all special characters work aside from the ""+"" - it thinks its a space. Looking on the backend which is python, there is no issues with it receiving special chars which I believe it is the frontend which is Javascript +what i need to do is replace ""+"" == ""%2b"". Is there a way for me to use create this so it has this value going forth?","You can use decodeURIComponent('%2b'), or encodeUriComponent('+'); +if you decode the response from the server, you get the + sign- +if you want to replace all ocurrence just place the whole string insde the method and it decodes/encodes the whole string.",1.2,True,1,5504 +2018-05-08 21:02:22.097,How to deal with working on one project on different machines (paths)?,"This is my first time coding a ""project"" (something more than solving exercises in single files). A number of my .py files have variables imported from a specific path. I also have a main ""Run"" file where I import things I've written in other files and execute the project as a whole. +Recently I've started working on this project on several different machines (home, work, laptop etc) and have just started learning how to use GitHub. +My question is, how do I deal with the fact that every time I open up my code on a different machine I need to go around changing all the paths to fit the new machine, and then change them back again when I'm home? I started writing a Run file for each location I work at so that my sys.path commands are ok with that machine, but it doesn't solve the problem of my other modules importing variables from specific paths that vary from machine to machine. Is there a way round this or is the problem in how I'm setting up the project itself? +In an ideal world it would all just work without me having to change something before I run, depending on the machine I'm working on, but I don't know if that's possible. +My current thoughts are whether there is some command I'm not aware of that can set variables inside a .py file from my main Run.py file - that way I can just have a run file for each machine. +Any suggestions are gladly taken! Whatever it is, it must be better than commenting back in the correct file path each time I open it on a different machine!","You should always use relative paths, not static which I assume you have got. +Assuming your in an index file and you need to access images folder, you probably have something like /users/username/project/images/image.png +Instead you want something like ../images/image.png, this tells your index file to go backwards one folder to say the root of the project, then proceed into our images folder etc. +Relative paths mean you create a path from where your file exists, and not an entire path from ground up.",0.0,False,1,5505 +2018-05-10 01:53:40.577,Document similarity in production environment,"We are having n number of documents. Upon submission of new document by user, our goal is to inform him about possible duplication of existing document (just like stackoverflow suggests questions may already have answer). +In our system, new document is uploaded every minute and mostly about the same topic (where there are more chance of duplication). +Our current implementation includes gensim doc2vec model trained on documents (tagged with unique document ids). We infer vector for new document and find most_similar docs (ids) with it. Reason behind choosing doc2vec model is that we wanted to take advantage of semantics to improve results. As far as we know, it does not support online training, so we might have to schedule a cron or something that periodically updates the model. But scheduling cron will be disadvantageous as documents come in a burst. User may upload duplicates while model is not yet trained for new data. Also given huge amount of data, training time will be higher. +So i would like to know how such cases are handled in big companies. Are there any better alternative? or better algorithm for such problem?","You don't have to take the old model down to start training a new model, so despite any training lags, or new-document bursts, you'll always have a live model doing the best it can. +Depending on how much the document space changes over time, you might find retraining to have a negligible benefit. (One good model, built on a large historical record, might remain fine for inferring new vectors indefinitely.) +Note that tuning inference to use more steps (especially for short documents), or a lower starting alpha (more like the training default of 0.025) may give better results. +If word-vectors are available, there is also the ""Word Mover's Distance"" (WMD) calculation of document similarity, which might be ever better at identifying close duplicates. Note, though, it can be quite expensive to calculate – you might want to do it only against a subset of likely candidates, or have to add many parallel processors, to do it in bulk. There's another newer distance metric called 'soft cosine similarity' (available in recent gensim) that's somewhere between simple vector-to-vector cosine-similarity and full WMD in its complexity, that may be worth trying. +To the extent the vocabulary hasn't expanded, you can load an old Doc2Vec model, and continue to train() it – and starting from an already working model may help you achieve similar results with fewer passes. But note: it currently doesn't support learning any new words, and the safest practice is to re-train with a mix of all known examples interleaved. (If you only train on incremental new examples, the model may lose a balanced understanding of the older documents that aren't re-presented.) +(If you chief concern is documents that duplicate exact runs-of-words, rather than just similar fuzzy topics, you might look at mixing-in other techniques, such as breaking a document into a bag-of-character-ngrams, or 'shingleprinting' as in common in plagiarism-detection applications.)",1.2,True,1,5506 +2018-05-10 02:52:36.463,Apache Airflow: Gunicorn Configuration File Not Being Read?,"I'm trying to run Apache Airflow's webserver from a virtualenv on a Redhat machine, with some configuration options from a Gunicorn config file. Gunicorn and Airflow are both installed in the virtualenv. The command airflow webserver starts Airflow's webserver and the Gunicorn server. The config file has options to make sure Gunicorn uses/accepts TLSv1.2 only, as well as a list of ciphers to use. +The Gunicorn config file is gunicorn.py. This file is referenced through an environment variable GUNICORN_CMD_ARGS=""--config=/path/to/gunicorn.py ..."" in .bashrc. This variable also sets a couple of other variables in addition to --config. However, when I run the airflow webserver command, the options in GUNICORN_CMD_ARGS are never applied. +Seeing as how Gunicorn is not called from command line, but instead by Airflow, I'm assuming this is why the GUNICORN_CMD_ARGS environment variable is not read, but I'm not sure and I'm new to both technologies... +TL;DR: +Is there another way to set up Gunicorn to automatically reference a config file, without the GUNICORN_CMD_ARGS environment variable? +Here's what I'm using: + +gunicorn 19.8.1 +apache-airflow 1.9.0 +python 2.7.5","When Gunicorn is called by Airflow, it uses ~\airflow\www\gunicorn_config.py as its config file.",1.2,True,1,5507 +2018-05-10 10:48:13.883,How to make a Python Visualization as service | Integrate with website | specially sagemaker,"I am from R background where we can use Plumber kind tool which provide visualization/graph as Image via end points so we can integrate in our Java application. +Now I want to integrate my Python/Juypter visualization graph with my Java application but not sure how to host it and make it as endpoint. Right now I using AWS sagemaker to host Juypter notebook","Amazon SageMaker is a set of different services for data scientists. You are using the notebook service that is used for developing ML models in an interactive way. The hosting service in SageMaker is creating an endpoint based on a trained model. You can call this endpoint with invoke-endpoint API call for real time inference. +It seems that you are looking for a different type of hosting that is more suitable for serving HTML media rich pages, and doesn’t fit into the hosting model of SageMaker. A combination of EC2 instances, with pre-built AMI or installation scripts, Congnito for authentication, S3 and EBS for object and block storage, and similar building blocks should give you a scalable and cost effective solution.",1.2,True,1,5508 +2018-05-11 04:04:54.463,Python - Enable TLS1.2 on OSX,"I have a virtualenv environment running python 3.5 +Today, when I booted up my MacBook, I found myself unable to install python packages for my Django project. I get the following error: + +Could not fetch URL : There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:646) - skipping + +I gather that TLS 1.0 has been discontinued, but from what I understand, newer versions of Python should be using TLS1.2, correct? Even outside of my environment, running pip3 trips the same error. I've updated to the latest version of Sierra and have updated Xcode as well. Does anyone know how to resolve this?","Here is the fix: +curl https://bootstrap.pypa.io/get-pip.py | python +Execute from within the appropriate virtual environment.",1.2,True,1,5509 +2018-05-11 21:19:50.853,python Ubuntu: too many open files [eventpoll],"Basically, it is a multi-threaded crawler program, which uses requests mainly. After running the program for a few hours, I keep getting the error ""Too many open files"". +By running: lsof -p pid, I saw a huge number of entries like below: +python 75452 xxx 396u a_inode 0,11 0 8121 [eventpoll] +I cannot figure out what it is and how to trace back to the problem. +Previously, I tried to have it running in Windows and never seen this error. +Any idea how to continue investigating this issue? thanks.","I have figured out that it is caused by Gevent. After replacing gevent with multi-thread, everything is just OK. +However, I still don't know what's wrong with gevent, which keeps opening new files(eventpoll).",0.0,False,1,5510 +2018-05-11 22:56:26.280,How to prepare Python Selenium project to be used on client's machine?,"I've recently started freelance python programming, and was hired to write a script that scraped certain info online (nothing nefarious, just checking how often keywords appear in search results). +I wrote this script with Selenium, and now that it's done, I'm not quite sure how to prepare it to run on the client's machine. +Selenium requires a path to your chromedriver file. Am I just going to have to compile the py file as an exe and accept the path to his chromedriver as an argument, then show him how to download chromedriver and how to write the path? +EDIT: Just actually had a thought while typing this out. Would it work if I sent the client a folder including a chromedriver.exe inside of said folder, so the path was always consistent?","Option 1) Deliver a Docker image if customer not to watch the browser during running and they can setup Docker environment. The Docker image should includes following items: + +Python +Dependencies for running your script, like selenium +Headless chrome browser and compatible chrome webdriver binary +Your script, put them in github and +fetch them when start docker container, so that customer can always get +your latest code + +This approach's benefit: + +You only need to focus on scripts like bug fix and improvement after delivery +Customer only need to execute same docker command + +Option 2) Deliver a Shell script to do most staff automatically. It should accomplish following items: + +Install Python (Or leave it for customer to complete) +Install Selenium library and others needed +Install latest chrome webdriver binary (which is compatible backward) +Fetch your script from code repo like github, or simply deliver as packaged folder +Run your script. + +Option 3) Deliver your script and an user guide, customer have to do many staff by self. You can supply a config file along with your script for customer to specify the chrome driver binary path after they download. Your script read the path from this file, better than enter it in cmd line every time.",0.0,False,1,5511 +2018-05-12 09:01:11.140,Using Hydrogen with Python 3,"The default version of python installed on my mac is python 2. I also have python 3 installed but can't install python 2. +I'd like to configure Hyrdrogen on Atom to run my script using python 3 instead. +Does anybody know how to do this?","I used jupyter kernelspec list and I found 2 kernels available, one for python2 and another for python3 +So I pasted python3 kernel folder in the same directory where python2 ken=rnel is installed and removed python2 kernel using 'rm -rf python2'",0.0,False,1,5512 +2018-05-12 09:48:08.917,Python 3 install location,"I am using Ubuntu 16.04 . Where is the python 3 installation directory ? +Running ""whereis python3"" in terminal gives me: + +python3: /usr/bin/python3.5m-config /usr/bin/python3 + /usr/bin/python3.5m /usr/bin/python3.5-config /usr/bin/python3.5 + /usr/lib/python3 /usr/lib/python3.5 /etc/python3 /etc/python3.5 + /usr/local/lib/python3.5 /usr/include/python3.5m + /usr/include/python3.5 /usr/share/python3 + /usr/share/man/man1/python3.1.gz + +Also where is the intrepreter i.e the python 3 executable ? And how would I add this path to Pycharm ?","you can try this : +which python3",1.2,True,1,5513 +2018-05-12 10:36:33.093,How to continue to train a model with new classes and data?,"I have trained a model successfully and now I want to continue training it with new data. If a given data with the same amount of classes it works fine. But having more data then initially it will give me the error: + +ValueError: Shapes (?, 14) and (?, 21) are not compatible + +How can I dynamically increase the number of classes in my trained model or how to make the model accept a lesser number of classes? Do I need to save the classes in a pickle file?","Best thing to do is to train your network from scratch with the output layers adjusted to the new output class size. +If retraining is an issue, then keep the trained network as it is and only drop the last layer. Add a new layer with the proper output size, initialized to random weights and then fine-tune (train) the entire network.",0.0,False,1,5514 +2018-05-13 11:51:03.607,transfer files between local machine and remote server,I want to make access from remote ubuntu server to local machine because I have multiple files in this machine and I want to transfer it periodically (every minute) to server how can I do that using python,"You can easily transfer files between local and remote or between two remote servers. If both servers are Linux-based and require to transfer multiple files and folder using single command, however, you need to follow up below steps: + +User from one remote server should have access to another remote server to corresponding directory you want to transfer the file. + +You might need to create a policy or group and assign to server list to that group +which you want to access and assign the user to that group so 2 different remote +server can talk to each other. + +Run the following scp command:- + + + scp [options] username1@source_host:directory1/filename1 + username2@destination_host:directory2/filename2",0.0,False,1,5515 +2018-05-13 19:28:44.063,Need help using Keras' model.predict,"My goal is to make an easy neural network fit by providing 2 verticies of a certain Graph and 1 if there's a link or 0 if there's none. +I fit my model, it gets loss of about 0.40, accuracy of about 83% during fitting. I then evaluate the model by providing a batch of all positive samples and several batches of negative ones (utilising random.sample). My model gets loss of ~0.35 and 1.0 accuracy for positive samples and ~0.46 loss 0.68 accuracy for negative ones. +My understanding of neural networks if extremely limited, but to my understanding the above means it theoretically always is right when it outputs 0 when there's no link, but can sometimes output 1 even if there is none. +Now for my actual problem: I try to ""reconstruct"" the original graph with my neural network via model.predict. The problem is I don't understand what the predict output means. At first I assumed values above 0.5 mean 1, else 0. But if that's the case the model doesn't even come close to rebuilding the original. +I get that it won't be perfect, but it simply returns value above 0.5 for random link candidates. +Can someone explain to me how exactly model.predict works and how to properly use it to rebuild my graph?","The model that you trained is not directly optimized w.r.t. the graph reconstruction. Without loss of generality, for a N-node graph, you need to predict N choose 2 links. And it may be reasonable to assume that the true values of the most of these links are 0. +When looking into your model accuracy on the 0-class and 1-class, it is clear that your model is prone to predict 1-class, assuming your training data is balanced. Therefore, your reconstructed graph contains many false alarm links. This is the exact reason why the performance of your reconstruction graph is poor. +If it is possible to retrain the model, I suggest you do it and use more negative samples. +If not, you need to consider applying some post-processing. For example, instead of finding a threshold to decide which two nodes have a link, use the raw predicted link probabilities to form a node-to-node linkage matrix, and apply something like the minimum spanning tree to further decide what are appropriate links.",0.0,False,1,5516 +2018-05-14 05:48:54.863,How to used a tensor in different graphs?,"I build two graphs in my code, graph1 and graph2. +There is a tensor, named embedding, in graph1. I tied to use it in graph2 by using get_variable, while the error is tensor must be from the same graph as Tensor. I found that this error occurs because they are in different graphs. +So how can I use a tensor in graph1 to graph2?","expanding on @jdehesa's comment, +embedding could be trained initially, saved from graph1 and restored to graph2 using tensorflows saver/restore tools. for this to work you should assign embedding to a name/variable scope in graph1 and reuse the scope in graph2",0.0,False,1,5517 +2018-05-14 18:25:36.107,Best practice for rollbacking a multi-purpose python script,"I'm sorry if the title is a little ambiguous. Let me explain what I mean by that : +I have a python script that does a few things : creates a row in a MySQL table, inserts a json document to a MongoDB, Updates stuff in a local file, and some other stuff, mostly related to databases. Thing is, I want the whole operation to be atomic. Means - If anything during the process I mentioned failed, I want to rollback everything I did. I thought of implementing a rollback function for every 'create' function I have. But I'd love to hear your opinion for how to make some sort of a linked list of operations, in which if any of the nodes failed, I want to discard all the changes done in the process. +How would you design such a thing? Is there a library in Python for such things?","You should implement every action to be reversible and the reverse action to be executable even if the original action has failed. Then if you have any failures, you execute every reversal.",0.0,False,1,5518 +2018-05-15 09:13:53.017,Why and how would you not use a python GUI framework and make one yourself like many applications including Blender do?,"I have looked at a few python GUI frameworks like PyQt, wxPython and Kivy, but have noticed there aren’t many popular (used widely) python applications, from what I can find, that use them. +Blender, which is pretty popular, doesn’t seem to use them. How would one go about doing what they did/what did they do and what are the potential benefits over using the previously mentioned frameworks?","I would say that python isn't a popular choice when it comes to making a GUI application, which is why you don't find many examples of using the GUI frameworks. tkinter, which is part of the python development is another option for GUI's. +Blender isn't really a good example as it isn't a GUI framework, it is a 3D application that integrates python as a means for users to manipulate it's data. It was started over 25 years ago when the choice of cross platform frameworks was limited, so making their own was an easier choice to make. Python support was added to blender about 13 years ago. One of the factors in blender's choice was to make each platform look identical. That goes against most frameworks that aim to implement a native look and feel for each target platform. +So you make your own framework when the work of starting your own framework seems easier than adjusting an existing framework to your needs, or the existing frameworks all fail to meet your needs, one of those needs may be licensing with Qt and wxWidgets both available under (L)GPL, while Qt also sells non-GPL licensing. +The benefit to using an existing framework is the amount of work that is already done, you will find there is more than you first think in a GUI framework, especially when you start supporting multiple operating systems.",1.2,True,1,5519 +2018-05-15 19:46:31.853,Installing Kivy to an alternate location,"I have Python version 3.5 which is located here C:\Program Files(x86)\Microsoft Visual Studio\Shared\Python35_64 If I install kivy and its components and add-ons with this command: python -m pip install kivy, then it does not install in the place that I need. I want to install kivy in this location C:\Program Files(x86)\ Microsoft Visual Studio\Shared\Python35_64\Lib\site-packages, how can I do this? +I did not understand how to do this from the explanations on the official website.","So it turned out that I again solved my problem myself, I have installed Python 3.5 and Python 3.6 on my PC, kiwy was installed in Python 3.6 by default, and my development environment was using Python 3.5, I replaced it with 3.6 and it all worked.",0.3869120172231254,False,1,5520 +2018-05-16 07:28:11.157,Portable application: s3 and Google cloud storage,"I want to write an application which is portable. +With ""portable"" I mean that it can be used to access these storages: + +amazon s3 +google cloud storage +Eucalyptus Storage + +The software should be developed using Python. +I am unsure how to start, since I could not find a library which supports all three storages.",You can use boto3 for accessing any services of Amazon.,0.3869120172231254,False,1,5521 +2018-05-16 14:25:25.257,How to access created nodes in a mininet topology?,"I am new in mininet. I created a custom topology with 2 linear switches and 4 nodes. I need to write a python module accessing each nodes in that topology and do something but I don't know how. +Any idea please?","try the following: +s1.cmd('ifconfig s1 192.168.1.0') +h1.cmd('ifconfig h1 192.168.2.0')",1.2,True,1,5522 +2018-05-16 16:07:12.060,Real width of detected face,"I've been researching like forever, but couldn't find an answer. I'm using OpenCV to detect faces, now I want to calculate the distance to the face. When I detect a face, I get a matofrect (which I can visualize with a rectangle). Pretty clear so far. But now: how do I get the width of the rectangle in the real world? There has to be some average values that represent the width of the human face. If I have that value (in inch, mm or whatever), I can calculate the distance using real width, pixel width and focal length. Please, can anyone help me? +Note: I'm comparing the ""simple"" rectangle solution against a Facemark based distance measuring solution, so no landmark based answers. I just need the damn average face / matofrectwidth :D +Thank you so much!","OpenCV's facial recognition is slightly larger than a face, therefore an average face may not be helpful. Instead, just take a picture of a face at different distances from the camera and record the distance from the camera along with the pixel width of the face for several distances. After plotting the two variables on a graph, use a trendline to come up with a predictive model.",0.6730655149877884,False,1,5523 +2018-05-16 17:31:21.103,Split a PDF file into two columns along a certain measurement in Python?,"I have a ton of PDF files that are laid out in two columns. When I use PyPDF2 to extract the text, it reads the entire first column (which are like headers) and the entire second column. This makes splitting on the headers impossible. It's laid out in two columns: +____ __________ +|Col1 Col2 | +|Col1 Col2 | +|Col1 Col2 | +|Col1 Col2 | +____ __________ +I think I need to split the PDF in half along the edge of the column, then read each column left to right. It's 2.26 inches width on an 8x11 PDF. I can also get the coordinates using PyPDF2. +Does anyone have any experience doing this or know how I would do it? +Edit: When I extractText using PyPDF2, the ouput has no spaces: Col1Col1Col1Col1Col2Col2Col2Col2",Using pdfminer.six successfully read from left to right with spaces in between.,0.3869120172231254,False,1,5524 +2018-05-17 16:34:01.880,how to make a copy of an sqlalchemy object (data only),"I get a db record as an sqlalchemy object and I need to consult the original values during some calculation process, so I need the original record till the end. However, the current code modifies the object as it goes and I don't want to refactor it too much at the moment. +How can I make a copy of the original data? The deepcopy seems to create a problem, as expected. I definitely prefer not to copy all the fields manually, as someone will forget to update this code when modifying the db object.","You can have many options here to copy your object.Two of them which I can think of are : + +Using __dict__ it will give the dictionary of the original sqlalchemy object and you can iterate through all the attributes using .keys() function which will give all the attributes. +You can also use inspect module and getmembers() to get all the attributes defined and set the required attributes using setattr() method.",0.0,False,1,5525 +2018-05-18 06:14:11.447,basic serial port contention,"I am using a pi3 which talks to an arduino via serial0 (ttyAMA0) +It all works fine. I can talk to it with minicom, bidirectionally. However, a python based server also wants this port. I notice when minicom is running, the python code can write to serial0 but not read from it. At least minicom reports the python server has sent a message. +Can someone let me know how this serial port handles contention, if at all? I notice running two minicom session to the same serial port wrecks both sessions. Is it possible to have multiple writers and readers if they are coordinated not to act at the same time? Or can there be multiple readers (several terms running cat /dev/serial0) +I have googled around for answers but most hits are about using multiple serial ports or getting a serial port to work at all. +Cheers","Since two minicoms can attempt to use the port and there are collisions minicom must not set an advisory lock on local writes to the serial port. I guess that the first app to read received remote serial message clears it, since serial doesn't buffer. When a local app writes to serial, minicom displays this and it gets sent. I'm going to make this assumed summary + +when a local process puts a message on the serial port everyone can +see it and it gets sent to remote. +when a remote message arrives on +serial, the first local process to get it, gets it. The others +can't see it. +for some reason, minicom has privilege over arriving +messages. This is why two minicoms break the message.",0.3869120172231254,False,1,5526 +2018-05-18 14:53:02.983,Effective passing of large data to python 3 functions,"I am coming from a C++ programming background and am wondering if there is a pass by reference equivalent in python. The reason I am asking is that I am passing very large arrays into different functions and want to know how to do it in a way that does not waste time or memory by having copy the array to a new temporary variable each time I pass it. It would also be nice if, like in C++, changes I make to the array would persist outside of the function. +Thanks in advance, +Jared","Python handles function arguments in the same manner as most common languages: Java, JavaScript, C (pointers), C++ (pointers, references). +All objects are allocated on the heap. Variables are always a reference/pointer to the object. The value, which is the pointer, is copied. The object remains on the heap and is not copied.",0.999329299739067,False,1,5527 +2018-05-19 10:36:50.560,How to find symbolic derivative using python without sympy?,"I need to make a program which will differentiate a function, but I have no idea how to do this. I've only made a part which transforms the regular expression(x ^ 2 + 2 for example ) into reverse polish notation. Can anybody help me with creating a program which will a find symbolic derivatives of expression with + * / - ^","Hint: Use a recursive routine. If an operation is unary plus or minus, leave the plus or minus sign alone and continue with the operand. (That means, recursively call the derivative routine on the operand.) If an operation is addition or subtraction, leave the plus or minus sign alone and recursively find the derivative of each operand. If the operation is multiplication, use the product rule. If the operation is division, use the quotient rule. If the operation is exponentiation, use the generalized power rule. (Do you know that rule, for u ^ v? It is not given in most first-year calculus books but is easy to find using logarithmic differentiation.) (Now that you have clarified in a comment that there will be no variable in the exponent, you can use the regular power rule (u^n)' = n * u^(n-1) * u' where n is a constant.) And at the base of the recursion, the derivative of x is 1 and the derivative of a constant is zero. +The result of such an algorithm would be very un-simplified but it would meet your stated requirements. Since this algorithm looks at an operation then looks at the operands, having the expression in Polish notation may be simpler than reverse Polish or ""regular expression."" But you could still do it for the expression in those forms. +If you need more detail, show us more of your work.",1.2,True,1,5528 +2018-05-19 21:46:47.500,how to get the distance of sequence of nodes in pgr_dijkstra pgrouting?,"I have an array of integers(nodes or destinations) i.e array[2,3,4,5,6,8] that need to be visited in the given sequence. +What I want is, to get the shortest distance using pgr_dijkstra. But the pgr_dijkstra finds the shortest path for two points, therefore I need to find the distance of each pair using pgr_dijkstra and adding all distances to get the total distance. +The pairs will be like +2,3 +3,4 +4,5 +5,6 +6,8. +Is there any way to define a function that takes this array and finds the shortest path using pgr_dijkstra. +Query is: +for 1st pair(2,3) +SELECT * FROM pgr_dijkstra('SELECT gid as id,source, target, rcost_len AS cost FROM finalroads',2,3, false); +for 2nd pair(3,4) +SELECT * FROM pgr_dijkstra('SELECT gid as id,source, target, rcost_len AS cost FROM finalroads'***,3,4,*** false) +for 3rd pair(4,5) +SELECT * FROM pgr_dijkstra('SELECT gid as id,source, target, rcost_len AS cost FROM finalroads'***,4,5,*** false); +NOTE: The array size is not fixed, it can be different. +Is there any way to automate this in postgres sql may be using a loop etc? +Please let me know how to do it. +Thank you.","If you want all pairs distance then use +select * from pgr_apspJohnson ('SELECT gid as id,source, target, rcost_len AS cost FROM finalroads)",0.0,False,1,5529 +2018-05-21 10:54:03.443,Using aws lambda to render an html page in aws lex chatbot,"I have built a chatbot using AWS Lex and lambda. I have a use case where in a user enters a question (For example: What is the sale of an item in a particular region). I want that once this question is asked, a html form/pop up appears that askes the user to select the value of region and item from dropdown menus and fills the slot of the question with the value selected by the user and then return a response. Can some one guide how can this be achieved? Thanks.","Lex has something called response cards where your can add all the possible values. These are called prompts. The user can simply select his/her choice and the slot gets filled. Lex response cards work in Facebook and slack. +In case of custom channel, you will have to custom develop the UI components.",0.0,False,1,5530 +2018-05-22 07:22:36.627,How to install image library in python 3.6.4 in windows 7?,I am new to Python and I am using Python 3.6.4. I also use PyCharm editor to write all my code. Please let me know how can I install Image library in Windows 7 and would it work in PyCharm too.,"From pycharm, + +goto settings -> project Interpreter +Click on + button on top right corner and you will get pop-up window of +Available packages. Then search for pillow, PIL image python packages. +Then click on Install package to install those packages.",1.2,True,1,5531 +2018-05-23 00:28:20.643,"I have downloaded eclipse and pydev, but I am unsure how to get install django","I am attempting to learn how to create a website using python. I have been going off the advice of various websites including stackoverflow. Currently I can run code in eclipse using pydev, but I need to install django. I have no idea how to do this and I don't know who to ask or where to begin. Please help","I would recommend the following: + +Install virtual environment + +$pip install virtualenv + +Create a new virtualenvironment + +$ virtualenv django-venv + +Activate virtual environment & use + +$ source django-venv/bin/activate + +And install django as expected + +(django-venv)$ pip install django==1.11.13 +(Replace with django version as needed)",0.0,False,1,5532 +2018-05-23 14:46:15.693,Proper way of streaming JSON with Django,"i have a webservice which gets user requests and produces (multiple) solution(s) to this request. +I want to return a solution as soon as possible, and send the remaining solutions when they are ready. +In order to do this, I thought about using Django's Http stream response. Unfortunately, I am not sure if this is the most adequate way of doing so, because of the problem I will describe below. +I have a Django view, which receives a query and answers with a stream response. This stream returns the data returned by a generator, which is always a python dictionary. +The problem is that upon the second return action of the stream, the Json content breaks. +If the python dictionary, which serves as a response, is something like {key: val}, after the second yield the returned response is {key: val} {key: val}, which is not valid Json. +Any suggestions on how to return multiple Json objects at different moments in time?","Try decoding with something like +for example + + + +import json +json.dumps( {key: val} {key: val}, separators=('}', ':')) #check it",0.0,False,1,5533 +2018-05-23 15:52:41.077,pycharm won't let me run from desktop,"I have been using pycharm for a while now, and I have to say that I am a real fan of it's features. I have one issue though, when I try to run a .py file from either the desktop or command prompt, I am instead prompted to use the run feature in pycharm. I consider this an issue because if I try to create a program for someone who doesn't know how to code, they would probably be scared off by opening pycharm. I don't, however, want to uninstall pycharm because it is so useful when writing code. Does anyone have any Ideas for me? By the way, I am using a dell Inspiron 15 7000 Gaming laptop with the current version of Windows 10 installed.","You can try running the direct path of the file, I'm not sure what you have tried. +If you wanted to run it as I just described you would do: +py C:\~AppData\Local\Programs\Python\Python36-32\hello.py +If you move the file into your current working directory when programming, you should just be able to run py hello.py.",1.2,True,1,5534 +2018-05-23 20:49:52.333,Calling database handler class in a python thread,"I'm programming a bit of server code and the MQTT side of it runs in it's own thread using the threading module which works great and no issues but now I'm wondering how to proceed. +I have two MariaDB databases, one of them is local and the other is remote (There is a good and niche reason for this.) and I'm writing a class which handles the databases. This class will start new threads of classes that submits the data to their respected databases. If conditions are true, then it tells the data to start a new thread to push data to one database, if they are false, the data will go to the other database. The MQTT thread has a instance of the ""Database handler"" class and passes data to it through different calling functions within the class. +Will this work to allow a thread to concentrate on MQTT tasks while another does the database work? There are other threads as well, I've just never combined databases and threads before so I'd like an opinion or any information that would help me out from more seasoned programmers.","Writing code that is ""thread safe"" can be tricky. I doubt if the Python connector to MySQL is thread safe; there is very little need for it. +MySQL is quite happy to have multiple connections to it from clients. But they must be separate connections, not the same connection running in separate threads. +Very few projects need multi-threaded access to the database. Do you have a particular need? If so let's hear about it, and discuss the 'right' way to do it. +For now, each of your threads that needs to talk to the database should create its own connection. Generally, such a connection can be created soon after starting the thread (or process) and kept open until close to the end of the thread. That is, normally you should have only one connection per thread.",0.0,False,1,5535 +2018-05-25 18:54:02.363,python logging multiple calls after each instantiation,"I have multiple modules and they each have their own log. The all write to the log correctly however when a class is instantiated more than once the log will write the same line multiple times depending on the number of times it was created. +If I create the object twice it will log every messages twice, create the object three times it will log every message three times, etc... +I was wondering how I could fix this without having to only create each object only once. +Any help would be appreciated.",I was adding the handler multiple times after each instantiation of a log. I checked if the handler had already been added at the instantiation and that fixed the multiple writes.,0.0,False,1,5536 +2018-05-28 15:00:34.117,using c extension library with gevent,"I use celery for doing snmp requests with easysnmp library which have a C interface. +The problem is lots of time is being wasted on I/O. I know that I should use eventlet or gevent in this kind of situations, but I don't know how to handle patching a third party library when it uses C extensions.","Eventlet and gevent can't monkey-patch C code. +You can offload blocking calls to OS threads with eventlet.tpool.execute(library.io_func)",0.3869120172231254,False,1,5537 +2018-05-29 02:13:44.043,How large data can Python Ray handle?,"Python Ray looks interesting for machine learning applications. However, I wonder how large Python Ray can handle. Is it limited by memory or can it actually handle data that exceeds memory?","It currently works best when the data fits in memory (if you're on a cluster, then that means the aggregate memory of the cluster). If the data exceeds the available memory, then Ray will evict the least recently used objects. If those objects are needed later on, they will be reconstructed by rerunning the tasks that created them.",1.2,True,1,5538 +2018-05-29 18:31:38.537,Discord bot with user specific counter,"I'm trying to make a Discord bot in Python that a user can request a unit every few minutes, and later ask the bot how many units they have. Would creating a google spreadsheet for the bot to write each user's number of units to be a good idea, or is there a better way to do this?","Using a database is the best option. If you're working with a small number of users and requests you could use something even simpler like a text file for ease of use, but I'd recommend a database. +Easy to use database options include sqlite (use the sqlite3 python library) and MongoDB (I use the mongoengine python library for my Slack bot).",0.0,False,1,5539 +2018-05-29 21:28:22.547,How execute python command within virtualenv with Visual Studio Code,"I have created virtual environment named virualenv. I have scrapy project and I am using there some programs installed in my virtualenv. When I run it from terminal in VSC I can see errors even when I set up my virtual environment via Ctrl+Shift+P -> Python: Select Interpreter -> Python 3.5.2(virtualenv). Interpreter works in some way, I can import libs without errors etc, but I am not possible to start my scrapy project from terminal. I have to activate my virtual environment first via /{path_to_virtualenv}/bin/activate. Is there a way, how to automatically activate it? Now I am using PyCharm and it is possible there, but VSC looks much better according to me.","One way I know how, +Start cmd +Start you virtual env +(helloworld) \path\etc> code . +It will start studio code in this environment. Hope it helps",0.3869120172231254,False,1,5540 +2018-05-30 15:56:33.700,"TensorFlow debug: WARNING:tensorflow:Tensor._shape is private, use Tensor.shape instead. Tensor._shape will eventually be removed","I'm new (obviously) to python, but not so new to TensorFlow +I've been trying to debug my program using breakpoint, but everytime I try to check the content of a tensor in the variable view of my Visual Studio Code debugger, the content doesn't show I get this warning in the console: + +WARNING:tensorflow:Tensor._shape is private, use Tensor.shape instead. Tensor._shape will eventually be removed. + +I'm a bit confused on how to fix this issue. Do I have to wait for an update of TensorFlow before it works?","You can simply stop at the break point, and switch to DEBUG CONSOLE panel, and type var.shape. It's not that convenient, but at least you don't need to write any extra debug code in your code.",0.0,False,2,5541 +2018-05-30 15:56:33.700,"TensorFlow debug: WARNING:tensorflow:Tensor._shape is private, use Tensor.shape instead. Tensor._shape will eventually be removed","I'm new (obviously) to python, but not so new to TensorFlow +I've been trying to debug my program using breakpoint, but everytime I try to check the content of a tensor in the variable view of my Visual Studio Code debugger, the content doesn't show I get this warning in the console: + +WARNING:tensorflow:Tensor._shape is private, use Tensor.shape instead. Tensor._shape will eventually be removed. + +I'm a bit confused on how to fix this issue. Do I have to wait for an update of TensorFlow before it works?","Probably yes you may have to wait. In the debug mode a deprecated function is being called. +You can print out the shape explicitly by calling var.shape() in the code as a workaround. I know not very convenient.",0.0,False,2,5541 +2018-05-30 16:38:21.447,Django storages S3 - Store existing file,"I have django 1.11 with latest django-storages, setup with S3 backend. +I am trying to programatically instantiate an ImageFile, using the AWS image link as a starting point. I cannot figure out how to do this looking at the source / documentation. +I assume I need to create a file, and give it the path derived from the url without the domain, but I can't find exactly how. +The final aim of this is to programatically create wagtail Image objects, that point to S3 images (So pass the new ImageFile to the Imagefield of the image). I own the S3 bucket the images are stored in it. +Uploading images works correctly, so the system is setup correctly. +Update +To clarify, I need to do the reverse of the normal process. Normally a physical image is given to the system, which then creates a ImageFile, the file is then uploaded to S3, and a URL is assigned to the File.url. I have the File.url and need an ImageFile object.","It turns out, in several models that expect files, when using DjangoStorages, all I had to do is instead of passing a File on the file field, pass the AWS S3 object key (so not a URL, just the object key). +When model.save() is called, a boto call is made to S3 to verify an object with the provided key is there, and the item is saved.",1.2,True,1,5542 +2018-05-31 22:09:08.750,import sklearn in python,"I installed miniconda for Windows10 successfully and then I could install numpy, scipy, sklearn successfully, but when I run import sklearn in python IDLE I receive No module named 'sklearn' in anaconda prompt. It recognized my python version, which was 3.6.5, correctly. I don't know what's wrong, can anyone tell me how do I import modules in IDLE ?","Why bot Download the full anaconda and this will install everything you need to start which includes Spider IDE, Rstudio, Jupyter and all the needed modules.. +I have been using anaconda without any error and i will recommend you try it out.",1.2,True,1,5543 +2018-06-01 01:04:30.917,Pycharm Can't install TensorFlow,"I cannot install tensorflow in pycharm on windows 10, though I have tried many different things: + +went to settings > project interpreter and tried clicking the green plus button to install it, gave me the error: non-zero exit code (1) and told me to try installing via pip in the command line, which was successful, but I can't figure out how to make Pycharm use it when it's installed there +tried changing to a Conda environment, which still would not allow me to run tensorflow since when I input into the python command line: pip.main(['install', 'tensorflow']) it gave me another error and told me to update pip +updated pip then tried step 2 again, but now that I have pip 10.0.1, I get the error 'pip has no attribute main'. I tried reverted pip to 9.0.3 in the command line, but this won't change the version used in pycharm, which makes no sense to me. I reinstalled anaconda, as well as pip, and deleted and made a new project and yet it still says that it is using pip 10.0.1 which makes no sense to me + +So in summary, I still can't install tensorflow, and I now have the wrong version of pip being used in Pycharm. I realize that there are many other posts about this issue but I'm pretty sure I've been to all of them and either didn't get an applicable answer or an answer that I understand.","what worked for is this; + +I installed TensorFlow on the command prompt as an administrator using this command pip install tensorflow +then I jumped back to my pycharm and clicked the red light bulb pop-up icon, it will have a few options when you click it, just select the one that says install tensor flow. This would not install in from scratch but basically, rebuild and update your pycharm workspace to note the newly installed tensorflow",0.0,False,1,5544 +2018-06-02 08:27:36.887,How should I move my completed Django Project in a Virtual Environment?,"I started learning django a few days back and started a project, by luck the project made is good and I'm thinking to deploy it. However I didn't initiate it in virtual environment. have made a virtual environment now and want to move project to that. I want to know how can I do that ? I have created requirements.txt whoever it has included all the irrelevant library names. How can I get rid of them and have only that are required for the project.","Django is completely unrelated to the environment you run it on. +The environment represents which python version are you using (2,3...) and the libraries installed. +To answer your question, the only thing you need to do is run your manage.py commands from the python executable in the new virtual environment. Of course install all of the necessary libraries in the new environment if you haven't already did so. +It might be a problem if you created a python3 environment while the one you created was in python2, but at that point it's a code portability issue.",1.2,True,1,5545 +2018-06-03 08:14:39.850,Train CNN model with multiple folders and sub-folders,"I am developing a convolution neural network (CNN) model to predict whether a patient in category 1,2,3 or 4. I use Keras on top of TensorFlow. +I have 64 breast cancer patient data, classified into four category (1=no disease, 2= …., 3=….., 4=progressive disease). In each patient's data, I have 3 set of MRI scan images taken at different dates and inside each MRI folder, I have 7 to 8 sub folders containing MRI images in different plane (such as coronal plane/sagittal plane etc). +I learned how to deal with basic “Cat-Dog-CNN-Classifier”, it was easy as I put all the cat & dog images into a single folder to train the network. But how do I tackle the problem in my breast cancer patient data? It has multiple folders and sub-solders. +Please suggest.",Use os.walk to access all the files in sub-directories recursively and append to the dataset.,-0.1352210990936997,False,1,5546 +2018-06-03 14:02:27.027,How can I change the default version of Python Used by Atom?,"I have started using Atom recently and for the past few days, I have been searching on how to change the default version used in Atom (The default version is currently python 2.7 but I want to use 3.6). Is there anyone I can change the default path? (I have tried adding a profile to the ""script"" package but it still reverts to python 2.7 when I restart Atom. Any help will be hugely appreciated!! Thank you very much in advance.","Yes, there is. After starting Atom, open the script you wish to run. Then open command palette and select 'Python: Select interpreter'. A list appears with the available python versions listed. Select the one you want and hit return. Now you can run the script by placing the cursor in the edit window and right-clicking the mouse. A long menu appears and you should choose the 'Run python in the terminal window'. This is towards the bottom of the long menu list. The script will run using the interpreter you selected.",0.0,False,4,5547 +2018-06-03 14:02:27.027,How can I change the default version of Python Used by Atom?,"I have started using Atom recently and for the past few days, I have been searching on how to change the default version used in Atom (The default version is currently python 2.7 but I want to use 3.6). Is there anyone I can change the default path? (I have tried adding a profile to the ""script"" package but it still reverts to python 2.7 when I restart Atom. Any help will be hugely appreciated!! Thank you very much in advance.","I would look in the atom installed plugins in settings.. you can get here by pressing command + shift + p, then searching for settings. +The only reason I suggest this is because, plugins is where I installed swift language usage accessibility through a plugin that manages that in atom. +Other words for plugins on atom would be ""community packages"" +Hope this helps.",0.0,False,4,5547 +2018-06-03 14:02:27.027,How can I change the default version of Python Used by Atom?,"I have started using Atom recently and for the past few days, I have been searching on how to change the default version used in Atom (The default version is currently python 2.7 but I want to use 3.6). Is there anyone I can change the default path? (I have tried adding a profile to the ""script"" package but it still reverts to python 2.7 when I restart Atom. Any help will be hugely appreciated!! Thank you very much in advance.","I came up with an inelegant solution that may not be universal. Using platformio-ide-terminal, I simply had to call python3.9 instead of python or python3. Not sure if that is exactly what you're looking for.",0.0,False,4,5547 +2018-06-03 14:02:27.027,How can I change the default version of Python Used by Atom?,"I have started using Atom recently and for the past few days, I have been searching on how to change the default version used in Atom (The default version is currently python 2.7 but I want to use 3.6). Is there anyone I can change the default path? (I have tried adding a profile to the ""script"" package but it still reverts to python 2.7 when I restart Atom. Any help will be hugely appreciated!! Thank you very much in advance.","I am using script 3.18.1 in Atom 1.32.2 +Navigate to Atom (at top left) > Open Preferences > Open Config folder. +Now, Expand the tree as script > lib > grammars +Open python.coffee and change 'python' to 'python3' in both the places in command argument",0.9866142981514304,False,4,5547 +2018-06-04 05:13:38.857,Line by line data from Google cloud vision API OCR,"I have scanned PDFs (image based) of bank statements. +Google vision API is able to detect the text pretty accurately but it returns blocks of text and I need line by line text (bank transactions). +Any idea how to go about it?","In Google Vision API there is a method fullTextAnnotation which returns a full text string with \n specifying the end of the line, You can try that.",0.0,False,1,5548 +2018-06-04 20:20:23.930,"XgBoost accuracy results differ on each run, with the same parameters. How can I make them constant?","The 'merror' and 'logloss' result from XGB multiclass classification differs by about 0.01 or 0.02 on each run, with the same parameters. Is this normal? +I want 'merror' and 'logloss' to be constant when I run XGB with the same parameters so I can evaluate the model precisely (e.g. when I add a new feature). +Now, if I add a new feature I can't really tell whether it had a positive impact on my model's accuracy or not, because my 'merror' and 'logloss' differ on each run regardless of whether I made any changes to the model or the data fed into it since the last run. +Should I try to fix this and if I should, how can I do it?","Managed to solve this. First I set the 'seed' parameter of XgBoost to a fixed value, as Hadus suggested. Then I found out that I used sklearn's train_test_split function earlier in the notebook, without setting the random_state parameter to a fixed value. So I set the random_state parameter to 22 (you can use whichever integer you want) and now I'm getting constant results.",0.0,False,1,5549 +2018-06-04 23:38:16.783,How to keep python programming running constantly,"I made a program that grabs the top three new posts on the r/wallpaper subreddit. It downloads the pictures every 24 hours and adds them to my wallpapers folder. What I'm running into is how to have the program running in the background. The program resumes every time I turn the computer on, but it pauses whenever I close the computer. Is there a way to close the computer without pausing the program? I'm on a mac.","Programs can't run when the computer is powered off. However, you can run a computer headlessly (without mouse, keyboard, and monitor) to save resources. Just ensure your program runs over the command line interface.",0.0,False,1,5550 +2018-06-05 04:53:45.747,Pandas - Read/Write to the same csv quickly.. getting permissions error,"I have a script that I am trying to execute every 2 seconds.. to begin it reads a .csv with pd.read_csv. Then executes modifications on the df and finally overwrites the original .csv with to_csv. +I'm running into a PermissionError: [Errno 13] Permission denied: and from my searches I believe it's due to trying to open/write too often to the same file though I could be wrong. + +Any suggestions how to avoid this? +Not sure if relevant but the file is stored in one-drive folder. +It does save on occasion, seemingly randomly. +Increasing the timeout so the script executes slower helps but I want it running fast! + +Thanks","Close the file that you are trying to read and write and then try running your script. +Hope it helps",-0.2012947653214861,False,1,5551 +2018-06-06 11:33:58.087,Optimizing RAM usage when training a learning model,"I have been working on creating and training a Deep Learning model for the first time. I did not have any knowledge about the subject prior to the project and therefor my knowledge is limited even now. +I used to run the model on my own laptop but after implementing a well working OHE and SMOTE I simply couldnt run it on my own device anymore due to MemoryError (8GB of RAM). Therefor I am currently running the model on a 30GB RAM RDP which allows me to do so much more, I thought. +My code seems to have some horribly inefficiencies of which I wonder if they can be solved. One example is that by using pandas.concat my model's RAM usages skyrockets from 3GB to 11GB which seems very extreme, afterwards I drop a few columns making the RAm spike to 19GB but actually returning back to 11GB after the computation is completed (unlike the concat). I also forced myself to stop using the SMOTE for now just because the RAM usage would just go up way too much. +At the end of the code, where the training happens the model breaths its final breath while trying to fit the model. What can I do to optimize this? +I have thought about splitting the code into multiple parts (for exmaple preprocessing and training) but to do so I would need to store massive datasets in a pickle which can only reach 4GB (correct me if I'm wrong). I have also given thought about using pre-trained models but I truely did not understand how this process goes to work and how to use one in Python. +P.S.: I would also like my SMOTE back if possible +Thank you all in advance!","Slightly orthogonal to your actual question, if your high RAM usage is caused by having entire dataset in memory for the training, you could eliminate such memory footprint by reading and storing only one batch at a time: read a batch, train on this batch, read next batch and so on.",0.0,False,1,5552 +2018-06-07 17:31:59.093,ARIMA Forecasting,"I have a time series data which looks something like this +Loan_id Loan_amount Loan_drawn_date + id_001 2000000 2015-7-15 + id_003 100 2014-7-8 + id_009 78650 2012-12-23 + id_990 100 2018-11-12 +I am trying to build a Arima forecasting model on this data which has round about 550 observations. These are the steps i have followed + +Converted the time series data into daily data and replaced NA values with 0. the data look something like this +Loan_id Loan_amount Loan_drawn_date +id_001 2000000 2015-7-15 +id_001 0 2015-7-16 +id_001 0 2015-7-17 +id_001 0 2015-7-18 +id_001 0 2015-7-19 +id_001 0 2015-7-20 +.... +id_003 100 2014-7-8 +id_003 0 2014-7-9 +id_003 0 2014-7-10 +id_003 0 2014-7-11 +id_003 0 2014-7-12 +id_003 0 2014-7-13 +.... +id_009 78650 2012-12-23 +id_009 0 2012-12-24 +id_009 0 2012-12-25 +id_009 0 2012-12-26 +id_009 0 2012-12-27 +id_009 0 2012-12-28 +... +id_990 100 2018-11-12 +id_990 0 2018-11-13 +id_990 0 2018-11-14 +id_990 0 2018-11-15 +id_990 0 2018-11-16 +id_990 0 2018-11-17 +id_990 0 2018-11-18 +id_990 0 2018-11-19 +Can Anyone please suggest me how do i proceed ahead with these 0 values now? +Seeing the variance in the loan amount numbers i would take log of the of the loan amount. i am trying to build the ARIMA model for the first time and I have read about all the methods of imputation but there is nothing i can find. Can anyone please tell me how do i proceed ahead in this data","I don't know exactly about your specific domain problem, but these things apply usually in general: + +If the NA values represent 0 values for your domain specific problem, then replace them with 0 and then fit the ARIMA model (this would for example be the case if you are looking at daily sales and on some days you have 0 sales) +If the NA values represent unknown values for your domain specific problem then do not replace them and fit your ARIMA model. (this would be the case, if on a specific day the employee forgot to write down the amount of sales and it could be any number). + +I probably would not use imputation at all. There are methods to fit an ARIMA model on time series that have missing values. Usually these algorithms should probably also implemented somewhere in python. (but I don't know since I am mostly using R)",1.2,True,1,5553 +2018-06-08 11:15:45.900,Randomizing lists with variables in Python 3,"I'm looking for a way to randomize lists in python (which I already know how to do) but to then make sure that two things aren't next to each other. For example, if I were to be seating people and numbering the listing going down by 0, 1, 2, 3, 4, 5 based on tables but 2 people couldn't sit next to each other how would I make the list organized in a way to prohibit the 2 people from sitting next to each other.","As you say that you know how to shuffle a list, the only requirement is that two elements are not next to each other. +A simple way is to: + +shuffle the full list +if the two elements are close, choose a random possible position for the second one +exchange the two elements + +Maximum cost: one shuffle, one random choice, one exchange",1.2,True,1,5554 +2018-06-09 00:49:48.297,how to check the SD card size before mounted and do not require root,"I want to check the SD card size in bash or python. Right now I know df can check it when the SD card is mounted or fdisk -l if root is available. +But I want to know how to check the SD card size without requiring mounting the card to the file system or requiring the root permission? For example, if the SD card is not mounted and I issue df -h /dev/sdc, this will return a wrong size. In python, os.statvfs this function returns the same content as well. I search on stack overflow but did not find a solution yet.","Well, I found the lsblk -l can do the job. It tells the total size of the partitions.",0.0,False,1,5555 +2018-06-09 15:59:07.447,How to write a python program that 'scrapes' the results from a website for all possible combinations chosen from the given drop down menus?,"There is a website that claims to predict the approximate salary of an individual on the basis of the following criteria presented in the form of individual drop-down + +Age : 5 options +Education : 3 Options +Sex : 3 Options +Work Experience : 4 Options +Nationality: 12 Options + +On clicking the Submit button, the website gives a bunch of text as output on a new page with an estimate of the salary in numerals. +So, there are technically 5*3*3*4*12 = 2160 data points. I want to get that and arrange it in an excel sheet. Then I would run a regression algorithm to guess the function this website has used. This is what I am looking forward to achieve through this exercise. This is entirely for learning purposes since I'm keen on learning these tools. +But I don't know how to go about it? Any relevant tutorial, documentation, guide would help! I am programming in python and I'd love to use it to achieve this task! +Thanks!","If you are uncomfortable asking them for database as roganjosh suggested :) use Selenium. Write in Python a script that controls Web Driver and repeatedly sends requests to all possible combinations. The script is pretty simple, just a nested loop for each type of parameter/drop down. +If you are sure that value of each type do not depend on each other, check what request is sent to the server. If it is simple URL encoded, like age=...&sex=...&..., then Selenium is not needed. Just generate such URLa for all possible combinations and call the server.",1.2,True,1,5556 +2018-06-09 16:51:02.213,"Rasa-core, dealing with dates","I have a problem with rasa core, let's suppose that I have a rasa-nlu able to detect time +eg ""let's start tomorrow"" would get the entity time: 2018-06-10:T18:39:155Z +Ok, now I want next branches, or decisions to be conditioned by: + +time is in the past +time before one month from now +time is beyond 1 +month + +I do not know how to do that. I do not know how to convert it to a slot able to influence the dialog. My only idea would be to have an action that converts the date to a categorical slot right after detecting time, but I see two problems with that approach: + +one it would already be too late, meaning that if I do it with a +posterior action it means the rasa-core has already decided what +decision to take without using the date +and secondly, I do know how to save it, because if I have a +stories.md that compares a detecting date like in the example with +the current time, maybe in the time of the example it was beyond one +month but now it is in the past, so the reset of that story would be +wrong. + +I am pretty lost and I do not know how to deal with this, thanks a lot!!!","I think you could have a validation in the custom form. +Where it perform validation on the time and perform next action base on the decision on the time. +Your story will have to train to handle different action paths.",0.0,False,1,5557 +2018-06-10 13:57:31.837,Multi crtieria alterative ranking based on mixed data types,"I am building a recommender system which does Multi Criteria based ranking of car alternatives. I just need to do ranking of the alternatives in a meaningful way. I have ways of asking user questions via a form. +Each car will be judged on the following criteria: price, size, electric/non electric, distance etc. As you can see its a mix of various data types, including ordinal, cardinal(count) and quantitative dat. +My question is as follows: + +Which technique should I use for incorporating all the models into a single score Which I can rank. I looked at normalized Weighted sum model, but I have a hard time assigning weights to ordinal(ranked) data. I tried using the SMARTER approach for assigning numerical weights to ordinal data but Im not sure if it is appropriate. Please help! +After someone can help me figure out answer to finding the best ranking method, what if the best ranked alternative isnt good enough on an absolute scale? how do i check that so that enlarge the alternative set further? + +3.Since the criterion mention above( price, etc) are all on different units, is there a good method to normalized mixed data types belonging to different scales? does it even make sense to do so, given that the data belongs to many different types? +any help on these problems will be greatly appreciated! Thank you!","I am happy to see that you are willing to use multiple criteria decision making tool. You can use Analytic Hierarchy Process (AHP), Analytic Network Process (ANP), TOPSIS, VIKOR etc. Please refer relevant papers. You can also refer my papers. +Krishnendu Mukherjee",-0.3869120172231254,False,1,5558 +2018-06-11 22:00:14.173,Security of SFTP packages in Python,"There is plenty of info on how to use what seems to be third-party packages that allow you to access your sFTP by inputting your credentials into these packages. +My dilemma is this: How do I know that these third-party packages are not sharing my credentials with developers/etc? +Thank you in advance for your input.","Thanks everyone for comments. +To distill it: Unless you do a code review yourself or you get a the sftp package from a verified vendor (ie - packages made by Amazon for AWS), you can not assume that these packages are ""safe"" and won't post your info to a third-party site.",1.2,True,1,5559 +2018-06-11 22:56:02.750,How to sync 2 streams from separate sources,"Can someone point me the right direction to where I can sync up a live video and audio stream? +I know it sound simple but here is my issue: + +We have 2 computers streaming to a single computer across multiple networks (which can be up to hundreds of miles away). +All three computers have their system clocks synchronized using NTP +Video computer gathers video and streams UDP to the Display computer +Audio computer gathers audio and also streams to the Display computer + +There is an application which accepts the audio stream. This application does two things (plays the audio over the speakers and sends network delay information to my application). I am not privileged to the method which they stream the audio. +My application displays the video and two other tasks (which I haven't been able to figure out how to do yet). +- I need to be able to determine the network delay on the video stream (ideally, it would be great to have a timestamp on the video stream from the Video computer which is related to that system clock so I can compare that timestamp to my own system clock). +- I also need to delay the video display to allow it to be synced up with the audio. +Everything I have found assumes that either the audio and video are being streamed from the same computer, or that the audio stream is being done by gstreamer so I could use some sync function. I am not privileged to the actual audio stream. I am only given the amount of time the audio was delayed getting there (network delay). +So intermittently, I am given a number as the network delay for the audio (example: 250 ms). I need to be able to determine my own network delay for the video (which I don't know how to do yet). Then I need to compare to see if the audio delay is more than the video network delay. Say the video is 100ms ... then I would need to delay the video display by 150ms (which I also don't know how to do). +ANY HELP is appreciated. I am trying to pick up where someone else has left off in this design so it hasn't been easy for me to figure this out and move forward. Also being done in Python ... which further limits the information I have been able to find. Thanks. +Scott","A typical way to synch audio and video tracks or streams is have a timestamp for each frame or packet, which is relative to the start of the streams. +This way you know that no mater how long it took to get to you, the correct audio to match with the video frame which is 20001999 (for example) milliseconds from the start is the audio which is also timestamped as 20001999 milliseconds from the start. +Trying to synch audio and video based on an estimate of the network delay will be extremely hard as the delay is very unlikely to be constant, especially on any kind of IP network. +If you really have no timestamp information available, then you may have to investigate more complex approaches such as 'markers' in the stream metadata or even some intelligent analysis of the audio and video streams to synch on an event in the streams themselves.",0.0,False,1,5560 +2018-06-12 08:22:14.127,Python script as service has not access to asoundrc configuration file,"I have a python script that records audio from an I2S MEMS microphone, connected to a Raspberry PI 3. +This script runs as supposed to, when accessed from the terminal. The problem appears when i run it as a service in the background. +From what i have seen, the problem is that the script as service, has no access to a software_volume i have configured in asoundrc. The strange thing is that i can see this ""device"" in the list of devices using the get_device_info_by_index() function. +For audio capturing i use the pyaudio library and for making the script a service i have utilized the supervisor utility. +Any ideas what the problem might be and how i can make my script to have access to asoundrc when it runs as a service?","The ~/.asoundrc file is looked for the home directory of the current user (this is what ~ means). +Put it into the home directory of the user as which the service runs, or put the definitions into the global ALSA configuration file /etc/asound.conf.",1.2,True,1,5561 +2018-06-12 14:34:32.823,Odoo 10 mass mailing configure bounces,"I'm using Odoo 10 mass mailing module to send newsletters. I have configured it but I don't know how to configure bounced emails. It is registering correctly sent emails, received (except that it is registering bounced as received), opened and clicks. +Can anyone please help me? +Regards","I managed to solve this problem. Just configured the 'bounce' system parameter to an email with the same name. +Example: +I created an email bounce-register@example.com. Also remember to configure the alias domain in your general settings to 'example.com' +After configuring your email to register bounces you need to configure an incomming mail server for this email (I configured it as an IMAP so I think that should do altough you can also configure it as a POP). That would be it. +Hope this info server for you",1.2,True,1,5562 +2018-06-14 15:07:58.413,How to predict word using trained skipgram model?,"I'm using Google's Word2vec and I'm wondering how to get the top words that are predicted by a skipgram model that is trained using hierarchical softmax, given an input word? +For instance, when using negative sampling, one can simply multiply an input word's embedding (from the input matrix) with each of the vectors in the output matrix and take the one with the top value. However, in hierarchical softmax, there are multiple output vectors that correspond to each input word, due to the use of the Huffman tree. +How do we compute the likelihood value/probability of an output word given an input word in this case?","I haven't seen any way to do this, and given the way hierarchical-softmax (HS) outputs work, there's no obviously correct way to turn the output nodes' activation levels into a precise per-word likelihood estimation. Note that: + +the predict_output_word() method that (sort-of) simulates a negative-sampling prediction doesn't even try to handle HS mode +during training, neither HS nor negative-sampling modes make exact predictions – they just nudge the outputs to be more like the current training example would require + +To the extent you could calculate all output node activations for a given context, then check each word's unique HS code-point node values for how close they are to ""being predicted"", you could potentially synthesize relative scores for each word – some measure of how far the values are from a ""certain"" output of that word. But whether and how each node's deviation should contribute to that score, and how that score might be indicative of a interpretable liklihood, is unclear. +There could also be issues because of the way HS codes are assigned strictly by word-frequency – so 'neighbor' word sharing mostly-the-same-encoding may be very different semantically. (There were some hints in the original word2vec.c code that it could potentially be beneficial to assign HS-encodings by clustering related words to have similar codings, rather than by strict frequency, but I've seen little practice of that since.) +I would suggest sticking to negative-sampling if interpretable predictions are important. (But also remember, word2vec isn't mainly used for predictions, it just uses the training-attempts-at-prediction to bootstrap a vector-arrangment that turn out to be useful for other tasks.)",0.0,False,1,5563 +2018-06-15 06:29:25.043,ImportError: cannot import name _remove_dead_weakref python 2.7,"I use windows 7 and python 2.7 +When I used py2exe to make an .exe file I get the error; +Traceback (most recent call last): +File ""mainpy"", line 17, in +File ""main.py"", line 17, in +File ""zipextimporter.pyc"", line 82, in load_module +File ""zipextimporter.pyc"", line 82, in load_module +File ""logging_init_.pyc"", line 26, in +File ""zipextimporter.pyc"", line 82, in load_module +File ""weakref.pyc"", line 14, in +ImportError: cannot import name _remove_dead_weakref +The same code could be used to make an .exe file in another computer so there is nothing wrong with the code in main.py. The minor environmental difference may cause this problem. I used pycharm, python 2.7.10 and py2exe 0.6.9. On another computer all other config are the same except using sublimetext instead of pycharm. +Could anyone please tell me how to fix that? +Another tricky thing is that",It is possible that the library does not exists for the other computer.Please check whether the library exists or not.,0.0,False,1,5564 +2018-06-15 08:06:21.200,finding length of linked list in constant time python,"I'm trying to write a function which finds the length of a linked list in O(1). +I know how to implement it in O(n) but I can't figure out how to do it in constant time... is that even possible?","Its not possible because you have to atleast pass through entire linked list and it takes O(n) +Else you have to use a variable which counts when inserting elements into linked list",0.0,False,1,5565 +2018-06-15 21:13:27.137,"Accessing Hidden Tabs, Web Scraping With Python 3.6","I'm using bs4 and urllib.request in python 3.6 to webscrape. I have to open tabs / be able to toggle an ""aria-expanded"" in button tabs in order to access the div tabs I need. +The button tab when the tab is closed is as follows with <> instead of --: +button id=""0-accordion-tab-0"" type=""button"" class=""accordion-panel-title u-padding-ver-s u-text-left text-l js-accordion-panel-title"" aria-controls=""0-accordion-panel-0"" aria-expanded=""false"" +When opened, the aria-expanded=""true"" and the div tab appears underneath. +Any idea on how to do this? +Help would be super appreciated.","BeautifulSoup is used to parse HTML/XML content. You can't click around on a webpage with it. +I recommend you look through the document to make sure it isn't just moving the content from one place to the other. If the content is loaded through AJAX when the button is clicked then you will have to use something like selenium to trigger the click. +An easier option could be to check what url the content is fetched from when you click the button and make a similar call in your script if possible.",0.0,False,1,5566 +2018-06-16 19:30:32.583,How to I close down a python server built using flask,"When I run this simple code: +from flask import Flask,render_template +app = Flask(__name__) +@app.route('/') +def index(): + return 'this is the homepage' +if __name__ == ""__main__"": + app.run(debug=True, host=""0.0.0.0"",port=8080) +It works fine but when I close it using ctrl+z in the terminal and try to run it again I get OSError: [Errno 98] Address already in use +So I tried changing the port address and re-running it which works for some of the port numbers I enter. But I want to know a graceful way to clear the address being used by previous program so that it is free for the current one. +Also is what is the apt way to shutdown a server and free the port address. +Kindly tell a simple way to do so OR explain the method used fully because I read solutions to similar problems but didn't understand any of it. +When I run +netstat -tulpn +The output is : +(Not all processes could be identified, non-owned process info + will not be shown, you would have to be root to see it all.) +Active Internet connections (only servers) +Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name +tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN - +tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN - +tcp 0 0 0.0.0.0:3689 0.0.0.0:* LISTEN 4361/rhythmbox +tcp6 0 0 ::1:631 :::* LISTEN - +tcp6 0 0 :::3689 :::* LISTEN 4361/rhythmbox +udp 0 0 0.0.0.0:5353 0.0.0.0:* 3891/chrome +udp 0 0 0.0.0.0:5353 0.0.0.0:* - +udp 0 0 0.0.0.0:39223 0.0.0.0:* - +udp 0 0 127.0.1.1:53 0.0.0.0:* - +udp 0 0 0.0.0.0:68 0.0.0.0:* - +udp 0 0 0.0.0.0:631 0.0.0.0:* - +udp 0 0 0.0.0.0:58140 0.0.0.0:* - +udp6 0 0 :::5353 :::* 3891/chrome +udp6 0 0 :::5353 :::* - +udp6 0 0 :::41938 :::* - +I'm not sure how to interpret it. +the output of ps aux | grep 8080 +is : +shreyash 22402 0.0 0.0 14224 928 pts/2 S+ 01:20 0:00 grep --color=auto 8080 +I don't know how to interpret it. +Which one is the the process name and what is it's id?","It stays alive because you're not closing it. With Ctrl+Z you're removing the execution from current terminal without killing a process. +To stop the execution use Ctrl+C",0.2012947653214861,False,2,5567 +2018-06-16 19:30:32.583,How to I close down a python server built using flask,"When I run this simple code: +from flask import Flask,render_template +app = Flask(__name__) +@app.route('/') +def index(): + return 'this is the homepage' +if __name__ == ""__main__"": + app.run(debug=True, host=""0.0.0.0"",port=8080) +It works fine but when I close it using ctrl+z in the terminal and try to run it again I get OSError: [Errno 98] Address already in use +So I tried changing the port address and re-running it which works for some of the port numbers I enter. But I want to know a graceful way to clear the address being used by previous program so that it is free for the current one. +Also is what is the apt way to shutdown a server and free the port address. +Kindly tell a simple way to do so OR explain the method used fully because I read solutions to similar problems but didn't understand any of it. +When I run +netstat -tulpn +The output is : +(Not all processes could be identified, non-owned process info + will not be shown, you would have to be root to see it all.) +Active Internet connections (only servers) +Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name +tcp 0 0 127.0.1.1:53 0.0.0.0:* LISTEN - +tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN - +tcp 0 0 0.0.0.0:3689 0.0.0.0:* LISTEN 4361/rhythmbox +tcp6 0 0 ::1:631 :::* LISTEN - +tcp6 0 0 :::3689 :::* LISTEN 4361/rhythmbox +udp 0 0 0.0.0.0:5353 0.0.0.0:* 3891/chrome +udp 0 0 0.0.0.0:5353 0.0.0.0:* - +udp 0 0 0.0.0.0:39223 0.0.0.0:* - +udp 0 0 127.0.1.1:53 0.0.0.0:* - +udp 0 0 0.0.0.0:68 0.0.0.0:* - +udp 0 0 0.0.0.0:631 0.0.0.0:* - +udp 0 0 0.0.0.0:58140 0.0.0.0:* - +udp6 0 0 :::5353 :::* 3891/chrome +udp6 0 0 :::5353 :::* - +udp6 0 0 :::41938 :::* - +I'm not sure how to interpret it. +the output of ps aux | grep 8080 +is : +shreyash 22402 0.0 0.0 14224 928 pts/2 S+ 01:20 0:00 grep --color=auto 8080 +I don't know how to interpret it. +Which one is the the process name and what is it's id?","You will have another process listening on port 8080. You can check to see what that is and kill it. You can find processes listening on ports with netstat -tulpn. Before you do that, check to make sure you don't have another terminal window open with the running instance.",-0.1016881243684853,False,2,5567 +2018-06-18 05:46:38.073,How to print all recieved post request include headers in python,"I am a python newbie and i have a controler that get Post requests. +I try to print to log file the request that it receive, i am able to print the body but how can i extract all the request include the headers? +I am using request.POST.get() to get the body/data from the request. +Thanks","request.POST should give you the POST body if it is get use request.GET +if the request body is json use request.data",-0.2012947653214861,False,1,5568 +2018-06-18 09:08:56.737,Add conda to my environment variables or path?,"I am having trouble adding conda to my environment variables on windows. I installed anaconda 3 though I didn't installed python, so neither pip or pip3 is working in my prompt. I viewed a few post online but I didn't find anything regarding how to add conda to my environment variables. +I tried to create a PYTHONPATH variable which contained every single folder in Anaconda 3 though it didn't worked. +My anaconda prompt isn't working too. :( +so...How do I add conda and pip to my environment variables or path ?","Thanks guys for helping me out. I solved the problem reinstalling anaconda (several times :[ ), cleaning every log and resetting the path variables via set path= in the windows power shell (since I got some problems reinstalling anaconda adding the folder to PATH[specifically ""unable to load menus"" or something like that])",0.0,False,1,5569 +2018-06-18 16:13:18.567,"getting ""invalid environment marker"" when trying to install my python project","I'm trying to set up a beta environment on Heroku for my Django-based project, but when I install I am getting: + +error in cryptography setup command: Invalid environment marker: + python_version < '3' + +I've done some googling, and it is suggested that I upgrade setuptools, but I can't figure out how to do that. (Putting setuptools in requirements.txt gives me a different error message.) +Sadly, I'm still on Python 2.7, if that matters.","The problem ended up being the Heroku ""buildpack"" that I was using. I had been using the one from ""thenovices"" for a long time so that I could use numpy, scipy, etc. +Sadly, that buildpack specifies an old version of setuptools and python, and those versions were not understanding some of the new instructions (python_version) in the newer setup files for cryptography. +If you're facing this problem, Heroku's advice is to move to Docker-based Heroku, rather than ""traditional"" Heroku.",1.2,True,1,5570 +2018-06-19 10:47:23.783,how to use the Werkzeug debugger in postman?,"i am building a flask RESTapi and i am using postman to make http post requests to my api , i want to use the werkzeug debugger , but postman wont allow me to put in the debugging pin and debug the code from postman , what can i do ?","Never needed any debugger for postman. This is not the tool you need the long blanket of code for one endpoint to test. +It gives a good option - console. I have never experienced any trouble this simple element didn't help me so far.",0.0,False,1,5571 +2018-06-19 13:14:35.270,Importing Numpy into Sublime Text 3,"I'm new to coding and I have been learning it on Jupyter. I have anaconda, Sublime Text 3, and the numpy package installed on my Mac. +On Jupyter, we would import numpy by simply typing + import numpy as np +However, this doesnt seem to work on Sublime as I get the error ModuleNotFoundError: No module named 'numpy' +I would appreciate it if someone could guide me on how to get this working. Thanks!","If you have Annaconda, install Spyder. +If you continue to have this problem, you could check all the lib install from anaconda. +I suggest you to install nmpy from anaconda.",0.3869120172231254,False,1,5572 +2018-06-19 18:36:14.277,dataframe from underlying script not updating,"I have a script called ""RiskTemplate.py"" which generates a pandas dataframe consisting of 156 columns. I created two additional columns which gives me a total count of 158 columns. However, when I run this ""RiskTemplate.py"" script in another script using the below code, the dataframe only pulls the original 156 columns I had before the two additional columns were added. +exec(open(""RiskTemplate.py"").read()) +how can I get the reference script to pull in the revised dataframe from the underlying script ""RiskTemplate.py""? +here are the lines creating the two additional dataframe columns, they work as intended when I run it directly in the ""RiskTemplate.py"" script. The original dataframe is pulling from SQL via df = pd.read_sql(query,connection) +df['LMV % of NAV'] = df['longmv']/df['End of Month NAV']*100 +df['SMV % of NAV'] = df['shortmv']/df['End of Month NAV']*100","I figured it out, sorry for the confusion. I did not save the risktemplate that I updated the dataframe to in the same folder that the other reference script was looking at! Newbie!",0.3869120172231254,False,1,5573 +2018-06-20 01:59:58.440,Python regex to match words not having dot,"I want to accept only those strings having the pattern 'wild.flower', 'pink.flower',...i.e any word preceding '.flower', but the word should not contain dot. For example, ""pink.blue.flower"" is unacceptable. Can anyone help how to do this in python using regex?","Your case of pink.blue.flower is unclear. There are 2 possibilities: + +Match only blue (cut off preceding dot and what was before). +Reject this case altogether (you want to match a word preceding .flower +only if it is not preceded with a dot). + +In the first case accept other answers. +But if you want the second solution, use: \b(? Settings > Project > Project Interpreter.",1.2,True,1,5580 +2018-06-22 18:41:42.363,Getting IDs from t-SNE plot?,"Quite simple, +If I perform t-SNE in Python for high-dimensional data then I get 2 or 3 coordinates that reflect each new point. +But how do I map these to the original IDs? +One way that I can think of is if the indices are kept fixed the entire time, then I can do: + +Pick a point in t-SNE +See what row it was in t-SNE (e.g. index 7) +Go to original data and pick out row/index 7. + +However, I don't know how to check if this actually works. My data is super high-dimensional and it is very hard to make sense of it with a normal ""sanity check"". +Thanks a lot! +Best,","If you are using sklearn's t-SNE, then your assumption is correct. The ordering of the inputs match the ordering of the outputs. So if you do y=TSNE(n_components=n).fit_transform(x) then y and x will be in the same order so y[7] will be the embedding of x[7]. You can trust scikit-learn that this will be the case.",0.3869120172231254,False,1,5581 +2018-06-22 19:56:07.460,how to print the first lines of a large XML?,"I have this large XML file on my drive. The file is too large to be opened with sublimetext or other text editors. +It is also too large to be loaded in memory by the regular XML parsers. +Therefore, I dont even know what's inside of it! +Is it just possible to ""print"" a few rows of the XML files (as if it was some sort of text document) so that I have an idea of the nodes/content? +I am suprised not to find an easy solution to that issue. +Thanks!","This is one of the few things I ever do on the command line: the ""more"" command is your friend. Just type + +more big.xml",0.1352210990936997,False,1,5582 +2018-06-25 05:26:40.297,Two python3 interpreters on win10 cause misunderstanding,"I used win10. When I installed Visual Studio2017, I configure the Python3 environment. And then after half year I installed Anaconda(Python3) in another directory. Now I have two interpreters in different directories. + +Now, no matter in what IDE I code the codes, after I save it and double click it in the directory, the Python File is run by the interpreter configured by VS2017. + +Why do I know that? I use sys.path to get to know it. But when I use VS2017 to run the code, it shows no mistake. The realistic example is that I pip install requests in cmd, then I import it in a Python File. Only when I double click it, the Traceback says I don't have this module. In other cases it works well. + +So, how to change the default python interpreter of the cmd.exe?","Just change the interpreter order of the python in the PATH is enough. +If you want to use python further more, I suggest you to use virtual environment tools like pipenv to control your python interpreters and modules.",0.0,False,1,5583 +2018-06-25 07:13:06.080,How can I update Python version when working on JGRASP on mac os?,"When I installed the new version of python 3.6.5, JGRASP was using the previous version, how can I use the new version on JGRASP?","By default, jGRASP will use the first ""python"" on the system path. +The new version probably only exists as ""python3"". If that is the case, install jGRASP 2.0.5 Beta if you are using 2.0.4 or a 2.0.5 Alpha. Then, go to ""Settings"" > ""Compiler Settings"" > ""Workspace"", select language ""Python"" if not already selected, select environment ""Python 3 (python 3) - generic"", hit ""Use"" button, and ""OK"" the dialog.",0.0,False,1,5584 +2018-06-25 13:30:47.293,Passing command line parameters to python script from html page,"I have a html page with text box and submit button. When somebody enters data in text box and click submit, i have to pass that value to a python script which does some operation and print output. Can someone let me now how to achieve this. I did some research on stackoverflow/google but nothing conclusive. I have python 2.7, Windows 10 and Apache tomcat. Any help would be greatly appreciated. +Thanks, +Jagadeesh.K","Short answer: You can't just run a python script in the clients browser. It doesn't work that way. +If you want to execute some python when the user does something, you will have to run a web app like the other answer suggested.",0.0,False,1,5585 +2018-06-26 09:53:17.980,How to uninstall (mini)conda entirely on Windows,"I was surprised to be unable to find any information anywhere on the web on how to do this properly, but I suppose my surprise ought to be mitigated by the fact that normally this can be done via Microsoft's 'Add or Remove Programs' via the Control Panel. +This option is not available to me at this time, since I had installed Python again elsewhere (without having uninstalled it), then uninstalled that installation the standard way. Now, despite no option for uninstalling conda via the Control Panel, conda persists in my command line. +Now, the goal is to remove every trace of it, to end up in a state as though conda never existed on my machine in the first place before I reinstall it to the necessary location. +I have a bad feeling that if I simply delete the files and then reinstall, this will cause problems. Does anyone have any guidance in how to achieve the above?","Open the folder where you installed miniconda, and then search for uninstall.exe. Open that it will erase miniconda for you.",0.9950547536867304,False,1,5586 +2018-06-27 02:35:38.367,"protobuf, and tensorflow installation, which version to choose","I already installed python3.5.2, tensorflow(with python3.5.2). +I want to install protobuf now. However, protobuf supports python3.5.0; 3.5.1; and 3.6.0 +I wonder which version should I install. +My question is should I upgrade python3.5.2 to python3.6, or downgrade it to python3.5.1. +I see some people are trying downgrade python3.6 to python3.5 +I googled how to change python3.5.2 to python3.5.1, but no valuable information. I guess this is not usual option.","So it is version problem +one google post says change python version to a more general version. +I am not sure how to change python3.5.2 to python3.5.1 +I just installed procobuf3.6 +I hope it works",0.0,False,1,5587 +2018-06-27 06:09:44.330,How to Resume Python Script After System Reboot?,"I'm still new to writing scripts with Python and would really appreciate some guidance. +I'm wondering how to continue executing my Python script from where it left off after a system restart. +The script essentially alternates between restarting and executing a task for example: restart the system, open an application and execute a task, restart the system, open another application and execute another task, etc... +But the issue is that once the system restarts and logs back in, all applications shut down including the terminal so the script stops running and never executes the following task. The program shuts down early without an error so the logs are not really of much use. Is there any way to reopen the script and continue from where it left off or prevent applications from being closed during a reboot ? Any guidance on the issue would be appreciated. +Thanks! +Also, I'm using a Mac running High Sierra for reference.","You could write your current progress to a file just before you reboot and read said file on Programm start. +About the automatic restart of the script after reboot: you could have the script to put itself in the Autostart of your system and after everything is done remove itself from it.",0.0,False,1,5588 +2018-06-29 09:49:04.483,Incorrect UTC date in MongoDB Compass,"I package my python (flask) application with docker. Within my app I'm generating UTC date with datetime library using datetime.utcnow(). +Unfortunately, when I inspect saved data with MongoDB Compass the UTC date is offset two hours (to my local time zone). All my docker containers have time zone set to Etc/UTC. Morover, mongoengine connection to MongoDB uses tz_aware=False and tzinfo=None, what prevents on fly date conversions. +Where does the offset come from and how to fix it?","Finally, after trying to prove myself wrong, and hairless head I found the cause and solution for my problem. +We are living in the world of illusion and what you see is not what you get!!!. I decided to inspect my data over mongo shell client +rather than MongoDB Compass GUI. I figure out that data that arrived to database contained correct UTC date. This narrowed all my previous +assumption that there has to be something wrong with my python application, and environment that the application is living in. What left was MongoDB Compass itself. +After changing time zone on my machine to a random time zone, and refreshing collection within MongoDB Compass, displayed UTC date changed to a date that fits random time zone. +Be aware that MongoDB Copass displays whatever is saved in database Date field, enlarged about your machine's time zone. Example, if you saved UTC time equivalent to 8:00 am, +and your machine's time zone is Europe/Warsaw then MongoDB Compass will display 10:00am.",1.2,True,1,5589 +2018-07-01 07:10:49.220,How to replace all string in all columns using pandas?,"In pandas, how do I replace & with '&' from all columns where & could be in any position in a string? +For example, in column Title if there is a value 'Good & bad', how do I replace it with 'Good & bad'?","Try this +df['Title'] = titanic_df['Title'].replace(""&"", ""&"")",0.0,False,1,5590 +2018-07-01 23:33:29.923,Binance API: how to get the USD as the quote asset,"I'm wondering what the symbol is or if I am even able to get historical price data on BTC, ETH, etc. denominated in United States Dollars. +right now when if I'm making a call to client such as: +Client.get_symbol_info('BTCUSD') +it returns nothing +Does anyone have any idea how to get this info? Thanks!","You can not make trades in Binance with dollars but instead with Tether(USDT) that is a cryptocurrency that is backed 1-to-1 with dollar. +To solve that use BTCUSDT +Change BTCUSD to BTCUSDT",0.9950547536867304,False,1,5591 +2018-07-02 10:22:40.247,How can i scale a thickness of a character in image using python OpenCV?,"I created one task, where I have white background and black digits. +I need to take the largest by thickness digit. I have made my picture bw, recognized all symbols, but I don't understand, how to scale thickness. I have tried arcLength(contours), but it gave me the largest by size. I have tried morphological operations, but as I undestood, it helps to remove noises and another mistakes in picture, right? And I had a thought to check the distance between neighbour points of contours, but then I thought that it would be hard because of not exact and clear form of symbols(I draw tnem on paint). So, that's all Ideas, that I had. Can you help me in this question by telling names of themes in Comp. vision and OpenCV, that could help me to solve this task? I don't need exact algorithm of solution, only themes. And if that's not OpenCV task, so which is? What library? Should I learn some pack of themes and basics before the solution of my task?","One possible solution that I can think of is to alternate erosion and find contours till you have only one contour left (that should be the thicker). This could work if the difference in thickness is enough, but I can also foresee many particular cases that can prevent a correct identification, so it depends very much on how is your original image.",0.2012947653214861,False,1,5592 +2018-07-02 13:55:01.080,"django inspectdb, how to write multiple table name during inspection","When I first execute this command it create model in my model.py but when I call it second time for another table in same model.py file then that second table replace model of first can anyone told the reason behind that because I am not able to find perfect solution for that? +$ python manage.py inspectdb tablename > v1/projectname/models.py +When executing this command second time for another table then it replace first table name. +$ python manage.py inspectdb tablename2 > v1/projectname/models.py","python manage.py inspectdb table1 table2 table3... > app_name/models.py +Apply this command for inspection of multiple tables of one database in django.",0.0,False,1,5593 +2018-07-02 17:04:29.297,Count Specific Values in Dataframe,"If I had a column in a dataframe, and that column contained two possible categorical variables, how do I count how many times each variable appeared? +So e.g, how do I count how many of the participants in the study were male or female? +I've tried value_counts, groupby, len etc, but seem to be getting it wrong. +Thanks","You could use len([x for x in df[""Sex""] if x == ""Male""). This iterates through the Sex column of your dataframe and determines whether an element is ""Male"" or not. If it is, it is appended to a list via list comprehension. The length of that list is the number of Males in your dataframe.",0.0,False,1,5594 +2018-07-03 17:27:42.043,Which newline character is in my CSV?,"We receive a .tar.gz file from a client every day and I am rewriting our import process using SSIS. One of the first steps in my process is to unzip the .tar.gz file which I achieve via a Python script. +After unzipping we are left with a number of CSV files which I then import into SQL Server. As an aside, I am loading using the CozyRoc DataFlow Task Plus. +Most of my CSV files load without issue but I have five files which fail. By reading the log I can see that the process is reading the Header and First line as though there is no HeaderRow Delimiter (i.e. it is trying to import the column header as ColumnHeader1ColumnValue1 +I took one of these CSVs, copied the top 5 rows into Excel, used Text-To-Columns to delimit the data then saved that as a new CSV file. +This version imported successfully. +That makes me think that somehow the original CSV isn't using {CR}{LF} as the row delimiter but I don't know how to check. Any suggestions?","Seeing that you have EmEditor, you can use EmEditor to find the eol character in two ways: + +Use View > Character Code Value... at the end of a line to display a dialog box showing information about the character at the current position. +Go to View > Marks and turn on Newline Characters and CR and LF with Different Marks to show the eol while editing. LF is displayed with a down arrow while CRLF is a right angle. + +Some other things you could try checking for are: file encoding, wrong type of data for a field and an inconsistent number of columns.",0.0,False,1,5595 +2018-07-03 18:21:44.653,Calling custom C subroutines in a Python application,"I have two custom-written C routines that I would like to use as a part of a large Python application. I would prefer not to rewrite the C code in pure Python (or Cython, etc.), especially to maintain speed. +What is the cleanest, easiest way that I can use my C code from my Python code? Or, what is the cleanest, easiest way for me to wrap my C code for use in my Python source? +I know ""cleanest"" and ""easiest"" will attract opinions, but I really just need some good options for using custom pre-written code, versus many of the other answers/tutorials which describe how to use full-on C libraries as CPython extensions. +EDIT: +Cython and ctypes have both been suggested. Which is a better choice in my case? Each of the two routines I mentioned originally are very computationally intensive. They are used for image calculations and reconstructions, so my plan is to build a Python application around their use (with other functionality in mind that I already have in Python) with the C code run as needed for processing.","Use cython to wrap your C code. In other words, create a CPython extension using Cython, that calls your C code.",1.2,True,1,5596 +2018-07-04 00:03:40.780,kubernetes architecture for microservices application - suggestions,"I have been asked to create a system which has different functionalities. Assume service 1, service 2 and service 3. I need to run these services per hour to do something. +To make the system of those services I need: database, web interface for seeing the result of the process, caching and etc. +This is what I have thought about so far: + +I need kubernetes to orchestrate my services which are packaged as docker containers. I will deploy mySql to save my data and I can use Redis cache for caching. +My service are written by python scripts and Java and need to interact with each other through APIs. +I think I can use AWS EKS for my kubernetes cluster + + +this is what I need to know: + +how to deploy python or Java applications and connect them to each other and also connect them to a database service +I also need to know how to schedule the application to run per hour so I can see the results in the web interface. + +Please shoot any ideas or questions you have. +Any help would be appreciated.","For python/java applications, create docker images for both applications. If these application run forever to serve traffic then deploy them as deployments.If you need to have only cron like functionality, deploy as Job in kubernetes. +To make services accessible, create services as selector for applications, so these services can route traffic to specific applications. +Database or cache should be exposed as service endpoints so your applications are environment independent.",0.3869120172231254,False,1,5597 +2018-07-04 12:45:42.993,search_s search_ext_s search_s methods of python-ldap library doesn't return any Success response code,"I am using search_ext_s() method of python-ldap to search results on the basis of filter_query, upon completion of search I get msg_id which I passed in result function like this ldap_object.result(msg_id) this returns tuple like this (100, attributes values) which is correct(I also tried result2, result3, result4 method of LDAP object), But how can I get response code for ldap search request, also if there are no result for given filter_criteria I get empty list whereas in case of exception I get proper message like this +ldap.SERVER_DOWN: {u'info': 'Transport endpoint is not connected', 'errno': 107, 'desc': u""Can't contact LDAP server""} +Can somebody please help me if there exists any attribute which can give result code for successful LDAP search operation. +Thanks, +Radhika","An LDAP server simply may not return any results, even if there was nothing wrong with the search operation sent by the client. With python-ldap you get an empty result list. Most times this is due to access control hiding directory content. In general the LDAP server won't tell you why it did not return results. +(There are some special cases where ldap.INSUFFICIENT_ACCESS is raised but you should expect the behaviour to be different when using different LDAP servers.) +In python-ldap if the search operation did not raise an exception the LDAP result code was ok(0). So your application has to deal with an empty search result in some application-specific way, e.g. by also raising a custom exception handled by upper layers.",1.2,True,1,5598 +2018-07-06 07:29:16.617,How to find dot product of two very large matrices to avoid memory error?,"I am trying to learn ML using Kaggle datasets. In one of the problems (using Logistic regression) inputs and parameters matrices are of size (1110001, 8) & (2122640, 8) respectively. +I am getting memory error while doing it in python. This would be same for any language I guess since it's too big. My question is how do they multiply matrices in real life ML implementations (since it would usually be this big)? +Things bugging me : + +Some ppl in SO have suggested to calculate dot product in parts and then combine. But even then matrix would be still too big for RAM (9.42TB? in this case) + +And If I write it to a file wouldn't it be too slow for optimization algorithms to read from file and minimize function? + +Even if I do write it to file how would fmin_bfgs(or any opt. function) read from file? + +Also Kaggle notebook shows only 1GB of storage available. I don't think anyone would allow TBs of storage space. + +In my input matrix many rows have similar values for some columns. Can I use it my advantage to save space? (like sparse matrix for zeros in matrix) +Can anyone point me to any real life sample implementation of such cases. Thanks!","I have tried many things. I will be mentioning these here, if anyone needs them in future: + +I had already cleaned up data like removing duplicates and +irrelevant records depending on given problem etc. +I have stored large matrices which hold mostly 0s as sparse matrix. +I implemented the gradient descent using mini-batch method instead of plain old Batch method (theta.T dot X). + +Now everything is working fine.",1.2,True,1,5599 +2018-07-06 17:58:05.770,Python Unit test debugging in VS code,"I use VS code for my Python projects and we have unit tests written using Python's unittest module. I am facing a weird issue with debugging unit tests. +VSCode Version: May 2018 (1.24) +OS Version: Windows 10 +Let's say I have 20 unit tests in a particular project. +I run the tests by right clicking on a unit test file and click 'Run all unit tests' +After the run is complete, the results bar displays how many tests are passed and how many are failed. (e.g. 15 passed, 5 failed). +And I can run/debug individual test because there is a small link on every unit test function for that. +If I re-run the tests from same file, then the results bar displays the twice number of tests. (e.g. 30 passed, 10 failed) +Also the links against individual test functions disappear. So I cannot run individual tests. +The only way to be able to run/debug individual tests after this is by re-launching the VS code. +Any suggestions on how to fix this?",This was a bug in Python extension for VS code and it is fixed now.,1.2,True,1,5600 +2018-07-08 23:33:21.993,Wondering how I can delete all of my python related files on Mac,"So I was trying to install kivy, which lead me to install pip, and I went down a rabbit hole of altering directories. I am using PyCharm for the record. +I would like to remove everything python related (including all libraries like pip) from my computer, and start fresh with empty directories, so when I download pycharm again, there will be no issues. +I am using a Mac, so if any of you could let me know how to do that on a Mac, it would be greatly appreciated. +Could I just open finder, search python, and delete all of the files (there are tons) or would that be too destructive? +I hope I am making my situation clear enough, please comment any questions to clarify things. +Thanks!","If you are familiar with the Terminal app, you can use command lines to uninstall Python from your Mac. For this, follow these steps: + + +Move Python to Trash. +Open the Terminal app and type the following command line in the window: ~ alexa$ sudo rm -rf /Applications/Python\ 3.6/ +It will require you to enter your administrator password to confirm the deletion. + + +And for the PyCharm: + +Just remove the ~/Library/Caches/PyCharm20 and + ~/Library/Preferences/PyCharm20 directories. + +Or if that won't be enough: + + +Go to Applications > right click PyCharm > move to trash +open a terminal and run the following: find ~/Library/ -iname ""pycharm"" +verify that all of the results are in fact related to PyCharm and not something else important you need to keep. Then, remove them all + using the command: find ~/Library -iname ""pycharm"" -exec rm -r ""{}"" + \;",0.3869120172231254,False,1,5601 +2018-07-10 09:58:49.683,Lost artwork while converting .m4a to .mp3 (Python),"I'm trying to convert m4a audio file with artwork (cover) to mp3. I'm using ffmpeg to convert the audio. +Once it copies, the artwork is lost. I'm quite not sure, how to retain the cover. I found some reference about mutagen library but not sure again how to use to copy the artwork. +Any help would be great. + +ffmpeg -i source/file -acodec libmp3lame -ab 128k destination.mp3 + +Update: +I'm reading the artwork and m4a to be able to attache it back. +I can get the artwork by using + +artwork = audio.tags['covr'] + +Now my problem is how do I save the artwork as image in a new file? +I tried the Following: + +with open(path/to/write, 'wb') as img: + img.write(artwork) + +This gives me an error + +'list' does not support the buffer interface line + +Any suggestion, how I can save the artwork extracted covr data?","If anyone is having the same issue; +I ended up reading the artwork from original file and attaching it back to mp3 + +if audioFileNameWithM4AExtension.startswith(""covr""): #checks if it has cover + cover = audioFileNameWithM4AExtension.tags['covr'][0] #gets the cover",0.0,False,1,5602 +2018-07-10 15:26:20.883,Use proxy sentences from cleaned data,"Gensim's Word2Vec model takes as an input a list of lists with the inner list containing individual tokens/words of a sentence. As I understand Word2Vec is used to ""quantify"" the context of words within a text using vectors. +I am currently dealing with a corpus of text that has already been split into individual tokens and no longer contains an obvious sentence format (punctuation has been removed). I was wondering how should I input this into the Word2Vec model? +Say if I simply split the corpus into ""sentences"" of uniform length (10 tokens per sentence for example), would this be a good way of inputting the data into the model? +Essentially, I am wondering how the format of the input sentences (list of lists) affects the output of Word2Vec?","That sounds like a reasonable solution. If you have access to data that is similar to your cleaned data you could get average sentence length from that data set. Otherwise, you could find other data in the language you are working with (from wikipedia or another source) and get average sentence length from there. +Of course your output vectors will not be as reliable as if you had the correct sentence boundaries, but it sounds like word order was preserved so there shouldn't be too much noise from incorrect sentence boundaries.",0.2012947653214861,False,1,5603 +2018-07-10 19:19:58.840,"Python: ContextualVersionConflict: pandas 0.22.0; Requirement.parse('pandas<0.22,>=0.19'), {'scikit-survival'})","I have this issue: + +ContextualVersionConflict: (pandas 0.22.0 (...), + Requirement.parse('pandas<0.22,>=0.19'), {'scikit-survival'}) + +I have even tried to uninstall pandas and install scikit-survival + dependencies via anaconda. But it still does not work.... +Anyone with a suggestion on how to fix? +Thanks!",Restarting jupyter notebook fixed it. But I am unsure why this would fix it?,0.9999092042625952,False,1,5604 +2018-07-11 15:01:09.260,How do I calculate the percentage of difference between two images using Python and OpenCV?,"I am trying to write a program in Python (with OpenCV) that compares 2 images, shows the difference between them, and then informs the user of the percentage of difference between the images. I have already made it so it generates a .jpg showing the difference, but I can't figure out how to make it calculate a percentage. Does anyone know how to do this? +Thanks in advance.",You will need to calculate this on your own. You will need the count of diferent pixels and the size of your original image then a simple math: (diferentPixelsCount / (mainImage.width * mainImage.height))*100,0.0,False,1,5605 +2018-07-11 21:22:40.900,How to import 'cluster' and 'pylab' into Pycharm,I would like to use Pycharm to write some data science code and I am using Visual Studio Code and run it from terminal. But I would like to know if I could do it on Pycharm? I could not find some modules such as cluster and pylab on Pycharm? Anyone knows how I could import these modules into Pycharm?,"Go to the Preferences Tab -> Project Interpreter, there's a + symbol that allows you to view and download packages. From there you should be able to find cluster and pylab and install them to PyCharm's interpreter. After that you can import them and run them in your scripts. +Alternatively, you may switch the project's interpreter to an interpreter that has the packages installed already. This can be done from that same menu.",0.1352210990936997,False,1,5606 +2018-07-14 17:06:41.383,"Multiple Inputs for CNN: images and parameters, how to merge","I use Keras for a CNN and have two types of Inputs: Images of objects, and one or two more parameters describing the object (e.g. weight). How can I train my network with both data sources? Concatenation doesn't seem to work because the inputs have different dimensions. My idea was to concatenate the output of the image analysis and the parameters somehow, before sending it into the dense layers, but I'm not sure how. Or is it possible to merge two classifications in Keras, i.e. classifying the image and the parameter and then merging the classification somehow?","You can use Concatenation layer to merge two inputs. Make sure you're converting multiple inputs into same shape; you can do this by adding additional Dense layer to either of your inputs, so that you can get equal length end layers. Use those same shape outputs in Concatenation layer.",1.2,True,1,5607 +2018-07-14 20:27:44.470,How to analyse the integrity of clustering with no ground truth labels?,"I'm clustering data (trying out multiple algorithms) and trying to evaluate the coherence/integrity of the resulting clusters from each algorithm. I do not have any ground truth labels, which rules out quite a few metrics for analysing the performance. +So far, I've been using Silhouette score as well as calinski harabaz score (from sklearn). With these scores, however, I can only compare the integrity of the clustering if my labels produced from an algorithm propose there to be at minimum, 2 clusters - but some of my algorithms propose that one cluster is the most reliable. +Thus, if you don't have any ground truth labels, how do you assess whether the proposed clustering by an algorithm is better than if all of the data was assigned in just one cluster?","Don't just rely on some heuristic, that someone proposed for a very different problem. +Key to clustering is to carefully consider the problem that you are working on. What is the proper way of proposing the data? How to scale (or not scale)? How to measure the similarity of two records in a way that it quantifies something meaningful for your domain. +It is not about choosing the right algorithm; your task is to do the math that relates your domain problem to what the algorithm does. Don't treat it as a black box. Choosing the approach based on the evaluation step does not work: it is already too late; you probably did some bad decisions already in the preprocessing, used the wrong distance, scaling, and other parameters.",0.0,False,1,5608 +2018-07-15 06:08:43.183,how to run python code in atom in a terminal?,"I'm a beginner in programming and atom so when try to run my python code written in the atom in terminal I don't know how...i tried installing packages like run-in-terminal,platformio-ide-terminal but I don't know how to use them.","I would not try to do it using extensions. I would use the platformio-ide-terminal and just do it from the command line. +Just type: Python script_name.py and it should run fine. Be sure you are in the same directory as your python script.",0.1352210990936997,False,3,5609 +2018-07-15 06:08:43.183,how to run python code in atom in a terminal?,"I'm a beginner in programming and atom so when try to run my python code written in the atom in terminal I don't know how...i tried installing packages like run-in-terminal,platformio-ide-terminal but I don't know how to use them.","Save your Script as a .py file in a directory. +Open the terminal and navigate to the directory containing your script using cd command. +Run python .py if you are using python2 +Run python3 if you are using python3",0.1352210990936997,False,3,5609 +2018-07-15 06:08:43.183,how to run python code in atom in a terminal?,"I'm a beginner in programming and atom so when try to run my python code written in the atom in terminal I don't know how...i tried installing packages like run-in-terminal,platformio-ide-terminal but I don't know how to use them.","""python filename.py"" should run your python code. If you wish to specifically run the program using python 3.6 then it would be ""python3.6 filename.py"".",0.0,False,3,5609 +2018-07-16 08:18:12.017,How to measure latency in paho-mqtt network,"I'm trying measure the latency from my publisher to my subscriber in an MQTT network. I was hoping to use the on_message() function to measure how long this trip takes but its not clear to me whether this callback comes after the broker receives the message or after the subscriber receives it? +Also does anyone else have any other suggestion on how to measure latency across the network?","I was involved in similar kind of work where I was supposed measure the latency in wireless sensor networks. There are different ways to measure the latencies. +If the subscriber and client are synchronized. + +Fill the payload with the time stamp value at the client and transmit +this packet to subscriber. At the subscriber again take the time +stamp and take the difference between the time stamp at the +subscriber and the timestamp value in the packet. +This gives the time taken for the packet to reach subscriber from +client. + +If the subscriber and client are not synchronized. +In this case measurement of latency is little tricky. Assuming the network is symmetrical. + +Start the timer at client before sending the packet to subscriber. +Configure subscriber to echo back the message to client. Stop the +timer at the client take the difference in clock ticks. This time +represents the round trip time you divide it by two to get one +direction latency.",0.5457054096481145,False,2,5610 +2018-07-16 08:18:12.017,How to measure latency in paho-mqtt network,"I'm trying measure the latency from my publisher to my subscriber in an MQTT network. I was hoping to use the on_message() function to measure how long this trip takes but its not clear to me whether this callback comes after the broker receives the message or after the subscriber receives it? +Also does anyone else have any other suggestion on how to measure latency across the network?","on_message() is called on the subscriber when the message reaches the subscriber. +One way to measure latency is to do a loop back publish in the same client e.g. + +Setup a client +Subscribe to a given topic +Publish a message to the topic and record the current (high resolution) timestamp. +When on_message() is called record the time again + +It is worth pointing out that this sort of test assumes that both publisher/subscriber will be on similar networks (e.g. not cellular vs gigabit fibre). +Also latency will be influenced by the load on the broker and the number of subscribers to a given topic. +The other option is to measure latency passively by monitoring the network assuming you can see all the traffic from one location as synchronising clocks across monitoring point is very difficult.",0.3869120172231254,False,2,5610 +2018-07-16 13:07:02.643,Brief explanation on tensorflow object detection working mechanism,"I've searched for working mechanism of tensorflow object detection in google. I've searched how tensorflow train models with dataset. It give me suggestion about how to implement rather than how it works. +Can anyone explain how dataset are trained in fit into models?","You can't ""simply"" understand how Tensorflow works without a good background on Artificial Intelligence and Machine Learning. +I suggest you start working on those topics. Tensorflow will get much easier to understand and to handle after that.",0.0,False,1,5611 +2018-07-16 16:38:23.357,fetch data from 3rd party API - Single Responsibility Principle in Django,"What's the most elegant way to fetch data from an external API if I want to be faithful to the Single Responsibility Principle? Where/when exactly should it be made? +Assuming I've got a POST /foo endpoint which after being called should somehow trigger a call to the external API and fetch/save some data from it in my local DB. +Should I add the call in the view? Or the Model?","I usually add any external API calls into dedicated services.py module (same level as your models.py that you're planning to save results into or common app if any of the existing are not logically related) +Inside that module you can use class called smth like MyExtarnalService and add all needed methods for fetching, posting, removing etc. just like you would do with drf api view. +Also remember to handle exceptions properly (timeouts, connection errors, error response codes) by defining custom error exception classes.",0.0,False,1,5612 +2018-07-16 18:35:21.250,What is the window length of moving average trend in seasonal.seasonal_decompose package?,"I am using seasonal.seasonal_decompose in python. +What is the window length of moving average trend in seasonal.seasonal_decompose package? +Based on my results, I think it is 25. But how can I be sure? how can I change this window length?","I found the answer. The ""freq"" part defines the window of moving average. Still not sure how the program choose the window when we do not declare it.",0.0,False,1,5613 +2018-07-17 10:48:39.477,How to retrain model in graph (.pb)?,"I have model saved in graph (.pb file). But now the model is inaccurate and I would like to develop it. I have pictures of additional data to learn, but I don't if it's possible or if it's how to do it? The result must be the modified of new data pb graph.","It's a good question. Actually it would be nice, if someone could explain how to do this. But in addition i can say you, that it would come to ""catastrophic forgetting"", so it wouldn't work out. You had to train all your data again. +But anyway, i also would like to know that espacially for ssd, just for test reasons.",0.5457054096481145,False,1,5614 +2018-07-17 10:52:00.203,Django - how to send mail 5 days before event?,"I'm Junior Django Dev. Got my first project. Doing quite well but senior dev that teaches me went on vacations.... +I have a Task in my company to create a function that will remind all people in specyfic Group, 5 days before event by sending mail. +There is a TournamentModel that contains a tournament_start_date for instance '10.08.2018'. +Player can join tournament, when he does he joins django group ""Registered"". +I have to create a function (job?) that will check tournament_start_date and if tournament begins in 5 days, this function will send emails to all people in ""Registered"" Group... automatically. +How can I do this? What should I use? How to run it and it will automatically check? I'm learning python/django for few months... but I meet jobs fot the first time ;/ +I will appreciate any help.",You can set this mail send function as cron job。You can schedule it by crontab or Celery if Your team has used it.,0.2012947653214861,False,1,5615 +2018-07-19 12:11:04.380,how to change vs code python extension's language?,"My computer's system language is zh_cn, so the vs code python extension set the default language to chinese. But i want to change the language to english. +I can't find the reference in the doc or on the internet. Anyone konws how to do it? Thank's for help +PS: vs code's locale is alreay set to english.","You probably installed other python extensions for VSCode. Microsoft official python extension will follow the locale setting in user/workspace settings. +Try uninstall other python extensions, you may see it changes to English.",0.0,False,2,5616 +2018-07-19 12:11:04.380,how to change vs code python extension's language?,"My computer's system language is zh_cn, so the vs code python extension set the default language to chinese. But i want to change the language to english. +I can't find the reference in the doc or on the internet. Anyone konws how to do it? Thank's for help +PS: vs code's locale is alreay set to english.",When VScode is open go to View menu and select Command Palette. Once the command palette is open type display in the box. This should display the message configure display language. Open that and you should be in a local.json file. The variable local should be set to en for English.,0.0,False,2,5616 +2018-07-19 19:12:26.090,Python3 remove multiple hyphenations from a german string,"I'm currently working on a neural network that evaluates students' answers to exam questions. Therefore, preprocessing the corpora for a Word2Vec network is needed. Hyphenation in german texts is quite common. There are mainly two different types of hyphenation: +1) End of line: +The text reaches the end of the line so the last word is sepa- +rated. +2) Short form of enumeration: +in case of two ""elements"": +Geistes- und Sozialwissenschaften +more ""elements"": +Wirtschafts-, Geistes- und Sozialwissenschaften +The de-hyphenated form of these enumerations should be: +Geisteswissenschaften und Sozialwissenschaften +Wirtschaftswissenschaften, Geisteswissenschaften und Sozialwissenschaften +I need to remove all hyphenations and put the words back together. I already found several solutions for the first problem. +But I have absoluteley no clue how to get the second part (in the example above ""wissenschaften"") of the words in the enumeration problem. I don't even know if it is possible at all. +I hope that I have pointet out my problem properly. +So has anyone an idea how to solve this problem? +Thank you very much in advance!","It's surely possible, as the pattern seems fairly regular. (Something vaguely analogous is sometimes seen in English. For example: The new requirements applied to under-, over-, and average-performing employees.) +The rule seems to be roughly, ""when you see word-fragments with a trailing hyphen, and then an und, look for known words that begin with the word-fragments, and end the same as the terminal-word-after-und – and replace the word-fragments with the longer words"". +Not being a German speaker and without language-specific knowledge, it wouldn't be possible to know exactly where breaks are appropriate. That is, in your Geistes- und Sozialwissenschaften example, without language-specific knowledge, it's unclear whether the first fragment should become Geisteszialwissenschaften or Geisteswissenschaften or Geistesenschaften or Geiestesaften or any other shared-suffix with Sozialwissenschaften. But if you've got a dictionary of word-fragments, or word-frequency info from other text that uses the same full-length word(s) without this particular enumeration-hyphenation, that could help choose. +(If there's more than one plausible suffix based on known words, this might even be a possible application of word2vec: the best suffix to choose might well be the one that creates a known-word that is closest to the terminal-word in word-vector-space.) +Since this seems a very German-specific issue, I'd try asking in forums specific to German natural-language-processing, or to libraries with specific German support. (Maybe, NLTK or Spacy?) +But also, knowing word2vec, this sort of patch-up may not actually be that important to your end-goals. Training without this logical-reassembly of the intended full words may still let the fragments achieve useful vectors, and the corresponding full words may achieve useful vectors from other usages. The fragments may wind up close enough to the full compound words that they're ""good enough"" for whatever your next regression/classifier step does. So if this seems a blocker, don't be afraid to just try ignoring it as a non-problem. (Then if you later find an adequate de-hyphenation approach, you can test whether it really helped or not.)",0.3869120172231254,False,1,5617 +2018-07-20 10:26:17.870,Can't install tensorflow with pip or anaconda,"Does anyone know how to properly install tensorflow on Windows? +I'm currently using Python 3.7 (also tried with 3.6) and every time I get the same ""Could not find a version that satisfies the requirement tensorflow-gpu (from versions: ) +No matching distribution found for tensorflow-gpu"" error +I tried installing using pip and anaconda, both don't work for me. + +Found a solution, seems like Tensorflow doesn't support versions of python after 3.6.4. This is the version I'm currently using and it works.",Tensorflow or Tensorflow-gpu is supported only for 3.5.X versions of Python. Try installing with any Python 3.5.X version. This should fix your problem.,1.2,True,5,5618 +2018-07-20 10:26:17.870,Can't install tensorflow with pip or anaconda,"Does anyone know how to properly install tensorflow on Windows? +I'm currently using Python 3.7 (also tried with 3.6) and every time I get the same ""Could not find a version that satisfies the requirement tensorflow-gpu (from versions: ) +No matching distribution found for tensorflow-gpu"" error +I tried installing using pip and anaconda, both don't work for me. + +Found a solution, seems like Tensorflow doesn't support versions of python after 3.6.4. This is the version I'm currently using and it works.","You mentioned Anaconda. Do you run your python through there? +If so check in Anaconda Navigator --> Environments, if your current environment have got tensorflow installed. +If not, install tensorflow and run from that environment. +Should work.",0.0,False,5,5618 +2018-07-20 10:26:17.870,Can't install tensorflow with pip or anaconda,"Does anyone know how to properly install tensorflow on Windows? +I'm currently using Python 3.7 (also tried with 3.6) and every time I get the same ""Could not find a version that satisfies the requirement tensorflow-gpu (from versions: ) +No matching distribution found for tensorflow-gpu"" error +I tried installing using pip and anaconda, both don't work for me. + +Found a solution, seems like Tensorflow doesn't support versions of python after 3.6.4. This is the version I'm currently using and it works.","As of July 2019, I have installed it on python 3.7.3 using py -3 -m pip install tensorflow-gpu +py -3 in my installation selects the version 3.7.3. +The installation can also fail if the python installation is not 64 bit. Install a 64 bit version first.",0.0,False,5,5618 +2018-07-20 10:26:17.870,Can't install tensorflow with pip or anaconda,"Does anyone know how to properly install tensorflow on Windows? +I'm currently using Python 3.7 (also tried with 3.6) and every time I get the same ""Could not find a version that satisfies the requirement tensorflow-gpu (from versions: ) +No matching distribution found for tensorflow-gpu"" error +I tried installing using pip and anaconda, both don't work for me. + +Found a solution, seems like Tensorflow doesn't support versions of python after 3.6.4. This is the version I'm currently using and it works.","Actually the easiest way to install tensorflow is: +install python 3.5 (not 3.6 or 3.7) you can check wich version you have by typing ""python"" in the cmd. +When you install it check in the options that you install pip with it and you add it to variables environnement. +When its done just go into the cmd and tipe ""pip install tensorflow"" +It will download tensorflow automatically. +If you want to check that it's been installed type ""python"" in the cmd then some that "">>>"" will appear, then you write ""import tensorflow"" and if there's no error, you've done it!",0.0,False,5,5618 +2018-07-20 10:26:17.870,Can't install tensorflow with pip or anaconda,"Does anyone know how to properly install tensorflow on Windows? +I'm currently using Python 3.7 (also tried with 3.6) and every time I get the same ""Could not find a version that satisfies the requirement tensorflow-gpu (from versions: ) +No matching distribution found for tensorflow-gpu"" error +I tried installing using pip and anaconda, both don't work for me. + +Found a solution, seems like Tensorflow doesn't support versions of python after 3.6.4. This is the version I'm currently using and it works.","Not Enabling the Long Paths can be the potential problem.To solve that, +Steps include: + +Go to Registry Editor on the Windows Laptop + +Find the key ""HKEY_LOCAL_MACHINE""->""SYSTEM""->""CurrentControlSet""-> +""File System""->""LongPathsEnabled"" then double click on that option and change the value from 0 to 1. + + +3.Now try to install the tensorflow it will work.",0.0,False,5,5618 +2018-07-21 10:12:24.710,Chatterbot dynamic training,"I'm using chatter bot for implementing chat bot. I want Chatterbot to training the data set dynamically. +Whenever I run my code it should train itself from the beginning, because I require new data for every person who'll chat with my bot. +So how can I achieve this in python3 and on windows platform ? +what I want to achieve and problem I'm facing: +I've a python program which will create a text file student_record.txt, this will be generate from a data base and almost new when different student signup or login. In the chatter bot, I trained the bot using with giving this file name but it still replay from the previous trained data","I got the solution for that, I just deleted the data base on the beginning of the program thus new data base will create during the execution of the program. + I used the following command to delete the data base +import os + os.remove(""database_name"") +in my case +import os + os.remove(""db.sqlite3"") +thank you",0.0,False,1,5619 +2018-07-21 11:51:55.627,How do I use Google Cloud API's via Anaconda Spyder?,"I am pretty new to Python in general and recently started messing with the Google Cloud environment, specifically with the Natural Language API. +One thing that I just cant grasp is how do I make use of this environment, running scripts that use this API or any API from my local PC in this case my Anaconda Spyder environment? +I have my project setup, but from there I am not exactly sure, which steps are necessary. Do I have to include the authentication somehow in the Script inside Spyder? +Some insights would be really helpful.",First install the API by pip install or conda install in the scripts directory of anaconda and then simply import it into your code and start coding.,-0.2012947653214861,False,1,5620 +2018-07-21 16:20:50.893,How to open/create images in Python without using external modules,"I have a python script which opens an image file (.png or .ppm) using OpenCV, then loads all the RGB values into a multidimensional Python array (or list), performs some pixel by pixel calculations solely on the Python array (OpenCV is not used at all for this stage), then uses the newly created array (containing new RGB values) to write a new image file (.png here) using OpenCV again. Numpy is not used at all in this script. The program works fine. +The question is how to do this without using any external libraries, regardless whether they are for image processing or not (e.g. OpenCV, Numpy, Scipy, Pillow etc.). To summarize, I need to use bare bones Python's internal modules to: 1. open image and read the RGB values and 2. write a new image from pre-calculated RGB values. I will use Pypy instead of CPython for this purpose, to speed things up. +Note: I use Windows 10, if that matters.","Working with bare-bones .ppm files is trivial: you have three lines of text (P6, ""width height"", 255), and then you have the 3*width*height bytes of RGB. As long as you don't need more complicated variants of the .ppm format, you can write a loader and a saver in 5 lines of code each.",0.1016881243684853,False,1,5621 +2018-07-22 01:51:12.200,How run my code in spyder as i used to run it in linux terminal,"Apologies if my question is stupid. +I am a newbie is all aspects. +I used to run my python code straight from the terminal in Linux Ubuntu, +e.g. I just open the terminal go to my folder and run my command in my Linux terminal +CUDA_VISIBLE_DEVICES=0 python trainval_net.py --dataset pascal_voc --net resnet101 --epochs 7 --bs 1 --nw 4 --lr 1e-3 --lr_decay_step 5 --cuda +now im trying to use Spyder. +So for the same project i have a folder with bunch of functions/folders/stuff inside it. +So i just open that main folder as a new project, then i have noo idea how i can run my code... +There is a console in the right side of spyder which looks like Ipython and i can do stuff in there, but i cannot run the code that i run in terminal there. +In iphython or jupyther i used to usee ! at the begining of the command but here when i do it (e.g. !CUDA_VISIBLE_DEVICES=0 python trainval_net.py --dataset pascal_voc --net resnet101 --epochs 7 --bs 1 --nw 4 --lr 1e-3 --lr_decay_step 5 --cuda) it does not even know the modules and throw errors (e.g. ImportError: No module named numpy`) +Can anyone tell me how should i run my code here in Spyder +Thank you in advance! :)","Okay I figured it out. +I need to go to run->configure per file and in the command line options put the configuration (--dataset pascal_voc --net resnet101 --epochs 7 --bs 1 --nw 4 --lr 1e-3 --lr_decay_step 5 --cuda)",0.0,False,1,5622 +2018-07-22 04:44:09.413,How to use Midiutil to add multiple notes in one timespot (or how to add chords),I am using Midiutil to recreate a modified Bach contrapuntist melody and I am having difficulty finding a method for creating chords using Midiutil in python. Does anyone know a way to create chords using Midiuitl or if there is a way to create chords.,"A chord consists of multiple notes. +Just add multiple notes with the same timestamp.",1.2,True,1,5623 +2018-07-22 16:11:22.640,"PyCharm, stop the console from clearing every time you run the program","So I have just switched over from Spyder to PyCharm. In Spyder, each time you run the program, the console just gets added to, not cleared. This was very useful because I could look through the console to see how my changes to the code were changing the outputs of the program (obviously the console had a maximum length so stuff would get cleared eventually) +However in PyCharm each time I run the program the console is cleared. Surely there must be a way to change this, but I can't find the setting. Thanks.","In Spyder the output is there because you are running iPython. +In PyCharm you can get the same by pressing on View -> Scientific Mode. +Then every time you run you see a the new output and the history there.",0.3869120172231254,False,1,5624 +2018-07-23 00:44:09.343,dateutil 2.5.0 is the minimum required version,"I'm running the jupyter notebook (Enthought Canopy python distribution 2.7) on Mac OSX (v 10.13.6). When I try to import pandas (import pandas as pd), I am getting the complaint: ImportError: dateutil 2.5.0 is the minimum required version. I have these package versions: + +Canopy version 2.1.3.3542 (64 bit) +jupyter version 1.0.0-25 +pandas version 0.23.1-1 +python_dateutil version 2.6.0-1 + +I'm not getting this complaint when I run with the Canopy Editor so it must be some jupyter compatibility problem. Does anyone have a solution on how to fix this? All was well a few months ago until I recently (and mindlessly) allowed an update of my packages.","The issue is with the pandas lib +downgrade using the command below +pip install pandas==0.22.0",0.0,False,3,5625 +2018-07-23 00:44:09.343,dateutil 2.5.0 is the minimum required version,"I'm running the jupyter notebook (Enthought Canopy python distribution 2.7) on Mac OSX (v 10.13.6). When I try to import pandas (import pandas as pd), I am getting the complaint: ImportError: dateutil 2.5.0 is the minimum required version. I have these package versions: + +Canopy version 2.1.3.3542 (64 bit) +jupyter version 1.0.0-25 +pandas version 0.23.1-1 +python_dateutil version 2.6.0-1 + +I'm not getting this complaint when I run with the Canopy Editor so it must be some jupyter compatibility problem. Does anyone have a solution on how to fix this? All was well a few months ago until I recently (and mindlessly) allowed an update of my packages.","I had this same issue using the newest pandas version - downgrading to pandas 0.22.0 fixes the problem. +pip install pandas==0.22.0",0.2401167094949473,False,3,5625 +2018-07-23 00:44:09.343,dateutil 2.5.0 is the minimum required version,"I'm running the jupyter notebook (Enthought Canopy python distribution 2.7) on Mac OSX (v 10.13.6). When I try to import pandas (import pandas as pd), I am getting the complaint: ImportError: dateutil 2.5.0 is the minimum required version. I have these package versions: + +Canopy version 2.1.3.3542 (64 bit) +jupyter version 1.0.0-25 +pandas version 0.23.1-1 +python_dateutil version 2.6.0-1 + +I'm not getting this complaint when I run with the Canopy Editor so it must be some jupyter compatibility problem. Does anyone have a solution on how to fix this? All was well a few months ago until I recently (and mindlessly) allowed an update of my packages.","Installed Canopy version 2.1.9. The downloaded version worked without updating any of the packages called out by the Canopy Package Manager. Updated all the packages, but then the ""import pandas as pd"" failed when using the jupyter notebook. Downgraded the notebook package from 4.4.1-5 to 4.4.1-4 which cascaded to 35 additional package downgrades. Retested the import of pandas and the issue seems to have disappeared.",0.0,False,3,5625 +2018-07-23 17:57:30.150,CNN image extraction to predict a continuous value,"I have images of vehicles . I need to predict the price of the vehicle based on image extraction. +What I have learnt is , I can use CNN to extract the image features but what I am not able to get is, How to predict the prices of vehicles. +I know that the I need to train my CNN model before it predicts the price. +I don't know how to train the model with images along with prices . +In the end what I expect is , I will input an vehicle image and I need to get price of the vehicle. +Can any one provide the approach for this ?","I would use the CNN to predict the model of the car and then using a list of all the car prices it's easy enough to get the price, or if you dont care about the car model just use the prices as lables",0.0,False,1,5626 +2018-07-24 11:59:30.057,How can I handle Pepper robot shutdown event?,I need to handle the event when the shutdown process is started(for example with long press the robot's chest button or when the battery is critically low). The problem is that I didn't find a way to handle the shutdown/poweroff event. Do you have any idea how this can be done in some convenient way?,"Unfortunately this won't be possible as when you trigger a shutdown naoqi will exit as well and destroy your service. +If you are coding in c++ you could use a destructor, but there is no proper equivalent for python... +An alternative would be to execute some code when your script exits whatever the reason. For this you can start your script as a service and wait for ""the end"" using qiApplication.run(). This method will simply block until naoqi asks your service to exit. +Note: in case of shutdown, all services are being killed, so you cannot run any command from the robot API (as they are probably not available anymore!)",1.2,True,1,5627 +2018-07-24 16:25:19.637,Python - pandas / openpyxl: Tips on Automating Reports (Moving Away from VBA).,"I currently have macros set up to automate all my reports. However, some of my macros can take up to 5-10 minutes due to the size of my data. +I have been moving away from Excel/VBA to Python/pandas for data analysis and manipulation. I still use excel for data visualization (i.e., pivot tables). +I would like to know how other people use python to automate their reports? What do you guys do? Any tips on how I can start the process? +Majority of my macros do the following actions - + +Import text file(s) +Paste the raw data into a table that's linked to pivot tables / charts. +Refresh workbook +Save as new","When using python to automate reports I fully converted the report from Excel to Pandas. I use pd.read_csv or pd.read_excel to read in the data, and export the fully formatted pivot tables into excel for viewing. doing the 'paste into a table and refresh' is not handled well by python in my experience, and will likely still need macros to handle properly ie, export a csv with the formatted data from python then run a short macro to copy and paste. +if you have any more specific questions please ask, i have done a decent bit of this",0.0,False,1,5628 +2018-07-24 19:41:53.300,How to make RNN time-forecast multiple days using Keras?,"I am currently working on a program that would take the previous 4000 days of stock data about a particular stock and predict the next 90 days of performance. +The way I've elected to do this is with an RNN that makes use of LSTM layers to use the previous 90 days to predict the next day's performance (when training, the previous 90 days are the x-values and the next day is used as the y-value). What I would like to do however, is use the previous 90-180 days to predict all the values for the next 90 days. However, I am unsure of how to implement this in Keras as all the examples I have seen only predict the next day and then they may loop that prediction into the next day's 90 day x-values. +Is there any ways to just use the previous 180 days to predict the next 90? Or is the LSTM restricted to only predicting the next day?","I don't have the rep to comment, but I'll say here that I've toyed with a similar task. One could use a sliding window approach for 90 days (I used 30, since 90 is pushing LSTM limits), then predict the price appreciation for next month (so your prediction is for a single value). @Digital-Thinking is generally right though, you shouldn't expect great performance.",0.0,False,1,5629 +2018-07-24 21:28:16.190,How do you setup script RELOAD/RESTART upon file changes using bash?,"I have a Python Kafka worker run by a bash script in a Docker image inside a docker-compose setup that I need to reload and restart whenever a file in its directory changes, as I edit the code. Does anyone know how to accomplish this for a bash script? +Please don't merge this with the several answers about running a script whenever a file in a directory changes. I've seen other answers regarding this, but I can't find a way to run a script once, and then stop, reload and re-run it if any files change. +Thanks!","My suggestion is to let docker start a wrapper script that simply starts the real script in the background. +Then in an infinite loop: + +using inotifywait the wrapper waits for the appropriate change +then kills/stop/reload/... the child process +starts a new one in the background again.",1.2,True,1,5630 +2018-07-25 09:28:59.487,Creating an exe file for windows using mac for my Kivy app,"I've created a kivy app that works perfectly as I desire. It's got a few files in a particular folder that it uses. For the life of me, I don't understand how to create an exe on mac. I know I can use pyinstaller but how do I create an exe from mac. +Please help!","This is easy with Pyinstaller. I've used it recently. +Install pyinstaller + +pip install pyinstaller + +Hit following command on terminal where file.py is path to your main file + +pyinstaller -w -F file.py + +Your exe will be created inside a folder dist +NOTE : verified on windowns, not on mac",-0.3869120172231254,False,2,5631 +2018-07-25 09:28:59.487,Creating an exe file for windows using mac for my Kivy app,"I've created a kivy app that works perfectly as I desire. It's got a few files in a particular folder that it uses. For the life of me, I don't understand how to create an exe on mac. I know I can use pyinstaller but how do I create an exe from mac. +Please help!","For pyinstaller, they have stated that packaging Windows binaries while running under OS X is NOT supported, and recommended to use Wine for this. + + +Can I package Windows binaries while running under Linux? + +No, this is not supported. Please use Wine for this, PyInstaller runs + fine in Wine. You may also want to have a look at this thread in the + mailinglist. In version 1.4 we had build in some support for this, but + it showed to work only half. It would require some Windows system on + another partition and would only work for pure Python programs. As + soon as you want a decent GUI (gtk, qt, wx), you would need to install + Windows libraries anyhow. So it's much easier to just use Wine. + +Can I package Windows binaries while running under OS X? + +No, this is not supported. Please try Wine for this. + +Can I package OS X binaries while running under Linux? + +This is currently not possible at all. Sorry! If you want to help out, + you are very welcome.",0.2012947653214861,False,2,5631 +2018-07-25 12:50:07.533,Python Redis on Heroku reached max clients,"I am writing a server with multiple gunicorn workers and want to let them all have access to a specific variable. I'm using Redis to do this(it's in RAM, so it's fast, right?) but every GET or SET request adds another client. I'm performing maybe ~150 requests per second, so it quickly reaches the 25 connection limit that Heroku has. To access the database, I'm using db = redis.from_url(os.environ.get(""REDIS_URL"")) and then db.set() and db.get(). Is there a way to lower that number? For instance, by using the same connection over and over again for each worker? But how would I do that? The 3 gunicorn workers I have are performing around 50 queries each per second. +If using redis is a bad idea(which it probably is), it would be great if you could suggest alternatives, but also please include a way to fix my current problem as most of my code is based off of it and I don't have enough time to rewrite the whole thing yet. +Note: The three pieces of code are the only times redis and db are called. I didn't do any configuration or anything. Maybe that info will help.","Most likely, your script creates a new connection for each request. +But each worker should create it once and use forever. +Which framework are you using? +It should have some documentation about how to configure Redis for your webapp. +P.S. Redis is a good choice to handle that :)",0.0,False,1,5632 +2018-07-25 18:37:23.550,Async HTTP server with scrapy and mongodb in python,"I am basically trying to start an HTTP server which will respond with content from a website which I can crawl using Scrapy. In order to start crawling the website I need to login to it and to do so I need to access a DB with credentials and such. The main issue here is that I need everything to be fully asynchronous and so far I am struggling to find a combination that will make everything work properly without many sloppy implementations. +I already got Klein + Scrapy working but when I get to implementing DB accesses I get all messed up in my head. Is there any way to make PyMongo asynchronous with twisted or something (yes, I have seen TxMongo but the documentation is quite bad and I would like to avoid it. I have also found an implementation with adbapi but I would like something more similar to PyMongo). +Trying to think things through the other way around I'm sure aiohttp has many more options to implement async db accesses and stuff but then I find myself at an impasse with Scrapy integration. +I have seen things like scrapa, scrapyd and ScrapyRT but those don't really work for me. Are there any other options? +Finally, if nothing works, I'll just use aiohttp and instead of Scrapy I'll do the requests to the websito to scrap manually and use beautifulsoup or something like that to get the info I need from the response. Any advice on how to proceed down that road? +Thanks for your attention, I'm quite a noob in this area so I don't know if I'm making complete sense. Regardless, any help will be appreciated :)","Is there any way to make pymongo asynchronous with twisted + +No. pymongo is designed as a synchronous library, and there is no way you can make it asynchronous without basically rewriting it (you could use threads or processes, but that is not what you asked, also you can run into issues with thread-safeness of the code). + +Trying to think things through the other way around I'm sure aiohttp has many more options to implement async db accesses and stuff + +It doesn't. aiohttp is a http library - it can do http asynchronously and that is all, it has nothing to help you access databases. You'd have to basically rewrite pymongo on top of it. + +Finally, if nothing works, I'll just use aiohttp and instead of scrapy I'll do the requests to the websito to scrap manually and use beautifulsoup or something like that to get the info I need from the response. + +That means lots of work for not using scrapy, and it won't help you with the pymongo issue - you still have to rewrite pymongo! +My suggestion is - learn txmongo! If you can't and want to rewrite it, use twisted.web to write it instead of aiohttp since then you can continue using scrapy!",1.2,True,1,5633 +2018-07-25 21:15:26.713,Python: How to plot an array of y values for one x value in python,"I am trying to plot an array of temperatures for different location during one day in python and want it to be graphed in the format (time, temperature_array). I am using matplotlib and currently only know how to graph 1 y value for an x value. +The temperature code looks like this: +Temperatures = [[Temp_array0] [Temp_array1] [Temp_array2]...], where each numbered array corresponds to that time and the temperature values in the array are at different latitudes and longitudes.","You can simply repeat the X values which are common for y values +Suppose +[x,x,x,x],[y1,y2,y3,y4]",0.0,False,1,5634 +2018-07-26 21:21:24.690,Triggering email out of Spotfire based on conditions,"Does anyone have experience with triggering an email from Spotfire based on a condition? Say, a sales figure falls below a certain threshold and an email gets sent to the appropriate distribution list. I want to know how involved this would be to do. I know that it can be done using an iron python script, but I'm curious if it can be done based on conditions rather than me hitting ""run""?","we actually have a product that does exactly this called the Spotfire Alerting Tool. it functions off of Automation Services and allows you to configure various thresholds for any metrics in the analysis, and then can notify users via email or even SMS. +of course there is the possibility of coding this yourself (the tool is simply an extension developed using the Spotfire SDK) but I can't comment on how to code it. +the best way to get this tool is probably to check with your TIBCO sales rep. if you'd like I can try to reach him on your behalf, but I'll need a bit more info from you. please contact me at nmaresco@tibco.com. +I hope this kind of answer is okay on SO. I don't have a way to reach you privately and this is the best answer I know how to give :)",0.3869120172231254,False,1,5635 +2018-07-27 00:49:39.630,"Scipy interp2d function produces z = f(x,y), I would like to solve for x","I am using the 2d interpolation function in scipy to smooth a 2d image. As I understand it, interpolate will return z = f(x,y). What I want to do is find x with known values of y and z. I tried something like this; +f = interp2d(x,y,z) +index = (np.abs(f(:,y) - z)).argmin() +However the interp2d object does not work that way. Any ideas on how to do this?","I was able to figure this out. yvalue, zvalue, xmin, and xmax are known values. By creating a linspace out of the possible values x can take on, a list can be created with all of the corresponding function values. Then using argmin() we can find the closest value in the list to the known z value. +f = interp2d(x,y,z) +xnew = numpy.linspace(xmin, xmax) +fnew = f(xnew, yvalue) +xindex = (numpy.abs(fnew - zvalue)).argmin() +xvalue = xnew(xindex)",0.0,False,1,5636 +2018-07-27 04:42:13.823,"How to set an start solution in Gurobi, when only objective function is known?","I have a minimization problem, that is modeled to be solved in Gurobi, via python. +Besides, I can calculate a ""good"" initial solution for the problem separately, that can be used as an upper bound for the problem. +What I want to do is to set Gurobi use this upper bound, to enhance its efficiency. I mean, if this upper bound can help Gurobi for its search. The point is that I just have the objective value, but not a complete solution. +Can anybody help me how to set this upper bound in the Gurobi? +Thanks.","I think that if you can calculate a good solution, you can also know some bound for your variable even you dont have the solution exactly ?",0.0,False,1,5637 +2018-07-28 15:56:50.503,Many to many relationship SQLite (studio or sql),"Hellow. It seems to me that I just don't understand something quite obvios in databases. +So, we have an author that write books and have books themselves. One author can write many books as well as one book could be written by many authors. +Thus, we have two tables 'Books' and 'Authors'. +In 'Authors' I have an 'ID'(Primary key) and 'Name', for example: +1 - L.Carrol +2 - D.Brown +In 'Books' - 'ID' (pr.key), 'Name' and 'Authors' (and this column is foreign key to the 'Authors' table ID) +1 - Some_name - 2 (L.Carol) +2 - Another_name - 2,1 (D.Brown, L.Carol) +And here is my stumbling block, cause i don't understand how to provide the possibility to choose several values from 'Authors' table to one column in 'Books' table.But this must be so simple, isn't it? +I've red about many-to-many relationship, saw many examples with added extra table to implement that, but still don't understand how to store multiple values from one table in the other's table column. Please, explain the logic, how should I do something like that ? I use SQLiteStudio but clear sql is appropriate too. Help ^(","You should have third intermediate table which will have following columns: + +id (primary) +author id (from Authors table) +book id (from Books table) + +This way you will be able to create a record which will map 1 author to 1 book. So you can have following records: + +1 ... Author1ID ... Book1ID +2 ... Author1ID ... Book2ID +3 ... Author2ID ... Book2ID + +AuthorXID and BookXID - foreign keys from corresponding tables. +So Book2 has 2 authors, Author1 has 2 books. +Also separate tables for Books and Authors don't need to contain any info about anything except itself. +Authors .. 1---Many .. BOOKSFORAUTHORS .. Many---1 .. Books",1.2,True,1,5638 +2018-07-28 23:43:19.713,Screen up time in desktop,"I might be sounding like a noob while asking this question but I really want to know how can I get the time from when my screen is on. Not the system up time but the screen up time. I want to use this time in a python app. So please tell me if there is any way to get that. Thanks in advance. +Edit- I want to get the time from when the display is black due to no activity and we move mouse or press a key and screen comes up, the display is up, the user is able to read and/or able to edit a document or play games. +OS is windows .","In Mac OS ioreg might have the information you're looking for. +ioreg -n IODisplayWrangler -r IODisplayWrangler -w 0 | grep IOPowerManagement",0.0,False,1,5639 +2018-07-29 11:14:44.810,Django Queryset find data between date,"I don't know what title should be, I just got stuck and need to ask. +I have a model called shift +and imagine the db_table like this: + +#table shift ++---------------+---------------+---------------+---------------+------------+------------+ +| start | end | off_start | off_end | time | user_id | ++---------------+---------------+---------------+---------------+------------+------------+ +| 2018-01-01 | 2018-01-05 | 2018-01-06 | 2018-01-07 | 07:00 | 1 | +| 2018-01-08 | 2018-01-14 | 2018-01-15 | Null | 12:00 | 1 | +| 2018-01-16 | 2018-01-20 | 2018-01-21 | 2018-01-22 | 18:00 | 1 | +| 2018-01-23 | 2018-01-27 | 2018-01-28 | 2018-01-31 | 24:00 | 1 | +| .... | .... | .... | .... | .... | .... | ++---------------+---------------+---------------+---------------+------------+------------+ + +if I use queryset with filter like start=2018-01-01 result will 07:00 +but how to get result 12:00 if I Input 2018-01-10 ?... +thank you!","Question isnt too clear, but maybe you're after something like +start__lte=2018-01-10, end__gte=2018-01-10?",1.2,True,1,5640 +2018-07-31 16:24:41.370,cannot run jupyter notebook from anaconda but able to run it from python,"After installing Anaconda to C:\ I cannot open jupyter notebook. Both in the Anaconda Prompt with jupyter notebook and inside the navigator. I just can't make it to work. It doesn't appear any line when I type jupyter notebook iniside the prompt. Neither does the navigator work. Then after that I reinstall Anaconda, didn't work either. +But then I try to reinstall jupyter notebook dependently using python -m install jupyter and then run python -m jupyter. It works and connect to the localhost:8888. So my question is that how can I make Jupyter works from Anaconda +Also note that my anaconda is not in the environment variable( or %PATH% ) and I have tried reinstalling pyzmq and it didn't solve the problem. I'm using Python 3.7 and 3.6.5 in Anaconda +Moreover, the spyder works perfectly","You need to activate the anaconda environment first. +In terminal: source activate environment_name, (or activate environment_name on windows?) +then jupyter notebook +If you don't know the env name, do conda list +to restore the default python environment: source deactivate",1.2,True,1,5641 +2018-07-31 16:30:46.247,Handling Error for Continuous Features in a Content-Based Filtering Recommender System,"I've got a content-based recommender that works... fine. I was fairly certain it was the right approach to take for this problem (matching established ""users"" with ""items"" that are virtually always new, but contain known features similar to existing items). +As I was researching, I found that virtually all examples of content-based filtering use articles/movies as an example and look exclusively at using encoded tf-idf features from blocks of text. That wasn't exactly what I was dealing with, but most of my features were boolean features, so making a similar vector and looking at cosine distance was not particularly difficult. I also had one continuous feature, which I scaled and included in the vector. As I said, it seemed to work, but was pretty iffy, and I think I know part of the reason why... +The continuous feature that I'm using is a rating (let's call this ""deliciousness""), where, in virtually all cases, a better score would indicate an item more favorable for the user. It's continuous, but it also has a clear ""direction"" (not sure if this is the correct terminology). Error in one direction is not the same as error in another. +I have cases where some users have given high ratings to items with mediocre ""deliciousness"" scores, but logically they would still prefer something that was more delicious. That user's vector might have an average deliciousness of 2.3. My understanding of cosine distance is that in my model, if that user encountered two new items that were exactly the same except that one had a deliciousness of 1.0 and the other had a deliciousness of 4.5, it would actually favor the former because it's a shorter distance between vectors. +How do I modify or incorporate some other kind of distance measure here that takes into account that deliciousness error/distance in one direction is not the same as error/distance in the other direction? +(As a secondary question, how do I decide how to best scale this continuous feature next to my boolean features?)","There are two basic approaches to solve this: +(1) Write your own distance function. The obvious approach is to remove the deliciousness element from each vector, evaluating that difference independently. Use cosine similarity on the rest of the vector. Combine that figure with the taste differential as desired. +(2) Transform your deliciousness data such that the resulting metric is linear. This will allow a ""normal"" distance metric to do its job as expected.",1.2,True,1,5642 +2018-07-31 22:16:11.853,How do i get Mac 10.13 to install modules into a 3.x install instead of 2.7,"I'm trying to learn python practically. +I installed PIP via easy_install and then I wanted to play with some mp3 files so I installed eyed3 via pip while in the project directory. Issue is that it installed the module into python 2.7 which comes standard with mac. I found this out as it keeps telling me that when a script does not run due to missing libraries like libmagic and no matter what I do, it keeps putting any libraries I install into 2.7 thus not being found when running python3. +My question is how to I get my system to pretty much ignore the 2.7 install and use the 3.7 install which I have. +I keep thinking I am doing something wrong as heaps of tutorials breeze over it and only one has so far mentioned that you get clashes between the versions. I really want to learn python and would appreciate some help getting past this blockage.","Have you tried pip3 install [module-name]? +Then you should be able to check which modules you've installed using pip3 freeze.",0.0,False,1,5643 +2018-08-01 06:16:42.720,Any way to save format when importing an excel file in Python?,"I'm doing some work on the data in an excel sheet using python pandas. When I write and save the data it seems that pandas only saves and cares about the raw data on the import. Meaning a lot of stuff I really want to keep such as cell colouring, font size, borders, etc get lost. Does anyone know of a way to make pandas save such things? +From what I've read so far it doesn't appear to be possible. The best solution I've found so far is to use the xlsxwriter to format the file in my code before exporting. This seems like a very tedious task that will involve a lot of testing to figure out how to achieve the various formats and aesthetic changes I need. I haven't found anything but would said writer happen to in any way be able to save the sheet format upon import? +Alternatively, what would you suggest I do to solve the problem that I have described?",Separate data from formatting. Have a sheet that contains only the data – that's the one you will be reading/writing to – and another that has formatting and reads the data from the first sheet.,0.0,False,1,5644 +2018-08-01 10:39:07.337,How backing file works in qcow2?,"qcow2 is an image for qemu and it's good to emulate. +I know how to write data for qcow2 format, but I don't know how backing files in qcow2 work? +I found nothing tutorial said this. +Can anyone give me tips?","Backing file is external snapshot for qcow2 and the qemu will write COW data in the new image. +For example: +You have image A and B, and A is backing file of B. +When you mount B to /dev/nbd and check its data, you'll find you can saw data of A. +That's because if there's no data in the range of B, qemu will read the same range of A. +An important notes: If qemu doesn't find A, you won't be able to mount B on /dev/nbd.",0.3869120172231254,False,1,5645 +2018-08-02 13:30:37.763,how to download many pdf files from google at once using python?,I want to download approximately 50 pdf files from the Internet using a python script. Can Google APIs help me anyhow?,"I am going to assume that you are downloading from Google drive. You can only download one file at a time. You cant batch download of the actual file itself. +YOu could look into some kind of multi threading system and download the files at the same time that way but you man run into quota issues.",0.0,False,1,5646 +2018-08-03 12:50:35.807,how to use coverage run --source = {dir_name},"I have certain files in a directory named benchmarks and I want to get code coverage by running these source files. +I have tried using source flag in the following ways but it doesn't work. +coverage3 run --source=benchmarks +coverage3 run --source=benchmarks/ +On running, I always get Nothing to do. +Thanks","coverage run is like python. If you would run a file with python myprog.py, then you can use coverage run myprog.py.",1.2,True,1,5647 +2018-08-04 18:15:06.493,Discord.py get message embed,"How can I get the embed of a message to a variable with the ID of the message in discord.py? +I get the message with uzenet = await client.get_message(channel, id), but I don't know how to get it's embed.","To get the first Embed of your message, as you said that would be a dict(): +embedFromMessage = uzenet.embeds[0] +To transfer the dict() into an discord.Embed object: +embed = discord.Embed.from_data(embedFromMessage)",1.2,True,1,5648 +2018-08-04 22:59:50.310,How to use Windows credentials to connect remote desktop,"In my Python script I want to connect to remote server every time. So how can I use my windows credentials to connect to server without typing user ID and password. +By default it should read the userid/password from local system and will connect to remote server. +I tried with getuser() and getpass() but I have to enter the password everytime. I don't want to enter the password it should take automatically from local system password. +Any suggestions..",I am sorry this is not exactly an answer but I have looked on the web and I do not think you can write a code to automatically open Remote desktop without you having to enter the credentials but can you please edit the question so that I can see the code?,0.0,False,1,5649 +2018-08-07 05:02:59.393,On project task created do not send email,"By default subscribers get email messages once the new task in a project is created. How it can be tailored so that unless the projects has checkbox ""Send e-mail on new task"" checked it will not send e-mails on new task? +I know how to add a custom field to project.project model. But don't know the next step. +What action to override to not send the email when a new task is created and ""Send e-mail on new task"" is not checked for project?","I found that if project has notifications option "" +Visible by following customers"" enabled then one can configure subscription for each follower. +To not receive e-mails when new task is added to the project: unmark the checkbox ""Task opened"" in the ""Edit subscription of User"" form.",1.2,True,1,5650 +2018-08-08 05:01:22.287,How can I pack python into my project?,"I am making a program that will call python. I would like to add python in my project so users don't have to download python in order to use it, also it will be better to use the python that my program has so users don't have to download any dependency. +My program it's going to be writing in C++ (but can be any language) and I guess I have to call the python that is in the same path of my project? +Let's say that the system where the user is running already has python and he/she calls 'pip' i want the program to call pip provided by the python give it by my program and install it in the program directory instead of the system's python? +It's that possible? If it is how can I do it? +Real examples: +There are programs that offer a terminal where you can execute python to do things in the program like: + +Maya by Autodesk +Nuke by The foundry +Houdini by Side Effects + +Note: It has to be Cross-platform solution","In order to run python code, the runtime is sufficient. Under Windows, you can use py2exe to pack your program code together with the python runtime and all recessary dependencies. But pip cannot be used and it makes no sense, as you don't want to develop, but only use the python part. +To distribute the complete python installation, like Panda3D does, you'll have to include it in the chosen installer software.",0.1352210990936997,False,1,5651 +2018-08-08 06:15:54.700,Python app to organise ideas by tags,"Please give me a hint about how is it better to code a Python application which helps to organise ideas by tags. +Add a new idea: +Input 1: the idea +Input 2: corresponding tags +Search for the idea: +Input 1: one or multiple tags +As far as I understood, it's necessary to create an array with ideas and an array with tags. But how to connect them? For example, idea number 3 corresponds to tags number 1 and 2. So the question is: how to link these two arrays in the most simple and elegant way?","Have two dictionaries: + +Idea -> Set of Tags +Tag -> Set of Ideas + +When you add a new idea, add it to the first dictionary, and then update all the sets of the tags it uses in the second dictionary. This way you get easy lookup by both tag and idea.",0.0,False,1,5652 +2018-08-08 13:54:35.003,Does ImageDataGenerator add more images to my dataset?,"I'm trying to do image classification with the Inception V3 model. Does ImageDataGenerator from Keras create new images which are added onto my dataset? If I have 1000 images, will using this function double it to 2000 images which are used for training? Is there a way to know how many images were created and now fed into the model?","Let me try and tell u in the easiest way possible with the help of an example. +For example: + +you have a set of 500 images +you applied the ImageDataGenerator to the dataset with batch_size = 25 +now you run your model for lets say 5 epochs with +steps_per_epoch=total_samples/batch_size +so , steps_per_epoch will be equal to 20 +now your model will run on all 500 images (randomly transformed according to instructions provided to ImageDataGenerator) in each epoch",0.0,False,2,5653 +2018-08-08 13:54:35.003,Does ImageDataGenerator add more images to my dataset?,"I'm trying to do image classification with the Inception V3 model. Does ImageDataGenerator from Keras create new images which are added onto my dataset? If I have 1000 images, will using this function double it to 2000 images which are used for training? Is there a way to know how many images were created and now fed into the model?","Also note that: These augmented images are not stored in the memory, they are generated on the fly while training and lost after training. You can't read again those augmented images. +Not storing those images is a good idea because we'd run out of memory very soon storing huge no of images",0.1160922760327606,False,2,5653 +2018-08-09 09:03:04.903,Can I use JetBrains MPS in a web application?,"I am developing a small web application with Flask. This application needs a DSL, which can express the content of .pdf files. +I have developed a DSL with JetBrains MPS but now I'm not sure how to use it in my web application. Is it possible? Or should I consider to switch to another DSL or make my DSL directly in Python.","If you want to use MPS in the web frontend the simple answer is: no. +Since MPS is a projectional editor it needs a projection engine so that user can interact with the program/model. The projection engine of MPS is build in Java for desktop applications. There have been some efforts to put MPS on the web and build Java Script/HTML projection engine but none of the work is complete. So unless you would build something like that there is no way to use MPS in the frontend. +If your DSL is textual anyway and doesn't leverage the projectional nature of MPS I would go down the text DSL road with specialised tooling for that e.g. python as you suggested or Xtext.",1.2,True,1,5654 +2018-08-09 10:03:54.250,"How to solve error Expected singleton: purchase.order.line (57, 58, 59, 60, 61, 62, 63, 64)","I'm using odoo version 9 and I've created a module to customize the reports of purchase order. Among the fields that I want displayed in the reports is the supplier reference for article but when I add the code that displays this field + but it displays an error when I want to start printing the report +QWebException: ""Expected singleton: purchase.order.line(57, 58, 59, 60, 61, 62, 63, 64)"" while evaluating +""', '.join([str(x.product_code) for x in o.order_line.product_id.product_tmpl_id.seller_ids])"" +PS: I don't change anything in the module purchase. +I don't know how to fix this problem any idea for help please ?","It is because your purchase order got several orderlines and you are hoping that the order will have only one orderline. +o.orderline.product_id.product_tmpl_id.seller_ids +will work only if there is one orderline otherwise you have loop through each orderline. Here o.orderline will have multiple orderlines and you can get product_id from multiple orderline. If you try o.orderline[0].product_id.product_tmpl_id.seller_ids it will work but will get only first orderline details. Inorder to get all the orderline details you need to loop through it.",1.2,True,1,5655 +2018-08-10 09:07:10.620,how to convert tensorflow .meta .data .index to .ckpt file?,"As we know, when using tensorflow to save checkpoint, we have 3 files, for e.g.: +model.ckpt.data-00000-of-00001 +model.ckpt.index +model.ckpt.meta +I check on the faster rcnn and found that they have an evaluation.py script which helps evaluate the pre-trained model, but the script only accept .ckpt file (as they provided some pre-trained models above). +I have run some finetuning from their pre-trained model +And then I wonder if there's a way to convert all the .data-00000-of-00001, .index and .meta into one single .ckpt file to run the evaluate.py script on the checkpoint? +(I also notice that the pre-trained models they provided in the repo do have only 1 .ckpt file, how can they do that when the save-checkpoint function generates 3 files?)","These +{ +model.ckpt.data-00000-of-00001 +model.ckpt.index +model.ckpt.meta +} +are the more recent checkpoint format +while +{model.ckpt} +is a previous checkpoint format +It will be in the same concept as to convert a Nintendo Switch to NES ... Or a 3 pieces CD bundle to a single ROM cartridge...",0.0,False,1,5656 +2018-08-10 17:54:31.013,How do I write a script that configures an applications settings for me?,"I need help on how to write a script that configures an applications (VLC) settings to my needs without having to do it manually myself. The reason for this is because I will eventually need to start this application on boot with the correct settings already configured. +Steps I need done in the script. +1) I need to open the application. +2) Open the “Open Network Stream…” tab (Can be done with Ctrl+N). +3) Type a string of characters “String of characters” +4) Push “Enter” twice on the keyboard. +I’ve checked various websites across the internet and could not find any information regarding this. I am sure it’s possible but I am new to writing scripts and not too experienced. Are commands like the steps above possible to be completed in a script? +Note: Using Linux based OS (Raspbian). +Thank you.","Do whichever changes you want manually once on an arbitrary system, then make a copy of the application's configuration files (in this case ~/.config/vlc) +When you want to replicate the settings on a different machine, simply copy the settings to the same location.",1.2,True,1,5657 +2018-08-10 22:27:20.097,Python/Tkinter - Making The Background of a Textbox an Image?,"Since Text(Tk(), image=""somepicture.png"") is not an option on text boxes, I was wondering how I could make bg= a .png image. Or any other method of allowing a text box to stay a text box, with an image in the background so it can blend into a its surroundings.","You cannot use an image as a background in a text widget. +The best you can do is to create a canvas, place an image on the canvas, and then create a text item on top of that. Text items are editable, but you would have to write a lot of bindings, and you wouldn't have nearly as many features as the text widget. In short, it would be a lot of work.",1.2,True,1,5658 +2018-08-11 06:44:26.587,how to uninstall pyenv(installed by homebrew) on Mac,"I used to install pyenv by homebrew to manage versions of python, but now, I want to use anaconda.But I don't know how to uninstall pyenv.Please tell me.","None work for me (under brew) under Mac Cataline. +They have a warning about file missing under .pyenv. +(After I removed the bash_profile lines and also rm -rf ~/.pyenv, +I just install Mac OS version of python under python.org and seems ok. +Seems get my IDLE work and ...",0.3869120172231254,False,2,5659 +2018-08-11 06:44:26.587,how to uninstall pyenv(installed by homebrew) on Mac,"I used to install pyenv by homebrew to manage versions of python, but now, I want to use anaconda.But I don't know how to uninstall pyenv.Please tell me.","Try removing it using the following command: +brew remove pyenv",0.3869120172231254,False,2,5659 +2018-08-11 08:48:32.293,How to install pandas for sublimetext?,"I cannot find the way to install pandas for sublimetext. Do you might know how? +There is something called pandas theme in the package control, but that was not the one I needed; I need the pandas for python for sublimetext.","For me, ""pip install pandas"" was not working, so I used pip3 install pandas which worked nicely. +I would advise using either pip install pandas or pip3 install pandas for sublime text",0.0,False,2,5660 +2018-08-11 08:48:32.293,How to install pandas for sublimetext?,"I cannot find the way to install pandas for sublimetext. Do you might know how? +There is something called pandas theme in the package control, but that was not the one I needed; I need the pandas for python for sublimetext.","You can install this awesome theme through the Package Control. + +Press cmd/ctrl + shift + p to open the command palette. +Type “install package” and press enter. Then search for “Panda Syntax Sublime” + +Manual installation + +Download the latest release, extract and rename the directory to “Panda Syntax”. +Move the directory inside your sublime Packages directory. (Preferences > Browse packages…) + +Activate the theme +Open you preferences (Preferences > Setting - User) and add this lines: +""color_scheme"": ""Packages/Panda Syntax Sublime/Panda/panda-syntax.tmTheme"" +NOTE: Restart Sublime Text after activating the theme.",-0.2012947653214861,False,2,5660 +2018-08-11 14:25:40.620,Can I get a list of all urls on my site from the Google Analytics API?,"I have a site www.domain.com and wanted to get all of the urls from my entire website and how many times they have been clicked on, from the Google Analytics API. +I am especially interested in some of my external links (the ones that don't have www.mydomain.com). I will then match this against all of the links on my site (I somehow need to get these from somewhere so may scrape my own site). +I am using Python and wanted to do this programmatically. Does anyone know how to do this?","I have a site www.domain.com and wanted to get all of the urls from my + entire website and how many times they have been clicked on + +I guess you need parameter Page and metric Pageviews + +I am especially interested in some of my external links + +You can get list of external links if you track they as events. +Try to use some crawler, for example Screaming Frog. It allows to get internal and external links. Free use up to 500 pages.",1.2,True,1,5661 +2018-08-12 10:05:41.443,Data extraction from wef output file,"I have a wrf output netcdf file.File have variables temp abd prec.Dimensions keys are time, south-north and west-east. So how I select different lat long value in region. The problem is south-north and west-east are not variable. I have to find index value of four lat long value","1) Change your Registry files (I think it is Registry.EM_COMMON) so that you print latitude and longitude in your wrfout_d01_time.nc files. +2) Go to your WRFV3 map. +3) Clean, configure and recompile. +4) Run your model again the way you are used to.",0.0,False,1,5662 +2018-08-12 19:39:13.970,Cosmic ray removal in spectra,"Python developers +I am working on spectroscopy in a university. My experimental 1-D data sometimes shows ""cosmic ray"", 3-pixel ultra-high intensity, which is not what I want to analyze. So I want to remove this kind of weird peaks. +Does anybody know how to fix this issue in Python 3? +Thanks in advance!!","The answer depends a on what your data looks like: If you have access to two-dimensional CCD readouts that the one-dimensional spectra were created from, then you can use the lacosmic module to get rid of the cosmic rays there. If you have only one-dimensional spectra, but multiple spectra from the same source, then a quick ad-hoc fix is to make a rough normalisation of the spectra and remove those pixels that are several times brighter than the corresponding pixels in the other spectra. If you have only one one-dimensional spectrum from each source, then a less reliable option is to remove all pixels that are much brighter than their neighbours. (Depending on the shape of your cosmics, you may even want to remove the nearest 5 pixels or something, to catch the wings of the cosmic ray peak as well).",0.0,False,1,5663 +2018-08-13 21:59:31.640,PyCharm running Python file always opens a new console,"I initially started learning Python in Spyder, but decided to switch to PyCharm recently, hence I'm learning PyCharm with a Spyder-like mentality. +I'm interested in running a file in the Python console, but every time I rerun this file, it will run under a newly opened Python console. This can become annoying after a while, as there will be multiple Python consoles open which basically all do the same thing but with slight variations. +I would prefer to just have one single Python console and run an entire file within that single console. Would anybody know how to change this? Perhaps the mindset I'm using isn't very PyCharmic?","To allow only one instance to run, go to ""Run"" in the top bar, then ""Edit Configurations..."". Finally, check ""Single instance only"" at the right side. This will run only one instance and restart every time you run.",0.0679224682270276,False,3,5664 +2018-08-13 21:59:31.640,PyCharm running Python file always opens a new console,"I initially started learning Python in Spyder, but decided to switch to PyCharm recently, hence I'm learning PyCharm with a Spyder-like mentality. +I'm interested in running a file in the Python console, but every time I rerun this file, it will run under a newly opened Python console. This can become annoying after a while, as there will be multiple Python consoles open which basically all do the same thing but with slight variations. +I would prefer to just have one single Python console and run an entire file within that single console. Would anybody know how to change this? Perhaps the mindset I'm using isn't very PyCharmic?","You have an option to Rerun the program. +Simply open and navigate to currently running app with: + +Alt+4 (Windows) +⌘+4 (Mac) + +And then rerun it with: + +Ctrl+R (Windows) +⌘+R (Mac) + +Another option: +Show actions popup: + +Ctrl+Shift+A (Windows) +⇧+⌘+A (Mac) + +And type Rerun ..., IDE then hint you with desired action, and call it.",0.0,False,3,5664 +2018-08-13 21:59:31.640,PyCharm running Python file always opens a new console,"I initially started learning Python in Spyder, but decided to switch to PyCharm recently, hence I'm learning PyCharm with a Spyder-like mentality. +I'm interested in running a file in the Python console, but every time I rerun this file, it will run under a newly opened Python console. This can become annoying after a while, as there will be multiple Python consoles open which basically all do the same thing but with slight variations. +I would prefer to just have one single Python console and run an entire file within that single console. Would anybody know how to change this? Perhaps the mindset I'm using isn't very PyCharmic?","One console is one instance of Python being run on your system. If you want to run different variations of code within the same Python kernel, you can highlight the code you want to run and then choose the run option (Alt+Shift+F10 default).",0.0,False,3,5664 +2018-08-14 03:28:58.627,What is Killed:9 and how to fix in macOS Terminal?,"I have a simple Python code for a machine learning project. I have a relatively big database of spontaneous speech. I started to train my speech model. Since it's a huge database I let it work overnight. In the morning I woke up and saw a mysterious +Killed: 9 +line in my Terminal. Nothing else. There is no other error message or something to work with. The code run well for about 6 hours which is 75% of the whole process so I really don't understand whats went wrong. +What is Killed:9 and how to fix it? It's very frustrating to lose hours of computing time... +I'm on macOS Mojave beta if it's matter. Thank you in advance!","Try to change the node version. +In my case, that helps.",-0.2012947653214861,False,1,5665 +2018-08-15 17:19:50.610,Identifying parameters in HTTP request,"I am fairly proficient in Python and have started exploring the requests library to formulate simple HTTP requests. I have also taken a look at Sessions objects that allow me to login to a website and -using the session key- continue to interact with the website through my account. +Here comes my problem: I am trying to build a simple API in Python to perform certain actions that I would be able to do via the website. However, I do not know how certain HTTP requests need to look like in order to implement them via the requests library. +In general, when I know how to perform a task via the website, how can I identify: + +the type of HTTP request (GET or POST will suffice in my case) +the URL, i.e where the resource is located on the server +the body parameters that I need to specify for the request to be successful","This has nothing to do with python, but you can use a network proxy to examine your requests. + +Download a network proxy like Burpsuite +Setup your browser to route all traffic through Burpsuite (default is localhost:8080) +Deactivate packet interception (in the Proxy tab) +Browse to your target website normally +Examine the request history in Burpsuite. You will find every information you need",1.2,True,1,5666 +2018-08-16 03:16:46.443,Why there is binary type after writing to hive table,"I read the data from oracle database to panda dataframe, then, there are some columns with type 'object', then I write the dataframe to hive table, these 'object' types are converted to 'binary' type, does any one know how to solve the problem?","When you read data from oracle to dataframe it's created columns with object datatypes. +You can ask pandas dataframe try to infer better datatypes (before saving to Hive) if it can: +dataframe.infer_objects()",0.0,False,1,5667 +2018-08-16 04:22:51.340,What is the use of Jupyter Notebook cluster,"Can you tell me what is the use of jupyter cluster. I created jupyter cluster,and established its connection.But still I'm confused,how to use this cluster effectively? +Thank you","With Jupyter Notebook cluster, you can run notebook on the local machine and connect to the notebook on the cluster by setting the appropriate port number. Example code: + +Go to Server using ssh username@ip_address to server. +Set up the port number for running notebook. On remote terminal run jupyter notebook --no-browser --port=7800 +On your local terminal run ssh -N -f -L localhost:8001:localhost:7800 username@ip_address of server. +Open web browser on local machine and go to http://localhost:8001/",1.2,True,1,5668 +2018-08-16 12:03:34.353,How to decompose affine matrix?,"I have a series of points in two 3D systems. With them, I use np.linalg.lstsq to calculate the affine transformation matrix (4x4) between both. However, due to my project, I have to ""disable"" the shear in the transform. Is there a way to decompose the matrix into the base transformations? I have found out how to do so for Translation and Scaling but I don't know how to separate Rotation and Shear. +If not, is there a way to calculate a transformation matrix from the points that doesn't include shear? +I can only use numpy or tensorflow to solve this problem btw.","I'm not sure I understand what you're asking. +Anyway If you have two sets of 3D points P and Q, you can use Kabsch algorithm to find out a rotation matrix R and a translation vector T such that the sum of square distances between (RP+T) and Q is minimized. +You can of course combine R and T into a 4x4 matrix (of rotation and translation only. without shear or scale).",1.2,True,1,5669 +2018-08-16 13:00:32.667,Jupyter notebook kernel does not want to interrupt,"I was running a cell in a Jupyter Notebook for a while and decided to interrupt. However, it still continues to run and I don't know how to proceed to have the thing interrupted... +Thanks for help","Sometimes this happens, when you are on a GPU accelerated machine, where the Kernel is waiting for some GPU operation to be finished. I noticed this even on AWS instances. +The best thing you can do is just to wait. In the most cases it will recover and finish at some point. If it does not, at least it will tell you the kernel died after some minutes and you don´t have to copy paste your notebook, to back up your work. In rare cases, you have to kill your python process manually.",1.2,True,1,5670 +2018-08-17 02:02:19.417,find token between two delimiters - discord emotes,"i am trying to recognise discord emotes. +They are always between two : and don't contain space. e.g. +:smile: +I know how to split strings at delimiters, but how do i only split tokens that are within exactly two : and contain no space? +Thanks in advance!","Thanks to @G_M i found the following solution: + + regex = re.compile(r':[A-Za-z0-9]+:') + result = regex.findall(message.content) + +Will give me a list with all the emotes within a message, independent of where they are within the message.",1.2,True,1,5671 +2018-08-17 14:49:24.567,Post file from one server to another,"I have an Apache server A set up that currently hosts a webpage of a bar chart (using Chart.js). This data is currently pulled from a local SQLite database every couple seconds, and the web chart is updated. +I now want to use a separate server B on a Raspberry Pi to send data to the server to be used for the chart, rather than using the database on server A. +So one server sends a file to another server, which somehow realises this and accepts it and processes it. +The data can either be sent and placed into the current SQLite database, or bypass the database and have the chart update directly from the Pi's sent information. +I have come across HTTP Post requests, but not sure if that's what I need or quite how to implement it. +I have managed to get the Pi to simply host a json file (viewable from the external ip address) and pull the data from that with a simple requests.get('ip_address/json_file') in Python, but this doesn't seem like the most robust or secure solution. +Any help with what I should be using much appreciated, thanks!","Maybe I didn't quite understand your request but this is the solution I imagined: + +You create a Frontend with WebSocket support that connects to Server A +Server B (the one running on the raspberry) sends a POST request +with the JSON to Server A +Server A accepts the JSON and sends it to all clients connected with the WebSocket protocol + +Server B ----> Server A <----> Frontend +This way you do not expose your Raspberry directly and every request made by the Frontend goes only to Server A. +To provide a better user experience you could also create a GET endpoint on Server A to retrieve the latest received JSON, so that when the user loads the Frontend for the first time it calls that endpoint and even if the Raspberry has yet to update the data at least the user can have an insight of the latest available data.",0.0,False,1,5672 +2018-08-17 15:42:47.703,How to display a pandas Series in Python?,"I have a variable target_test (for machine learning) and I'd like to display just one element of target_test. +type(target_test) print the following statement on the terminal : +class 'pandas.core.series.Series' +If I do print(target_test) then I get the entire 2 vectors that are displayed. +But I'd like to print just the second element of the first column for example. +So do you have an idea how I could do that ? +I convert target_test to frame or to xarray but it didn't change the error I get. +When I write something like : print(targets_test[0][0]) +I got the following output : +TypeError: 'instancemethod' object has no attribute '__getitem__'","For the first column, you can use targets_test.keys()[i], for the second one targets_test.values[i] where i is the row starting from 0.",1.2,True,1,5673 +2018-08-18 22:38:40.803,django-storages boto3 accessing file url of a private file,"I'm trying to get the generated URL of a file in a test model I've created, +and I'm trying to get the correct url of the file by: modelobject.file.url which does give me the correct url if the file is public, however if the file is private it does not automatically generate a signed url for me, how is this normally done with django-storages? +Is the API supposed to automatically generate a signed url for private files? I am getting the expected Access Denied Page for 'none' signed urls currently, and need to get the signed 'volatile' link to the file. +Thanks in advance","I've figured out what I needed to do, +in the Private Storage class, I forgot to put custom_domain = False originally left this line off, because I did not think I needed it however you absolutely do in order to generate signed urls automatically.",0.9999877116507956,False,1,5674 +2018-08-19 22:55:22.463,Django - DRF (django-rest-framework-social-oauth2) and React creating a user,"I'm using the DRF and ReactJS and I am trying to login with Patreon using +django-rest-framework-social-oauth2. +In React, I send a request to the back-end auth/login/patreon/ and I reach the Patreon OAuth screen where I say I want to login with PAtreon. Patreon then returns with a request to the back-end at accounts/profile. At this point a python-social-oauth user has also been created. +At this point I'm confused. How do I make a request to Patreon to login, create a user in the back-end, and return the session information to the react front-end so that I can include the session information in all following requests from the front-end? I don't want the returned request to be at the backend/accounts/profile, do I? +Update +I now realize I can set the redirect url with LOGIN_REDIRECT_URL but still, how do I now retrieve the session id, pass it to the front-end, and include it with all requests?","Once you receive the user profile email, unique id, and other details from Patreon then create a user at the Database level. +Now after creating a user at the Database level you have to log in the user using the Django login function or any other login mechanism before redirecting the user to the frontend with a session. The redirect URL for the home/ landing page is provided by the Frontend side where they want to land the user after being successfully logged with session-id being set in cookies. Onward Frontend side can use session id in cookies for other requests. +Here is the flow: + +React JS -> auth/login/patreon/ -> redirected to Patreon -> Redirected back to the Backend with user information -> Create User (DB level) -> Login user -> Redirect back to Frontend (React JS on a specific URL provided by Front end)",0.0,False,1,5675 +2018-08-20 15:34:25.450,"In Visual Studio Code, how do I load my python code to a read-print-eval loop?","I am teaching a class that uses VScode. +I am used to teaching using IDLE, and it is very nice for the students to be able to call their defined functions and run snippets of code in a python terminal, for debugging purposes. +In VScode, they I have been unable to do the same in a satisfactory way. +Option1: I can select all code, right click and run selection/line on terminal. This works for small snippets, but I cannot do it for the whole file (even after selecting the whole file with ctrl-A). On linux, this works, but on windows, it does not, unfortunately (and my students use windows) +Option2: I can use the debug console. This requires adding a breakpoint in one of the last lines of the file, and does not offer tab completion. It works, but is less convenient than IDLE. +Option 3: I can also add the commands to run to the bottom of the file (which is a least preferred alternative, given that is forgoes the interativity of the read-print-eval loop). +Is there any better solution? Installing a VScode extension would not be a problem.","Visual Code is just a text editor like your traditional notepad. to run and debug any kind program you need to install the particular extension for the programming language. +In your case you are using python so you need to install the extension of it. the best one is the ""Python"" which is developed by microsoft itself. go to your extensions manager and install this extension. right click and click ""run python file in terminal"" and you are all set. +this will run exactly as they run from the idle(which is default IDE provided by python itself) you can enter the arguments from the console itself. according to me this is the best way to run and debug python programs in VScode. +another way is that VScode shows which python version is installed on your computer on the left bottom side, click on it and the programs will use this interpreter. +out of all the ways listed here and many others, the best method is to run the program in the terminal which is the recommend by python itself and many other programmers. +this method is very simple. what you have to do is open up your command prompt and type the path where python.exe is installed and the type the path of the your program as the argument and press enter. you are done ! +ex : C:\Python27\python.exe C:\Users\Username\Desktop\my_python_script.py +You can also pass your arguments of your program in the command prompt itself. +if you do not want to type all this and then just use the solution mentioned above. +hope that your query is solved. +regards",0.9950547536867304,False,1,5676 +2018-08-20 22:16:15.047,Maximum files size for Pyspark RDD,"I’m practicing Pyspark (standalone) in the Pyspark shell at work and it’s pretty new to me. Is there a rule of thumb regarding max file size and the RAM (or any other spec) on my machine? What about when using a cluster? +The file I’m practicing with is about 1200 lines. But I’m curious to know how large of a file size can be read into an RDD in regards to machine specifications or cluster specifications.","There is no hard limit on the Data size you can process, however when your RDD (Resilient Distributed Dataset) size exceeds the size of your RAM then the data will be moved to Disk. Even after the data is moved to the Disk spark will be equally capable of processing it. For example if your data is 12GB and available memory is 8GB spark will distribute the leftover data to disk and takes care of all transformations / actions seamlessly. Having said that you can process the data appropriately equal to size of disk. +There are of-course size limitation on size of single RDD which is 2GB. In other words the maximum size of a block will not exceed 2GB.",1.2,True,1,5677 +2018-08-22 12:17:01.487,Abaqus: parametric geometry/assembly in Inputfile or Python script?,"i want to do something as a parametric study in Abaqus, where the parameter i am changing is a part of the assembly/geometry. +Imagine the following: +A cube is hanging on 8 ropes. Each two of the 8 ropes line up in one corner of a room. the other ends of the ropes merge with the room diagonal of the cube. It's something like a cable-driven parallel robot/rope robot. +Now, i want to calculate the forces in the ropes in different positions of the cube, while only 7 of the 8 ropes are actually used. That means i have 8 simulations for each position of my cube. +I wrote a matlab script to generate the nodes and wires of the cube in different positions and angle of rotations so i can copy them into an input file for Abaqus. +Since I'm new to Abaqus scripting etc, i wonder which is the best way to make this work. +would you guys generate 8 input files for one position of the cube and calculate +them manually or is there a way to let abaqus somehow iterate different assemblys? +I guess i should wright a python script, but i don't know how to make the ropes the parameter that is changing. +Any help is appreciated! +Thanks, Tobi","In case someon is interested, i was able to do it the following way: +I created a model in abaqus till the point, i could have started the job. Then i took the .jnl file (which is created automaticaly by abaqus) and saved it as a .py file. Then i modified this script by defining every single point as a variable and every wire for the parts as tuples, consisting out of the variables. Than i made for loops and for every 9 cases unique wire definitions, which i called during the loop. During the loop also the constraints were changed and the job were started. I also made a field output request for the endnodes of the ropes (representing motors) for there coordinates and reaction force (the same nodes are the bc pinned) +Then i saved the fieldoutput in a certain simple txt file which i was able to analyse via matlab. +Then i wrote a matlab script which created the points, attached them to the python script, copied it to a unique directory and even started the job. +This way, i was able to do geometric parametric studies in abaqus using matlab and python. +Code will be uploaded soon",1.2,True,1,5678 +2018-08-22 12:57:46.077,Pandas DataFrame Display in Jupyter Notebook,"I want to make my display tables bigger so users can see the tables better when that are used in conjunction with Jupyter RISE (slide shows). +How do I do that? +I don't need to show more columns, but rather I want the table to fill up the whole width of the Jupyter RISE slide. +Any idea on how to do that? +Thanks","If df is a pandas.DataFrame object. +You can do: +df.style.set_properties(**{'max-width': '200px', 'font-size': '15pt'})",0.0,False,1,5679 +2018-08-22 13:38:01.097,Will making a Django website public on github let others get the data in its database ? If so how to prevent it?,"I have a locally made Django website and I hosted it on Heroku, at the same time I push changes to anathor github repo. I am using built in Database to store data. Will other users be able to get the data that has been entered in the database from my repo (like user details) ? +If so how to prevent it from happening ? Solutions like adding files to .gitignore will also prevent pushing to Heroku.","The code itself wouldn't be enough to get access to the database. For that you need the db name and password, which shouldn't be in your git repo at all. +On Heroku you use environment variables - which are set automatically by the postgres add-on - along with the dj_database_url library which turns that into the relevant values in the Django DATABASES setting.",0.0,False,1,5680 +2018-08-22 15:24:11.663,Uploading an image to S3 and manipulating with Python in Lambda - best practice,"I'm building my first web application and I've got a question around process and best practice, I'm hoping the expertise on this website might be give me a bit of direction. +Essentially, all the MVP is doing is going to be writing an overlay onto an image and presenting this back to the user, as follows; + +User uploads picture via web form (into AWS S3) - to do +Python script executes (in lambda) and creates image overlay, saves new image back into S3 - complete +User is presented back with new image to download - to do + +I've been running this locally as sort of a proof of concept and was planning on linking up with S3 today but then suddenly realised, what happens when there are two concurrent users and two images being uploaded with different filenames with two separate lambda functions working? +The only solution I could think of is having the image renamed upon upload with a record inserted into an RDS, then the lambda function to run upon record insertion against the new image, which would resolve half of it, but then how would I get the correct image relayed back to the user? +I'll be clear, I have next to no experience in web development, I want the front end to be as dumb as possible and run everything in Python (I'm a data scientist, I can write Python for data analysis but no experience as a software dev!)","You don't really need an RDS, just invoke your lambda synchronously from the browser. +So + +Upload file to S3, using a randomized file name +Invoke your lambda synchronously, passing it the file name +Have your lambda read the file, convert it, and respond with either the file itself (binary responses aren't trivial), or a path to the converted file in S3.",0.0,False,1,5681 +2018-08-23 12:03:16.460,How to install twilio via pip,"how to install twilio via pip? +I tried to install twilio python module +but i can't install it +i get following error +no Module named twilio +When trying to install twilio +pip install twilio +I get the following error. +pyopenssl 18.0.0 has requirement six>=1.5.2, but you'll have six 1.4.1 which is incompatible. +Cannot uninstall 'pyOpenSSL'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. +i got the answer and installed +pip install --ignore-installed twilio +but i get following error + +Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pytz-2018.5.dist-info' +Consider using the `--user` option or check the permissions. + +i have anaconda installed +is this a problem?","step1:download python-2.7.15.msi +step 2:install and If your system does not have Python added to your PATH while installing +""add python exe to path"" +step 3:go C:\Python27\Scripts of your system +step4:in command prompt C:\Python27\Scripts>pip install twilio +step 5:after installation is done >python command line + import twilio +print(twilio.version) +step 6:if u get the version ...you are done",-0.2012947653214861,False,1,5682 +2018-08-23 14:53:44.523,How to retrieve objects from the sotlayer saved quote using Python API,"I'm trying to retrieve the objects/items (server name, host name, domain name, location, etc...) that are stored under the saved quote for a particular Softlayer account. Can someone help how to retrieve the objects within a quote? I could find a REST API (Python) to retrieve quote details (quote ID, status, etc..) but couldn't find a way to fetch objects within a quote. +Thanks! +Best regards, +Khelan Patel",Thanks Albert getRecalculatedOrderContainer is the thing I was looking for.,0.0,False,1,5683 +2018-08-23 23:45:21.277,Can I debug Flask applications in IntelliJ?,"I know how to debug a flask application in Pycharm. The question is whether this is also possible in IntelliJ. +I have my flask application debugging in Pycharm but one thing I could do in IntelliJ was evaluate expressions inline by pressing the alt + left mouse click. This isn't available in Pycharm so I wanted to run my Flask application in IntelliJ but there isn't a Flask template. +Is it possible to add a Flask template to the Run/Debug configuration? I tried looking for a plugin but couldn't find that either.","Yes, you can. Just setup the proper parameters for Run script into PyCharm IDE. After that you can debug it as usual py script. In PyCharm you can evaluate any line in debug mode too.",0.0,False,1,5684 +2018-08-24 14:36:02.090,"how to add the overall ""precision"" and ""recall"" metrics to ""tensorboard"" log file, after training is finished?","After the training is finished and I did the prediction on my network, I want to calculate ""precision"" and ""recall"" of my model, and then send it to log file of ""tensorboard"" to show the plot. +while training, I send ""tensorboard"" function as a callback to keras. but after training is finished, I dont know how to add some more data to tensorboard to be plotted. +I use keras for coding and tensorflow as its backend.",I believe that you've already done that work: it's the same process as the validation (prediction and check) step you do after training. You simply tally the results of the four categories (true/false pos/neg) and plug those counts into the equations (ratios) for precision and recall.,0.0,False,1,5685 +2018-08-27 21:20:09.317,Convolutional neural network architectures with an arbitrary number of input channels (more than RGB),"I am very new to image recognition with CNNs and currently using several standard (pre-trained) architectures available within Keras (VGG and ResNet) for image classification tasks. I am wondering how one can generalise the number of input channels to more than 3 (instead of standard RGB). For example, I have an image which was taken through 5 different (optic) filters and I am thinking about passing these 5 images to the network. +So, conceptually, I need to pass as an input (Height, Width, Depth) = (28, 28, 5), where 28x28 is the image size and 5 - the number of channels. +Any easy way to do it with ResNet or VGG please?","If you retrain the models, that's not a problem. Only if you want to use a trained model, you have to keep the input the same.",1.2,True,1,5686 +2018-08-28 02:21:26.060,How to use Docker AND Conda in PyCharm,"I want to run python in PyCharm by using a Docker image, but also with a Conda environment that is set up in the Docker image. I've been able to set up Docker and (locally) set up Conda in PyCharm independently, but I'm stumped as to how to make all three work together. +The problem comes when I try to create a new project interpreter for the Conda environment inside the Docker image. When I try to enter the python interpreter path, it throws an error saying that the directory/path doesn't exist. +In short, the question is the same as the title: how can I set up PyCharm to run on a Conda environment inside a Docker image?","I'm not sure if this is the most eloquent solution, but I do have a solution to this now! + +Start up a container from the your base image and attach to it +Install the Conda env yaml file inside the docker container +From outside the Docker container stream (i.e. a new terminal window), commit the existing container (and its changes) to a new image: docker commit SOURCE_CONTAINER NEW_IMAGE + +Note: see docker commit --help for more options here + +Run the new image and start a container for it +From PyCharm, in preferences, go to Project > Project Interpreter +Add a new Docker project interpreter, choosing your new image as the image name, and set the path to wherever you installed your Conda environment on the Docker image (ex: /usr/local/conda3/envs/my_env/bin/python) + +And just like that, you're good to go!",1.2,True,1,5687 +2018-08-28 13:52:18.727,how to detect upside down face?,"I would like to detect upright and upside-down faces, however faces weren't recognized in upside-down images. +I used the dlib library in Python with shape_predictor_68_face_landmarks.dat. +Is there a library that can recognize upright and upside-down faces?","You could use the same library to detect upside down faces. If the library is unable to detect the face initially, transform it 180° and check again. If it is recognized in this condition, you know it was an upside down face.",1.2,True,1,5688 +2018-08-29 10:28:25.480,How to have cfiles in python code,"I'm using the Geany IDE and I've wrote a python code that makes a GUI. Im new to python and i'm better with C. I've done research on the web and its too complicated because theres so much jargon involved. Behind each button I want C to be the backbone of it (So c to execute when clicked). So, how can i make a c file and link it to my code?","I too had a question like this and I found a website that described how to do it step by step but I can’t seem to find it. If you think about it, all these ‘import’ files are just code thats been made separately and thats why you import them. So, in order to import your ‘C File’ do the following. + +Create the file you want to put in c (e.g bloop.c) +Then open the terminal and assuming you saved your file to the desktop, type ‘cd Desktop’. If you put it somewhere else other than the desktop, then type cd (insert the directory). +Now, type in gcc -shared -Wl,-soname,adder -o adder.so -fPIC bloop.c into the terminal. +After that, go into you python code and right at the very top of your code, type ‘import ctypes’ or ‘from ctypes import *’ to import the ctypes library. +Below that type adder = CDLL(‘./adder.so’). +if you want to add a instance for the class you need to type (letter or word)=adder.main(). For example, ctest = adder.main() +Now lets say you have a method you want to use from your c program you can type your charater or word (dot) method you created in c. For example ‘ctest.beans()’ (assuming you have a method in your code called beans).",1.2,True,1,5689 +2018-08-29 13:57:38.713,Cannot update svg file(s) for saleor framework + python + django,"I would like to know how should i could manage to change the static files use by the saelor framework. I've tried to change the logo.svg but failed to do so. +I'm still learning python program while using the saleor framework for e-commerce. +Thank you.",Here is how it should be done. You must put your logo in the saleor/static/images folder then change it in base.html file in footer and navbar section.,1.2,True,1,5690 +2018-08-29 20:22:17.757,"Determining ""SystemFaceButton"" RBG Value At RunTime","I am using tkinter and the PIL to make a basic photo viewer (mostly for learning purposes). I have the bg color of all of my widgets set to the default which is ""systemfacebutton"", whatever that means. +I am using the PIL.Image module to view and rotate my images. When an image is rotated you have to choose a fillcolor for the area behind the image. I want this fill color to be the same as the default system color but I have no idea how to get a the rgb value or a supported color name for this. It has to be calculated by python at run time so that it is consistent on anyone's OS. +Does anyone know how I can do this?","You can use w.winfo_rgb(""systembuttonface"") to turn any color name to a tuple of R, G, B. (w is any Tkinter widget, the root window perhaps. Note that you had the color name scrambled.) The values returned are 16-bit for some unknown reason, you'll likely need to shift them right by 8 bits to get the 0-255 values commonly used for specifying colors.",1.2,True,1,5691 +2018-08-30 01:29:02.027,"In tf.layers.conv2d, with use_bias=True, are the biases tied or untied?","One more question: +If they are tied biases, how can I implement untied biases? +I am using tensorflow 1.10.0 in python.","tied biases is used in tf.layers.conv2d. +If you want united biases, just turn off use_bias and create bias variable manually with tf.Variable or tf.get_variable same shape with following feature map, finally sum them up.",1.2,True,1,5692 +2018-08-30 19:43:08.963,Reading all the image files in a folder in Django,"I am trying to create a picture slideshow which will show all the png and jpg files of a folder using django. +Problem is how do I open windows explorer through django and prompt user to choose a folder name to load images from. Once this is done, how do I read all image files from this folder? Can I store all image files from this folder inside a list and pass this list in template views through context?","This link “https://github.com/csev/dj4e-samples/tree/master/pics” +shows how to store data into to database(sqlite is the database used here) using Django forms. But you cannot upload an entire folder at once, so you have to create a one to many model between display_id(This is just a field name in models you can name it anything you want) and pics. Now you can individually upload all pics in the folder to the same display _id and access all of them using this display_id. Also make sure to pass content_type for jpg and png separately while retrieving the pics.",0.0,False,1,5693 +2018-08-31 00:05:09.460,How can I get SMS verification code in my Python program?,"I'm writing a Python script to do some web automation stuff. In order to log in the website, I have to give it my phone number and the website will send out an SMS verification code. Is there a way to get this code so that I can use it in my Python program? Right now what I can think of is that I can write an Android APP and it will be triggered once there are new SMS and it will get the code and invoke an API so that the code will be stored somewhere. Then I can grab the stored code from within my Python program. This is doable but a little bit hard for me as I don't know how to develop a mobile APP. I want to know is there any other methods so that I can get this code? Thanks. +BTW, I have to use my own phone number and can't use other phone to receive the verification code. So it may not possible to use some services.",Answer my own question. I use IFTTT to forward the message to Slack and use Slack API to access the message.,0.0,False,1,5694 +2018-08-31 16:13:31.870,How to list available policies for an assumed AWS IAM role,"I am using python and boto to assume an AWS IAM role. I want to see what policies are attached to the role so i can loop through them and determine what actions are available for the role. I want to do this so I can know if some actions are available instead of doing this by calling them and checking if i get an error. However I cannot find a way to list the policies for the role after assuming it as the role is not authorised to perform IAM actions. +Is there anyone who knows how this is done or is this perhaps something i should not be doing.","To obtain policies, your AWS credentials require permissions to retrieve the policies. +If such permissions are not associated with the assumed role, you could use another set of credentials to retrieve the permissions (but those credentials would need appropriate IAM permissions). +There is no way to ask ""What policies do I have?"" without having the necessary permissions. This is an intentional part of AWS security because seeing policies can reveal some security information (eg ""Oh, why am I specifically denied access to the Top-Secret-XYZ S3 bucket?"").",0.3869120172231254,False,1,5695 +2018-08-31 19:23:27.853,"Creating ""zero state"" migration for existing db with sqlalchemy/alembic and ""faking"" zero migration for that existing db","I want to add alembic to an existing ,sqlalchemy using, project, with a working production db. I fail to find what's the standard way to do a ""zero"" migration == the migration setting up the db as it is now (For new developers setting up their environment) +Currently I've added import the declarative base class and all the models using it to the env.py , but first time alembic -c alembic.dev.ini revision --autogenerate does create the existing tables. +And I need to ""fake"" the migration on existing installations - using code. For django ORM I know how to make this work, but I fail to find what's the right way to do this with sqlalchemy/alembic","alembic revision --autogenerate inspects the state of the connected database and the state of the target metadata and then creates a migration that brings the database in line with metadata. +If you are introducing alembic/sqlalchemy to an existing database, and you want a migration file that given an empty, fresh database would reproduce the current state- follow these steps. + +Ensure that your metadata is truly in line with your current database(i.e. ensure that running alembic revision --autogenerate creates a migration with zero operations). + +Create a new temp_db that is empty and point your sqlalchemy.url in alembic.ini to this new temp_db. + +Run alembic revision --autogenerate. This will create your desired bulk migration that brings a fresh db in line with the current one. + +Remove temp_db and re-point sqlalchemy.url to your existing database. + +Run alembic stamp head. This tells sqlalchemy that the current migration represents the state of the database- so next time you run alembic upgrade head it will begin from this migration.",0.9999999999999966,False,1,5696 +2018-09-02 16:24:08.867,Django send progress back to client before request has ended,"I am working on an application in Django where there is a feature which lets the user share a download link to a public file. The server downloads the file and processes the information within. This can be a time taking task therefore I want to send periodic feedbacks to the user before operations has completed. For instances, I would like to inform the user that file has downloaded successfully or if some information was missing from one of the record e.t.c. +I was thinking that after the client app has sent the upload request, I could get client app to periodically ask the server about the status. But I don't know how can I track the progress a different request.How can I implement this?","At first the progress task information can be saved in rdb or redis。 +You can return the id of the task when uses submit the request to start task and the task can be executed in the background context。 +The background task can save the task progress info in the db which you selected. +The app client get the progress info by the task id which the backend returned and the backend get the progress info from the db and push it in the response. +The interval of the request can be defined by yourself.",0.0,False,1,5697 +2018-09-03 02:29:05.750,Numpy array size different when saved to disk (compared to nbytes),"Is it possible that a flat numpy 1d array's size (nbytes) is 16568 (~16.5kb) but when saved to disk, has a size of >2 mbs? +I am saving the array using numpy's numpy.save method. Dtype of array is 'O' (or object). +Also, how do I save that flat array to disk such that I get approx similar size to nbytes when saved on disk? Thanks","For others references, From numpy documentation: + +numpy.ndarray.nbytes attribute +ndarray.nbytes Total bytes consumed by the elements of the array. +Notes +Does not include memory consumed by non-element attributes of the +array object. + +So, the nbytes just considers elements of the array.",0.0,False,1,5698 +2018-09-05 10:27:35.310,Regex to match all lowercase character except some words,"I would like to write a RE to match all lowercase characters and words (special characters and symbols should not match), so like [a-z]+ EXCEPT the two words true and false. +I'm going to use it with Python. +I've written (?!true|false\b)\b[a-z]+, it works but it does not recognise lowercase characters following an uppercase one (e.g. with ""This"" it doesn't match ""his""). I don't know how to include also this kind of match. +For instance: + +true & G(asymbol) & false should match only asymbol +true & G(asymbol) & anothersymbol should match only [asymbol, anothersymbol] +asymbolUbsymbol | false should match only [asymbol, bsymbol] + +Thanks","I would create two regexes (you want to mix word boundary matching with optionally splitting words apart, which is, AFAIK not straighforward mixable, you would have to re-phrase your regex either without word boundaries or without splitting): + +first regex: [a-z]+ +second regex: \b(?!true|false)[a-z]+",0.0,False,1,5699 +2018-09-06 08:27:52.960,How to use double as the default type for floating numbers in PyTorch,"I want all the floating numbers in my PyTorch code double type by default, how can I do that?","You should use for that torch.set_default_dtype. +It is true that using torch.set_default_tensor_type will also have a similar effect, but torch.set_default_tensor_type not only sets the default data type, but also sets the default values for the device where the tensor is allocated, and the layout of the tensor.",0.3869120172231254,False,1,5700 +2018-09-06 20:34:52.430,how to change directory in Jupyter Notebook with Special characters?,"When I created directory under the python env, it has single quote like (D:\'Test Directory'). How do I change to this directory in Jupyter notebook?",I could able to change the directory using escape sequence like this.. os.chdir('C:\\'Test Directory\'),0.0,False,1,5701 +2018-09-08 02:24:30.413,"Graph traversal, maybe another type of mathematics?","Let’s say you have a set/list/collection of numbers: [1,3,7,13,21,19] (the order does not matter). Let’s say for reasons that are not important, you run them through a function and receive the following pairs: +(1, 13), (1, 19), (1, 21), (3,19), (7, 3), (7,13), (7,19), (21, 13), (21,19). Again order does not matter. My question involves the next part: how do I find out the minimum amount of numbers that can be part of a pair without being repeated? For this particular sequence it is all six. For [1,4,2] the pairs are (1,4), (1,2), (2,4). In this case any one of the numbers could be excluded as they are all in pairs, but they each repeat, therefore it would be 2 (which 2 do not matter). +At first glance this seems like a graph traversal problem - the numbers are nodes, the pairs edges. Is there some part of mathematics that deals with this? I have no problem writing up a traversal algorithm, I was just wondering if there was a solution with a lower time complexity. Thanks!","In case anyone cares in the future, the solution is called a blossom algorithm.",0.0,False,2,5702 +2018-09-08 02:24:30.413,"Graph traversal, maybe another type of mathematics?","Let’s say you have a set/list/collection of numbers: [1,3,7,13,21,19] (the order does not matter). Let’s say for reasons that are not important, you run them through a function and receive the following pairs: +(1, 13), (1, 19), (1, 21), (3,19), (7, 3), (7,13), (7,19), (21, 13), (21,19). Again order does not matter. My question involves the next part: how do I find out the minimum amount of numbers that can be part of a pair without being repeated? For this particular sequence it is all six. For [1,4,2] the pairs are (1,4), (1,2), (2,4). In this case any one of the numbers could be excluded as they are all in pairs, but they each repeat, therefore it would be 2 (which 2 do not matter). +At first glance this seems like a graph traversal problem - the numbers are nodes, the pairs edges. Is there some part of mathematics that deals with this? I have no problem writing up a traversal algorithm, I was just wondering if there was a solution with a lower time complexity. Thanks!","If you really intended to find the minimum amount, the answer is 0, because you don't have to use any number at all. +I guess you meant to write ""maximal amount of numbers"". +If I understand your problem correctly, it sounds like we can translated it to the following problem: +Given a set of n numbers (1,..,n), what is the maximal amount of numbers I can use to divide the set into pairs, where each number can appear only once. +The answer to this question is: + +when n = 2k f(n) = 2k for k>=0 +when n = 2k+1 f(n) = 2k for k>=0 + +I'll explain, using induction. + +if n = 0 then we can use at most 0 numbers to create pairs. +if n = 2 (the set can be [1,2]) then we can use both numbers to +create one pair (1,2) +Assumption: if n=2k lets assume we can use all 2k numbers to create 2k pairs and prove using induction that we can use 2k+2 numbers for n = 2k+2. +Proof: if n = 2k+2, [1,2,..,k,..,2k,2k+1,2k+2], we can create k pairs using 2k numbers (from our assomption). without loss of generality, lets assume out pairs are (1,2),(3,4),..,(2k-1,2k). we can see that we still have two numbers [2k+1, 2k+2] that we didn't use, and therefor we can create a pair out of two of them, which means that we used 2k+2 numbers. + +You can prove on your own the case when n is odd.",0.0,False,2,5702 +2018-09-08 12:37:37.387,error in missingno module import in Jupyter Notebook,"Getting error in missingno module import in Jupyter Notebook . It works fine in IDLE . But showing ""No missingno module exist"" in Jupyter Notebook . Can anybody tell me how to resolve this ?",Installing missingno through anaconda solved the problem for me,0.5457054096481145,False,2,5703 +2018-09-08 12:37:37.387,error in missingno module import in Jupyter Notebook,"Getting error in missingno module import in Jupyter Notebook . It works fine in IDLE . But showing ""No missingno module exist"" in Jupyter Notebook . Can anybody tell me how to resolve this ?","This command helped me: +conda install -c conda-forge/label/gcc7 missingno + You have to make sure that you run Anaconda prompt as Administrator.",0.3869120172231254,False,2,5703 +2018-09-08 18:25:29.300,Lazy loading with python and flask,"I’ve build a web based data dashboard that shows 4 graphs - each containing a large amount of data points. +When the URL endpoint is visited Flask calls my python script that grabs the data from a sql server and then starts manipulating it and finally outputs the bokeh graphs. +However, as these graphs get larger/there becomes more graphs on the screen the website takes long to load - since the entire function has to run before something is displayed. +How would I go about lazy loading these? I.e. it loads the first (most important graph) and displays it while running the function for the other graphs, showing them as and when they finish running (showing a sort of loading bar where each of the graphs are or something). +Would love some advice on how to implement this or similar. +Thanks!","I had the same problem as you. The problem with any kind of flask render is that all data is processed and passed to the page (i.e. client) simultaneously, often at large time cost. Not only that, but the the server web process is quite heavily loaded. +The solution I was forced to implement as the comment suggested was to load the page with blank charts and then upon mounting them access a flask api (via JS ajax) that returns chart json data to the client. This permits lazy loading of charts, as well as allowing the data manipulation to possibly be performed on a worker and not web server.",0.9950547536867304,False,1,5704 +2018-09-09 08:36:10.063,I can't import tkinter in pycharm community edition,"I've been trying for a few days now, to be able to import the library tkinter in pycharm. But, I am unable to do so. +,I tried to import it or to install some packages but still nothing, I reinstalled python and pycharm again nothing. Does anyone know how to fix this? +I am using pycharm community edition 2018 2.3 and python 3.7 . +EDIT:So , I uninstalled python 3.7 and I installed python 3.6 x64 ,I tried changing my interpreter to the new path to python and still not working... +EDIT 2 : I installed pycharm pro(free trial 30 days) and it's actually works and I tried to open my project in pycharm community and it's not working... +EDIT 3 : I installed python 3.6 x64 and now it's working. +Thanks for the help.","Thanks to vsDeus for asking this question. I had the same problem running Linux Mint Mate 19.1 and nothing got tkinter and some other modules working in Pycharm CE. In Eclipse with Pydev all worked just fine but for some reason I would rather work in Pycharm when coding than Eclipse. +The steps outlined here did not work for me but the steps he took handed me the solution. Basically I had to uninstall Pycharm, remove all its configuration files, then reinstall pip3, tkinter and then reinstall Pycharm CE. Finally I reopened previously saved projects and then set the correct interpreter. +When I tried to change the python interpreter before no alternatives appeared. After all these steps the choice became available. Most importantly now tkinter, matplotlib and other modules I wanted to use are available in Pycharm.",0.0,False,1,5705 +2018-09-10 11:25:39.227,how to use Tensorflow seq2seq.GreedyEmbeddingHelper first parameter Embedding in case of using normal one hot vector instead of embedding?,"I am trying to decode one character (represented as c-dimensional one hot vectors) at a time with tensorflow seq2seq model implementations. I am not using any embedding in my case. +Now I am stuck with tf.contrib.seq2seq.GreedyEmbeddingHelper. It requires ""embedding: A callable that takes a vector tensor of ids (argmax ids), or the params argument for embedding_lookup. The returned tensor will be passed to the decoder input."" +How I will define callable? What are inputs (vector tensor if ids(argmax ids)) and outputs of this callable function? Please explain using examples.","embedding = tf.Variable(tf.random_uniform([c-dimensional , +EMBEDDING_DIM])) +here you can create the embedding for you own model. +and this will be trained during your training process to give a vector for your own input. +if you don't want to use it you just can create a matrix where is every column of it is one hot vector represents the character and pass it as embedding. +it will be some thing like that: +[[1,0,0],[0,1,0],[0,0,1]] +here if you have vocabsize of 3 .",0.0,False,1,5706 +2018-09-10 11:43:29.133,"one server, same domain, different apps (example.com/ & example.com/tickets )?","I want advice on how to do the following: +On the same server, I want to have two apps. One WordPress app and one Python app. At the same time, I want the root of my domain to be a static landing page. +Url structure I want to achieve: + +example.com/ => static landing page +example.com/tickets => wordpress +example.com/pythonapp => python app + +I have never done something like this before and searching for solutions didn't help. +Is it even possible? +Is it better to use subdomains? +Is it better to use different servers? +How should I approach this? +Thanks in advance!","It depends on the webserver you want to use. Let's go with apache as it is one of the most used web servers on the internet. + +You install your wordpress installation into the /tickets subdirectory and install word-press as you normally would. This should install wordpress into the subdirectory. +Configure your Python-WSGI App with this configuration: + +WSGIScriptAlias /pythonapp /var/www/path/to/my/wsgi.py",0.2012947653214861,False,1,5707 +2018-09-12 02:15:34.913,How to saving plots and model results to pdf in python?,I know how to save model results to .txt files and saving plots to .png. I also found some post which shows how to save multiple plots on a single pdf file. What I am looking for is generating a single pdf file which can contain both model results/summary and it's related plots. So at the end I can have something like auto generated model report. Can someone suggest me how I can do this?,I’ve had good results with the fpdf module. It should do everything you need it to do and the learning curve isn’t bad. You can install with pip install fpdf.,0.0,False,1,5708 +2018-09-12 06:55:00.637,"Error configuring: unknown option ""-ipadx""","I want to add InPadding to my LabelFrame i'm using AppJar GUI. I try this: +self.app.setLabelFrameInPadding(self.name(""_content""), [20, 20]) +But i get this error: + +appJar:WARNING [Line 12->3063/configureWidget]: Error configuring _content: unknown option ""-ipadx"" + +Any ideas how to fix it?","Because of the way containers are implemented in appJar, padding works slightly differently for labelFrames. +Try calling: app.setLabelFramePadding('name', [20,20])",0.0,False,1,5709 +2018-09-12 13:04:34.793,Two flask Apps same domain IIS,"I want to deploy same flask application as two different instances lets say sandbox instance and testing instance on the same iis server and same machine. having two folders with different configurations (one for testing and one for sandbox) IIS runs whichever is requested first. for example I want to deploy one under www.example.com/test and the other under www.example.com/sandbox. if I requested www.example.com/test first then this app keeps working correctly but whenever I request www.example.com/sandbox it returns 404 and vice versa! +question bottom line: + +how can I make both apps run under the same domain with such URLs? +would using app factory pattern solve this issue? +what blocks both apps from running side by side as I am trying to do? + +thanks a lot in advance",been stuck for a week before asking this question and the neatest way I found was to assign each app a different app pool and now they are working together side by side happily ever after.,1.2,True,1,5710 +2018-09-13 06:51:37.370,Sharing PonyORM's db session across different python module,"I initially started a small python project (Python, Tkinter amd PonyORM) and became larger that is why I decided to divide the code (used to be single file only) to several modules (e.g. main, form1, entity, database). Main acting as the main controller, form1 as an example can contain a tkinter Frame which can be used as an interface where the user can input data, entity contains the db.Enttiy mappings and database for the pony.Database instance along with its connection details. I think problem is that during import, I'm getting this error ""pony.orm.core.ERDiagramError: Cannot define entity 'EmpInfo': database mapping has already been generated"". Can you point me to any existing code how should be done.","Probably you import your modules in a wrong order. Any module which contains entity definitions should be imported before db.generate_mapping() call. +I think you should call db.generate_mapping() right before entering tk.mainloop() when all imports are already done.",1.2,True,1,5711 +2018-09-13 08:55:49.327,Python3 - How do I stop current versions of packages being over-ridden by other packages dependencies,"Building Tensorflow and other such packages from source and especially against GPU's is a fairly long task and often encounters errors, so once built and installed I really dont want to mess with them. +I regularly use virtualenvs, but I am always worried about installing certain packages as sometimes their dependencies will overwrite my own packages I have built from source... +I know I can remove, and then rebuild from my .wheels, but sometimes this is a time consuming task. Is there a way that if I attempt to pip install a package, it first checks against current package versions and doesn't continue before I agree to those changes? +Even current packages dependencies don't show versions with pip show","Is there a way that if I attempt to pip install a package, it first checks against current package versions and doesn't continue before I agree to those changes? + +No. But pip install doesn't touch installed dependencies until you explicitly run pip install -U. So don't use -U/--upgrade option and upgrade dependencies when pip fails with unmet dependencies.",0.0,False,1,5712 +2018-09-14 02:32:31.807,how do I connect sys.argv into my float value?,"I must use ""q"" (which is a degree measure) from the command line and then convert ""q"" to radians and have it write out the value of sin(5q) + sin(6q). Considering that I believe I have to use sys.argv's for this I have no clue where to even begin","you can use following commands +q=sys.argv[1] #you can give the decimal value too in your command line +now q will be string eg. ""1.345"" so you have convert this to float[ using +function q=float(q) .",0.0,False,1,5713 +2018-09-14 10:30:59.240,Scrapy: Difference between simple spider and the one with ItemLoader,"I've been working on scrapy for 3 months. for extracting selectors I use simple response.css or response.xpath.. +I'm asked to switch to ItemLoaders and use add_xpath add_css etc. +I know how ItemLoaders work and ho convinient they are but can anyone compare these 2 w.r.t efficiency? which way is efficient and why ??",Item loaders do exactly the same thing underneath that you do when you don't use them. So for every loader.add_css/add_xpath call there will be responce.css/xpath executed. It won't be any faster and the little amount of additional work they do won't really make things any slower (especially in comparison to xml parsing and network/io load).,0.0,False,1,5714 +2018-09-15 01:56:10.107,Possible to get a file descriptor for Python's StringIO?,"From a Python script, I want to feed some small string data to a subprocess, but said subprocess non-negotiably accepts only a filename as an argument, which it will open and read. I non-negotiably do not want to write this data to disk - it should reside only in memory. +My first instinct was to use StringIO, but I realize that StringIO has no fileno(). mmap(-1, ...) also doesn't seem to create a file descriptor. With those off the table, I'm at a loss as to how to do this. Is this even achievable? The fd would be OS-level visible, but (I would expect) only to the process's children. +tl;dr how to create private file descriptor to a python string/memory that only a child process can see? +P.S. This is all on Linux and doesn't have to be portable in any way.","Reifying @user4815162342's comment as an answer: +The direct way to do this is: + +pass /dev/stdin as the file argument to the process; +use stdin=subprocess.PIPE; +finally, Popen.communicate() to feed the desired contents",0.6730655149877884,False,1,5715 +2018-09-17 15:44:04.130,how to modify txt file properties with python,"I am trying to make a python program that creates and writes in a txt file. +the program works, but I want it to cross the ""hidden"" thing in the txt file's properties, so that the txt can't be seen without using the python program I made. I have no clues how to do that, please understand I am a beginner in python.",I'm not 100% sure but I don't think you can do this in Python. I'd suggest finding a simple Visual Basic script and running it from your Python file.,0.0,False,1,5716 +2018-09-18 15:03:23.547,How can I run code for a certain amount of time?,"I want to play a sound (from a wav file) using winsound's winsound.PlaySound function. I know that winsound.Beep allows me to specify the time in milliseconds, but how can I implement that behavior with winsound.PlaySound? +I tried to use the time.sleep function, but that only delays the function, not specifies the amount of time. +Any help would be appreciated.","Create a thread to play the sound, start it. Create a thread that sleeps the right amount of time and has a handle to the first thread. Have the second thread terminate the first thread when the sleep is over.",1.2,True,1,5717 +2018-09-18 16:35:17.860,Do I need two instances of python-flask?,"I am building a web-app. One part of the app calls a function that starts a tweepy StreamListener on certain track. That functions process a tweet and then it writes a json object to a file or mongodb. +On the other hand I need a process that is reading the file or mongodb and paginates the tweet if some property is in it. The thing is that I don't know how to do that second part. Do I need different threads? +What solutions could there be?","You can certainly do it with a thread or spinning up a new process that will perform the pagination. +Alternatively you can look into a task queue service (Redis queue, celery, as examples). Your web-app can add a task to this queue and your other program can listen to this queue and perform the pagination tasks as they come in.",0.0,False,1,5718 +2018-09-19 22:34:46.480,Celery - how to stop running task when using distributed RabbitMQ backend?,"If I am running Celery on (say) a bank of 50 machines all using a distributed RabbitMQ cluster. +If I have a task that is running and I know the task id, how in the world can Celery figure out which machine its running on to terminate it? +Thanks.","I am not sure if you can actually do it, when you spawn a task you will have a worker, somewhere in you 50 boxes, that executes that and you technically have no control on it as it s a separate process and the only thing you can control is either the asyncResult or the amqp message on the queue.",0.0,False,1,5719 +2018-09-19 23:16:35.920,how to run periodic task in high frequency in flask?,"I want my flask APP to pull updates from a local txt file every 200ms, is it possible to do that? +P.S. I've considered BackgroundScheduler() from apschedulerler, but the granularity of is 1s.",Couldn't you just start a loop in a thread that sleeps for 200 ms before the next iteration?,0.2012947653214861,False,1,5720 +2018-09-20 06:14:37.797,How to search for all existing mongodbs for single GET request,"Suppose I have multiple mongodbs like mongodb_1, mongodb_2, mongodb_3 with same kind of data like employee details of different organizations. +When user triggers GET request to get employee details from all the above 3 mongodbs whose designation is ""TechnicalLead"". then first we need to connect to mongodb_1 and search and then disconnect with mongodb_1 and connect to mongodb_2 and search and repeat the same for all dbs. +Can any one suggest how can we achieve above using python EVE Rest api framework. +Best Regards, +Narendra","First of all, it is not a recommended way to run multiple instances (especially when the servers might be running at the same time) as it will lead to usage of the same config parameters like for example logpath and pidfilepath which in most cases is not what you want. +Secondly for getting the data from multiple mongodb instances you have to create separate get requests for fetching the data. There are two methods of view for the model that can be used: + +query individual databases for data, then assemble the results for viewing on the screen. +Query a central database that the two other databases continously update.",0.0,False,1,5721 +2018-09-20 17:05:30.047,python asyncronous images download (multiple urls),"I'm studying Python for 4/5 months and this is my third project built from scratch, but im not able to solve this problem on my own. +This script downloads 1 image for each url given. +Im not able to find a solution on how to implement Thread Pool Executor or async in this script. I cannot figure out how to link the url with the image number to the save image part. +I build a dict of all the urls that i need to download but how do I actually save the image with the correct name? +Any other advise? +PS. The urls present at the moment are only fake one. +Synchronous version: + + + import requests + import argparse + import re + import os + import logging + + from bs4 import BeautifulSoup + + + parser = argparse.ArgumentParser() + parser.add_argument(""-n"", ""--num"", help=""Book number"", type=int, required=True) + parser.add_argument(""-p"", dest=r""path_name"", default=r""F:\Users\123"", help=""Save to dir"", ) + args = parser.parse_args() + + + + logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', + level=logging.ERROR) + logger = logging.getLogger(__name__) + + + def get_parser(url_c): + url = f'https://test.net/g/{url_c}/1' + logger.info(f'Main url: {url_c}') + responce = requests.get(url, timeout=5) # timeout will raise an exeption + if responce.status_code == 200: + page = requests.get(url, timeout=5).content + soup = BeautifulSoup(page, 'html.parser') + return soup + else: + responce.raise_for_status() + + + def get_locators(soup): # take get_parser + # Extract first/last page num + first = int(soup.select_one('span.current').string) + logger.info(f'First page: {first}') + last = int(soup.select_one('span.num-pages').string) + 1 + + # Extract img_code and extension + link = soup.find('img', {'class': 'fit-horizontal'}).attrs[""src""] + logger.info(f'Locator code: {link}') + code = re.search('galleries.([0-9]+)\/.\.(\w{3})', link) + book_code = code.group(1) # internal code + extension = code.group(2) # png or jpg + + # extract Dir book name + pattern = re.compile('pretty"":""(.*)""') + found = soup.find('script', text=pattern) + string = pattern.search(found.text).group(1) + dir_name = string.split('""')[0] + logger.info(f'Dir name: {dir_name}') + + logger.info(f'Hidden code: {book_code}') + print(f'Extension: {extension}') + print(f'Tot pages: {last}') + print(f'') + + return {'first_p': first, + 'last_p': last, + 'book_code': book_code, + 'ext': extension, + 'dir': dir_name + } + + + def setup_download_dir(path, dir): # (args.path_name, locator['dir']) + # Make folder if it not exist + filepath = os.path.join(f'{path}\{dir}') + if not os.path.exists(filepath): + try: + os.makedirs(filepath) + print(f'Directory created at: {filepath}') + except OSError as err: + print(f""Can't create {filepath}: {err}"") + return filepath + + + def main(locator, filepath): + for image_n in range(locator['first_p'], locator['last_p']): + url = f""https://i.test.net/galleries/{locator['book_code']}/{image_n}.{locator['ext']}"" + logger.info(f'Url Img: {url}') + responce = requests.get(url, timeout=3) + if responce.status_code == 200: + img_data = requests.get(url, timeout=3).content + else: + responce.raise_for_status() # raise exepetion + + with open((os.path.join(filepath, f""{image_n}.{locator['ext']}"")), 'wb') as handler: + handler.write(img_data) # write image + print(f'Img {image_n} - DONE') + + + if __name__ == '__main__': + try: + locator = get_locators(get_parser(args.num)) # args.num ex. 241461 + main(locator, setup_download_dir(args.path_name, locator['dir'])) + except KeyboardInterrupt: + print(f'Program aborted...' + '\n') + + +Urls list: + + + def img_links(locator): + image_url = [] + for num in range(locator['first_p'], locator['last_p']): + url = f""https://i.test.net/galleries/{locator['book_code']}/{num}.{locator['ext']}"" + image_url.append(url) + logger.info(f'Url List: {image_url}') + return image_url","I found the solution in the book fluent python. Here the snippet: + + def download_many(cc_list, base_url, verbose, concur_req): + counter = collections.Counter() + with futures.ThreadPoolExecutor(max_workers=concur_req) as executor: + to_do_map = {} + for cc in sorted(cc_list): + future = executor.submit(download_one, cc, base_url, verbose) + to_do_map[future] = cc + done_iter = futures.as_completed(to_do_map) + if not verbose: + done_iter = tqdm.tqdm(done_iter, total=len(cc_list)) + for future in done_iter: + try: + res = future.result() + except requests.exceptions.HTTPError as exc: + error_msg = 'HTTP {res.status_code} - {res.reason}' + error_msg = error_msg.format(res=exc.response) + except requests.exceptions.ConnectionError as exc: + error_msg = 'Connection error' + else: + error_msg = '' + status = res.status + if error_msg: + status = HTTPStatus.error + counter[status] += 1 + if verbose and error_msg: + cc = to_do_map[future] + print('*** Error for {}: {}'.format(cc, error_msg)) + return counter",1.2,True,1,5722 +2018-09-23 11:46:47.050,How to put a list of arbitrary integers on screen (from lowest to highest) in pygame proportionally?,"Let's say I have a list of 887123, 123, 128821, 9, 233, 9190902. I want to put those strings on screen using pygame (line drawing), and I want to do so proportionally, so that they fit the screen. If the screen is 1280x720, how do I scale the numbers down so that they keep their proportions to each other but fit the screen? +I did try with techniques such as dividing every number by two until they are all smaller than 720, but that is skewed. Is there an algorithm for this sort of mathematical scaling?",I used this algorithm: x = (x / (maximum value)) * (720 - 1),0.3869120172231254,False,1,5723 +2018-09-23 16:36:12.867,Python3.6 and singletons - use case and parallel execution,"I have several unit-tests (only python3.6 and higher) which are importing a helper class to setup some things (eg. pulling some Docker images) on the system before starting the tests. +The class is doing everything while it get instantiate. It needs to stay alive because it holds some information which are evaluated during the runtime and needed for the different tests. +The call of the helper class is very expensive and I wanna speedup my tests the helper class only once. My approach here would be to use a singleton but I was told that in most cases a singleton is not needed. Are there other options for me or is a singleton here actually a good solution? +The option should allow executing all tests at all and every test on his own. +Also I would have some theoretical questions. +If I use a singleton here how is python executing this in parallel? Is python waiting for the first instance to be finish or can there be a race condition? And if yes how do I avoid them?","I can only given an answer on the ""are there other options for me"" part of your question... +The use of such a complex setup for unit-tests (pulling docker images etc.) makes me suspicious: +It can mean that your tests are in fact integration tests rather than unit-tests. Which could be perfectly fine if your goal is to find the bugs in the interactions between the involved components or in the interactions between your code and its system environment. (The fact that your setup involves Docker images gives the impression that you intend to test your system-under-test against the system environment.) If this is the case I wish you luck to get the other aspects of your question answered (parallelization of tests, singletons and thread safety). Maybe it makes sense to tag your question ""integration-testing"" rather than ""unit-testing"" then, in order to attract the proper experts. +On the other hand your complex setup could be an indication that your unit-tests are not yet designed properly and/or the system under test is not yet designed to be easily testable with unit-tests: Unit-tests focus on the system-under-test in isolation - isolation from depended-on-components, but also isolation from the specifics of the system environment. For such tests of a properly isolated system-under-test a complex setup using Docker would not be needed. +If the latter is true you could benefit from making yourself familiar with topics like ""mocking"", ""dependency injection"" or ""inversion of control"", which will help you to design your system-under-test and your unit test cases such that they are independent of the system environment. Then, your complex setup would no longer be necessary and the other aspects of your question (singleton, parallelization etc.) may no longer be relevant.",0.0,False,1,5724 +2018-09-24 09:39:59.467,How to increase the error limit in flake8 and pylint VS Code?,"As mentioned above I would like to know how I can increase the no of errors shown in flake8 and pylint. I have installed both and they work fine when I am working with small files. I am currently working with a very large file (>18k lines) and there is no error highlighting done at the bottom part of the file, I believe the current limit is set to 100 and would like to increase it. +If this isn't possible is there any way I can just do linting for my part of the code? I am just adding a function in this large file and would like to monitor the same.","Can use ""python.linting.maxNumberOfProblems"": 2000 to increase the no of problems being displayed but the limit seems to be set to 1001 so more than 1001 problems can't be displayed.",0.0,False,1,5725 +2018-09-24 11:25:27.520,Knowledge graph in python for NLP,how do I build a knowledge graph in python from structured texts? Do I need to know any graph databases? Any resources would be of great help.,"Knowledge Graph (KG) is just a virtual representation and not an actual graph stored as it is. +To store the data you can use any of the present databases like SQL, MongoDB, etc. But to benefit the fact that we are storing graphs here, I'll suggest better use graph-based databases like node4js.",0.0,False,1,5726 +2018-09-25 08:12:35.473,How to view Opendaylight topology on external webgui,"I'm exploring ODL and mininet and able to run both and populate the network nodes over ODL and I can view the topology via ODL default webgui. +I'm planning to create my own webgui and to start with simple topology view. I need advise and guideline on how I can achieve topology view on my own webgui. Plan to use python and html. Just a simple single page html and python script. Hopefully someone could lead me the way. Please assist and thank you.","If a web GUI for ODL would provide value for you, please consider working to contribute that upstream. The previous GUI (DLUX) has recently been deprecated because no one was supporting it, although it seems many people were using it.",0.0,False,1,5727 +2018-09-26 04:22:21.250,"Python3, calling super's __init__ from a custom exception","I have created custom exception in python 3 and the over all code works just fine. But there is one thing I am not able to wrap my head around is that why do I need to send my message to the Exception class's __init__() and how does it convert the Custom exception into that string message when I try to print the exception since the code in the Exception or even the BaseException does not do much. +Not quite able to understand why call the super().__init__() from custom exception?","This is so that your custom exceptions can start off with the same instance attributes as a BaseException object does, including the value attribute, which stores the exception message, which is needed by certain other methods such as __str__, which allows the exception object to be converted to a string directly. You can skip calling super().__init__ in your subclass's __init__ and instead initialize all the necessary attributes on your own if you want, but then you would not be taking advantage of one of the key benefits of class inheritance. Always call super().__init__ unless you have very specific reasons not to reuse any of the parent class's instance attributes.",0.3869120172231254,False,1,5728 +2018-09-26 21:19:30.580,Interpreter problem (apparently) with a project in PyCharm,"I recently upgraded PyCharm (community version). If it matters, I am running on a Mac OSX machine. After the upgrade, I have one project in which PyCharm cannot find any python modules. It can't find numpy, matplotlib, anything ... I have checked a couple of other projects and they seem to be fine. I noticed that somehow the interpreter for the project in question was not the same as for the others. So I changed it to match the others. But PyCharm still can't find the modules. Any ideas what else I can do? +More generally, something like this happens every time I upgrade to a new PyCharm version. The fix each time is a little different. Any ideas on how I can prevent this in the first place? +EDIT: FWIW, I just now tried to create a new dummy project. It has the same problem. I notice that my two problem projects are created with a ""venv"" sub-directory. My ""good"" projects don't have this thing. Is this a clue to what is going on? +EDIT 2: OK, just realized that when creating a new project, I can select ""New environment"" or ""Existing interpreter"", and I want ""Existing interpreter"". However, I would still like to know how one project that was working fine before is now hosed, and how I can fix it. Thanks.","It seems, when you are creating a new project, you also opt to create a new virtual environment, which then is created (default) in that venv sub-directory. +But that would only apply to new projects, what is going on with your old projects, changing their project interpreter environment i do not understand. +So what i would say is you have some corrupt settings (e.g. in ~/Library/Preferences/PyCharm2018.2 ), which are copied upon PyCharm upgrade. +You might try newly configure PyCharm by moving away those PyCharm preferences, so you can put them back later. +The Project configuration mainly, special the Project interpreter on the other hand is stored inside $PROJECT_ROOT/.idea and thus should not change.",1.2,True,2,5729 +2018-09-26 21:19:30.580,Interpreter problem (apparently) with a project in PyCharm,"I recently upgraded PyCharm (community version). If it matters, I am running on a Mac OSX machine. After the upgrade, I have one project in which PyCharm cannot find any python modules. It can't find numpy, matplotlib, anything ... I have checked a couple of other projects and they seem to be fine. I noticed that somehow the interpreter for the project in question was not the same as for the others. So I changed it to match the others. But PyCharm still can't find the modules. Any ideas what else I can do? +More generally, something like this happens every time I upgrade to a new PyCharm version. The fix each time is a little different. Any ideas on how I can prevent this in the first place? +EDIT: FWIW, I just now tried to create a new dummy project. It has the same problem. I notice that my two problem projects are created with a ""venv"" sub-directory. My ""good"" projects don't have this thing. Is this a clue to what is going on? +EDIT 2: OK, just realized that when creating a new project, I can select ""New environment"" or ""Existing interpreter"", and I want ""Existing interpreter"". However, I would still like to know how one project that was working fine before is now hosed, and how I can fix it. Thanks.","Your project is most likely pointing to the wrong interpreter. E.G. Using a virtual environment when you want to use a global one. +You must point PyCharm to the correct interpreter that you want to use. +""File/Settings(Preferences On Mac)/Project: ... /Project Interpreter"" takes you to the settings associated with the interpreters. +This window shows all of the modules within the interpreter. +From here you can click the settings wheel in the top right and configure your interpreters. (add virtual environments and what not) +or you can select an existing interpreter from the drop down to use with your project.",0.2012947653214861,False,2,5729 +2018-09-27 04:54:42.700,how can i check all the values of dataframe whether have null values in them without a loop,"if all(data_Window['CI']!=np.nan): +I have used the all() function with if so that if column CI has no NA values, then it will do some operation. But i got syntax error.","This gives you all a columns and how many null values they have. +df = pd.DataFrame({0:[1,2,None,],1:[2,3,None]) +df.isnull().sum()",0.0,False,1,5730 +2018-09-27 09:20:03.150,Choosing best semantics for related variables in an untyped language like Python,"Consider the following situation: you work with audio files and soon there are different contexts of what ""an audio"" actually is in same solution. +This on one side is more obvious through typing, though while Python has classes and typing, but it is less explicit in the code like in Java. I think this occurs in any untyped language. +My question is how to have less ambiguous variable names and whether there is something like an official and widely accepted guideline or even a standard like PEP/RFC for that or comparable. +Examples for variables: + +A string type to designate the path/filename of the actual audio file +A file handle for the above to do the I/O +Then, in the package pydub, you deal with the type AudioSegment +While in the package moviepy, you deal with the type AudioFileClip + +Using all the four together, requires in my eyes for a clever naming strategy, but maybe I just oversee something. +Maybe this is a quite exocic example, but if you think of any other media types, this should provide a more broad view angle. Likewise, is a Document a handle, a path or an abstract object?","There is no definitive standard/rfc to name your variables. One option is to prefix/suffix your variables with a (possibly short form) type. For example, you can name a variable as foo_Foo where variable foo_Foo is of type Foo.",0.0,False,1,5731 +2018-09-27 14:44:45.557,Holoviews - network graph - change edge color,I am using holoviews and bokeh with python 3 to create an interactive network graph fro mNetworkx. I can't manage to set the edge color to blank. It seems that the edge_color option does not exist. Do you have any idea how I could do that?,"Problem solved, the option to change edges color is edge_line_color and not edge_color.",0.3869120172231254,False,1,5732 +2018-09-27 15:09:52.837,Make Pipenv create the virtualenv in the same folder,"I want Pipenv to make virtual environment in the same folder with my project (Django). +I searched and found the PIPENV_VENV_IN_PROJECT option but I don't know where and how to use this.","For posterity's sake, if you find pipenv is not creating a virtual environment in the proper location, you may have an erroneous Pipfile somewhere, confusing the pipenv shell call - in which case I would delete it form path locations that are not explicitly linked to a repository.",0.1618299653758019,False,2,5733 +2018-09-27 15:09:52.837,Make Pipenv create the virtualenv in the same folder,"I want Pipenv to make virtual environment in the same folder with my project (Django). +I searched and found the PIPENV_VENV_IN_PROJECT option but I don't know where and how to use this.","This maybe help someone else.. I find another easy way to solve this! +Just make empty folder inside your project and name it .venv +and pipenv will use this folder.",0.9999999998319656,False,2,5733 +2018-09-27 15:26:56.820,Force tkinter listbox to highlight item when selected before task is started,"I have a tkinter listbox, when I select a item it performs a few actions then returns the results, while that is happening the item I selected does not show as selected, is there a way to force it to show selected immediately so it's obvious to the user they selected the correct one while waiting on the returned results? I'm using python 3.4 and I'm on a windows 7 machine.",The item does show as selected right away because the time consuming actions are executed before updating the GUI. You can force the GUI to update before executing the actions by using window.update_idletasks().,0.0,False,1,5734 +2018-09-27 20:02:47.580,In Python DataFrame how to find out number of rows that have valid values of columns,"I want to find the number of rows that have certain values such as None or """" or NaN (basically empty values) in all columns of a DataFrame object. How can I do this?","Use df.isnull().sum() to get number of rows with None and NaN value. +Use df.eq(value).sum() for any kind of values including empty string """".",0.2655860252697744,False,1,5735 +2018-09-28 10:00:04.037,.get + dict variable,"I have a charge object with information in charge['metadata']['distinct_id']. There could be the case that it's not set, therefore I tried it that way which doesn't work charge.get(['metadata']['distinct_id'], None) +Do you know how to do that the right way?","You don't say what the error is, but, two things possibly wrong + +it should be charge.get('metadata', None) +you can't directly do it on two consecutive levels. If the metadata key returns None, you can't go on and ask for the distinct_id key. You could return an empty dict and apply get to that, eg something like charge.get('metadata', {}).get('distinct_id', None)",1.2,True,2,5736 +2018-09-28 10:00:04.037,.get + dict variable,"I have a charge object with information in charge['metadata']['distinct_id']. There could be the case that it's not set, therefore I tried it that way which doesn't work charge.get(['metadata']['distinct_id'], None) +Do you know how to do that the right way?","As @blue_note mentioned you could not user two consecutive levels. However your can try something like +charge.get('metadata', {}).get('distinct_id') +here, you tried to get 'metadata' from charge and if it does not found then it will consider blank dictionary and try to get 'distinct_id' from there (technically it does not exists). In this scenario, you need not to worry about if metadata exists or not. If it exists then it will check for distinct_id from metadata or else it throws None. +Hope this will solve your problem. +Cheers..!",0.1352210990936997,False,2,5736 +2018-09-28 16:43:57.900,PyMongo how to get the last item in the collection?,"In the MongoDB console, I know that you can use $ last and $ natural. In PyMongo, I could not use it, maybe I was doing something wrong?","Another way is: +db.collection.find().limit(1).sort([('$natural',-1)]) +This seemed to work best for me.",0.2012947653214861,False,1,5737 +2018-09-29 12:08:21.843,how can I use Transfer Learning for LSTM?,I intent to implement image captioning. Would it be possible to transfer learning for LSTM? I have used pretrained VGG16(transfer learning) to Extract features as input of the LSTM.,"As I have discovered, we can't use Transfer learning on the LSTM weights. I think the causation is infra-structure of LSTM networks.",1.2,True,1,5738 +2018-09-29 19:52:13.553,Is there any way to retrieve file name using Python?,"In a Linux directory, I have several numbered files, such as ""day1"" and ""day2"". My goal is to write a code that retrieves the number from the files and add 1 to the file that has the biggest number and create a new file. So, for example, if there are files, 'day1', 'day2' and 'day3', the code should read the list of files and add 'day4'. To do so, at least I need to know how to retrieve the numbers on the file name.",Get all files with the os module/package (don't have the exact command handy) and then use regex(package) to get the numbers. If you don't want to look into regex you could remove the letters from your string with replace() and convert that string with int().,0.0,False,1,5739 +2018-09-30 05:33:24.990,"python 3, how print function changes output?","The following were what I did in python shell. Can anyone explain the difference? + + + +datetime.datetime.now() + datetime.datetime(2018, 9, 29, 21, 34, 10, 847635) +print(datetime.datetime.now()) + 2018-09-29 21:34:26.900063","The first is the result of calling repr on the datetime value, the second is the result of calling str on a datetime. +The Python shell calls repr on values other than None before printing them, while print tries str before calling repr (if str fails). +This is not dependent on the Python version.",1.2,True,1,5740 +2018-09-30 17:25:43.813,Python's cmd.Cmd case insensitive commands,"I am using python's CLI module which takes any do_* method and sets it as a command, so a do_show() method will be executed if the user type ""show"". +How can I execute the do_show() method using any variation of capitalization from user input e.g. SHOW, Show, sHoW and so on without giving a Command Not Found error? +I think the answer would be something to do with overriding the Cmd class and forcing it to take the user's input.lower() but idk how to do that :/",You should override onecmd to achieve desired functionality.,1.2,True,1,5741 +2018-10-01 07:38:38.010,Possible ways to embed python matplotlib into my presentation interactively,"I need to present my data in various graphs. Usually what I do is to take a screenshot of my graph (I almost exclusively make them with matplotlib) and paste it into my PowerPoint. +Unfortunately my direct superior seems not to be happy with the way I present them. Sometimes he wants certain things in log scale and sometimes he dislike my color palette. The data is all there, but because its an image there's no way I can change that in the meeting. +My superior seems to really care about those things and spend quite a lot of time telling me how to make plots in every single meeting. He (usually) will not comment on my data before I make a plot the way he wants. +That's where my question becomes relevant. Right now what I have in my mind is to have an interactive canvas embedded in my PowerPoint such that I can change the range of the axis, color of my data point, etc in real time. I have been searching online for such a thing but it comes out empty. I wonder if that could be done and how can it be done? +For some simple graphs Excel plot may work, but usually I have to present things in 1D or 2D histograms/density plots with millions of entries. Sometimes I have to fit points with complicated mathematical formulas and that's something Excel is incapable of doing and I must use scipy and pandas. +The closest thing to this I found online is rise with jupyter which convert a jupyter notebook into a slide show. I think that is a good start which allows me to run python code in real time inside the presentation, but I would like to use PowerPoint related solutions if possible, mostly because I am familiar with how PowerPoint works and I still find certain PowerPoint features useful. +Thank you for all your help. While I do prefer PowerPoint, any other products that allows me to modify plots in my presentation in real time or alternatives of rise are welcomed.","When putting a picture in PowerPoint you can decide whether you want to embed it or link to it. If you decide to link to the picture, you would be free to change it outside of powerpoint. This opens up the possibility for the following workflow: +Next to your presentation you have a Python IDE or Juypter notebook open with the scripts that generate the figures. They all have a savefig command in them to save to exactly the location on disc from where you link the images in PowerPoint. If you need to change the figure, you make the changes in the python code, run the script (or cell) and switch back to PowerPoint where the newly created image is updated. +Note that I would not recommend putting too much effort into finding a better solution to this, but rather spend the time thinking about good visual reprentations of the data, due to the following reasons: 1. If your instrutor's demands are completely unreasonable (""I like blue better than green, so you need to use blue."") than it's not worth spending effort into satisfying their demands at all. 2. If your instrutor's demands are based on the fact that the current reprentation does not allow to interprete the data correctly, this can be prevented by spending more thoughts on good plots prior to the presentation. This is a learning process, which I guess your instructor wants you to internalize. After all, you won't get a degree in computer science for writing a PowerPoint backend to matplotlib, but rather for being able to present your research in a way suited for your subject.",1.2,True,1,5742 +2018-10-01 18:01:04.283,"""No package 'coinhsl' found"": IPOPT compiles and passes test, but pyomo cannot find it?","I don't know if the problem is between me and Pyomo.DAE or between me and IPOPT. I am doing this all from the command-line interface in Bash on Ubuntu on Windows (WSL). When I run: + +JAMPchip@DESKTOP-BOB968S:~/examples/dae$ python3 run_disease.py + +I receive the following output: + +WARNING: Could not locate the 'ipopt' executable, which is required + for solver + ipopt Traceback (most recent call last): File ""run_disease.py"", line 15, in + results = solver.solve(instance,tee=True) File ""/usr/lib/python3.6/site-packages/pyomo/opt/base/solvers.py"", line + 541, in solve + self.available(exception_flag=True) File ""/usr/lib/python3.6/site-packages/pyomo/opt/solver/shellcmd.py"", line + 122, in available + raise ApplicationError(msg % self.name) pyutilib.common._exceptions.ApplicationError: No executable found for + solver 'ipopt' + +When I run ""make test"" in the IPOPT build folder, I reecieved: + +Testing AMPL Solver Executable... + Test passed! Testing C++ Example... + Test passed! Testing C Example... + Test passed! Testing Fortran Example... + Test passed! + +But my one major concern is that in the ""configure"" output was the follwing: + +checking for COIN-OR package HSL... not given: No package 'coinhsl' + found + +There were also a few warning when I ran ""make"". I am not at all sure where the issue lies. How do I make python3 find IPOPT, and how do I tell if I have IPOPT on the system for pyomo.dae to find? I am pretty confident that I have ""coibhsl"" in the HSL folder, so how do I make sure that it is found by IPOPT?","As sascha states, you need to make sure that the directory containing your IPOPT executable (likely the build folder) is in your system PATH. That way, if you were to open a terminal and call ipopt from an arbitrary directory, it would be detected as a valid command. This is distinct from being able to call make test from within the IPOPT build folder.",0.0,False,1,5743 +2018-10-02 13:17:45.260,how to disable printscreen key on windows using python,"Is there any way to disable the print screen key when running a python application? +Maybe editing the windows registry is the way? +Thanks!","printscreen is OS Functionality. +Their is No ASCII code for PrintScreen. +Even their are many ways to take PrintScreen. + +Thus, You can Disable keyboard but its difficult to stop user from taking PrintScreen.",0.0,False,1,5744 +2018-10-04 09:28:55.060,How does scrapy behave when enough resources are not available,"I am running multiple scrapers using the command line which is an automated process. +Python : 2.7.12 +Scrapy : 1.4.0 +OS : Ubuntu 16.04.4 LTS +I want to know how scrapy handles the case when + +There is not enough memory/cpu bandwidth to start a scraper. +There is not enough memory/cpu bandwidth during a scraper run. + +I have gone through the documentation but couldn't find anything. +Anyone answering this, you don't have to know the right answer, if you can point me to the general direction of any resource you know which would be helpful, that would also be appreciated","The operating system kills any process that tries to access more memory than the limit. +Applies to python programs too. and scrapy is no different. +More often than not, bandwidth is the bottleneck in scraping / crawling applications. +Memory would only be a bottleneck if there is a serious memory leak in your application. +Your application would just be very slow if CPU is being shared by many process on the same machine.",1.2,True,1,5745 +2018-10-04 17:55:05.990,how to change raspberry pi ip in flask web service,"I have a raspberry pi 3b+ and i'm showing ip camera stream using the Opencv in python. +My default ip in rasppberry is 169.254.210.x range and I have to put the camera in the same range. +How can i change my raspberry ip? +Suppose if I run the program on a web service such as a flask, can i change the raspberry pi server ip every time?","You can statically change your ip of raspberry pi by editing /etc/network/interfaces +Try editing a line of the file which contains address.",0.0,False,1,5746 +2018-10-04 19:48:49.993,"""No module named 'docx'"" error but ""requirement already satisfied"" when I try to install","From what I've read, it sounds like the issue might be that the module isn't in the same directory as my script. Is that the case? If so, how do I find the module and move it to the correct location? +Edit +In case it's relevant - I installed docx using easy_install, not pip.","pip show docx +This will show you where it is installed. However, if you're using python3 then + pip install python-docx +might be the one you need.",0.0,False,2,5747 +2018-10-04 19:48:49.993,"""No module named 'docx'"" error but ""requirement already satisfied"" when I try to install","From what I've read, it sounds like the issue might be that the module isn't in the same directory as my script. Is that the case? If so, how do I find the module and move it to the correct location? +Edit +In case it's relevant - I installed docx using easy_install, not pip.","Please install python-docx. +Then you import docx (not python-docx)",0.0,False,2,5747 +2018-10-05 16:36:21.090,How can I see what packages were installed using `sudo pip install`?,"I know that installing python packages using sudo pip install is bad a security risk. Unfortunately, I found this out after installing quite a few packages using sudo. +Is there a way to find out what python packages I installed using sudo pip install? The end goal being uninstallment and correctly re-installing them within a virtual environment. +I tried pip list to get information about the packages, but it only gave me their version. pip show gave me more information about an individual package such as where it is installed, but I don't know how to make use of that information.","any modules you installed with sudo will be owned by root, so you can open your shell/terminal, cd to site-packages directory & check the directories owner with ls -la, then any that has root in the owner column is the one you want to uninstall.",1.2,True,2,5748 +2018-10-05 16:36:21.090,How can I see what packages were installed using `sudo pip install`?,"I know that installing python packages using sudo pip install is bad a security risk. Unfortunately, I found this out after installing quite a few packages using sudo. +Is there a way to find out what python packages I installed using sudo pip install? The end goal being uninstallment and correctly re-installing them within a virtual environment. +I tried pip list to get information about the packages, but it only gave me their version. pip show gave me more information about an individual package such as where it is installed, but I don't know how to make use of that information.",try the following command: pip freeze,0.0,False,2,5748 +2018-10-06 20:14:32.777,Is it possible to change the loss function dynamically during training?,"I am working on a machine learning project and I am wondering whether it is possible to change the loss function while the network is training. I'm not sure how to do it exactly in code. +For example, start training with cross entropy loss and then halfway through training, switch to 0-1 loss.",You have to implement your own algorithm. This is mostly possible with Tensorflow.,0.0,False,1,5749 +2018-10-08 17:02:32.603,Keras LSTM Input Dimension understanding each other,"but I have been trying to play around with it for awhile. I've seen a lot of guides on how Keras is used to build LSTM models and how people feed in the inputs and get expected outputs. But what I have never seen yet is, for example stock data, how we can make the LSTM model understand patterns between different dimensions, say close price is much higher than normal because volume is low. +Point of this is that I want to do a test with stock prediction, but make it so that each dimensions are not reliant on previous time steps, but also reliant on other dimensions it haves as well. +Sorry if I am not asking the question correctly, please ask more questions if I am not explaining it clearly.","First: Regressors will replicate if you input a feature that gives some direct intuition about the predicted input might be to secure the error is minimized, rather than trying to actually predict it. Try to focus on binary classification or multiclass classification, whether the closing price go up/down or how much. +Second: Always engineer the raw features to give more explicit patterns to the ML algorithm. Think on inputs as Volume(t) - Volume(t-1), close(t)^2 - close(t-1)^2, technical indicators(RSI, CCI, OBV etc.) Create your own features. You can use the pyti library for technical indicators.",0.0,False,1,5750 +2018-10-09 06:31:10.137,SoftLayer API: order a 128 subnet,"We are trying to order a 128 subnet. But looks like it doesn't work, get an error saying Invalid combination specified for ordering a subnet. The same code works to order a 64 subnet. Any thoughts how to order a 128 subnet? + +network_mgr = SoftLayer.managers.network.NetworkManager(client) +network_mgr.add_subnet(‘private’, 128, vlan_id, test_order=True) + + +Traceback (most recent call last): + File ""subnet.py"", line 11, in + result = nwmgr.add_subnet('private', 128, vlan_id, test_order=True) + File ""/usr/local/lib/python2.7/site-packages/SoftLayer/managers/network.py"", line 154, in add_subnet + raise TypeError('Invalid combination specified for ordering a' +TypeError: Invalid combination specified for ordering a subnet.","Currently it seems not possible to add 128 ip subnet into the order, the package used by the manager to order subnets only allows to add subnets for: 64,32,16,8,4 (capacity), +It is because the package that does not contain any item that has 128 ip addresses subnet, this is the reason why you are getting the error Exception you provided. +You may also verify this through the Portal UI, if you can see 128 ip address option through UI in your account, please update this forum with a screenshot.",0.0,False,1,5751 +2018-10-09 10:19:24.127,Add Python to the Windows path,"If I forget to add the Python to the path while installing it, how can I add it to my Windows path? +Without adding it to the path I am unable to use it. Also if I want to put python 3 as default.","Edit Path in Environment Variables +Add Python's path to the end of the list (these are separated by ';'). +For example: + +C:\Users\AppData\Local\Programs\Python\Python36; +C:\Users\AppData\Local\Programs\Python\Python36\Scripts + +and if you want to make it default +you have to edit the system environmental variables +edit the following from the Path + +C:\Windows;C:\Windows\System32;C:\Python27 + +Now Python 3 would have been become the default python in your system +You can check it by python --version",0.3869120172231254,False,1,5752 +2018-10-09 11:15:40.860,"Deploying python with docker, images too big","We've built a large python repo that uses lots of libraries (numpy, scipy, tensor flow, ...) And have managed these dependencies through a conda environment. Basically we have lots of developers contributing and anytime someone needs a new library for something they are working on they 'conda install' it. +Fast forward to today and now we need to deploy some applications that use our repo. We are deploying using docker, but are finding that these images are really large and causing some issues, e.g. 10+ GB. However each individual application only uses a subset of all the dependencies in the environment.yml. +Is there some easy strategy for dealing with this problem? In a sense I need to know the dependencies for each application, but I'm not sure how to do this in an automated way. +Any help here would be great. I'm new to this whole AWS, Docker, and python deployment thing... We're really a bunch of engineers and scientists who need to scale up our software. We have something that works, it just seems like there has to be a better way .","First see if there are easy wins to shrink the image, like using Alpine Linux and being very careful about what gets installed with the OS package manager, and ensuring you only allow installing dependencies or recommended items when truly required, and that you clean up and delete artifacts like package lists, big things you may not need like Java, etc. +The base Anaconda/Ubuntu image is ~ 3.5GB in size, so it's not crazy that with a lot of extra installations of heavy third-party packages, you could get up to 10GB. In production image processing applications, I routinely worked with Docker images in the range of 3GB to 6GB, and those sizes were after we had heavily optimized the container. +To your question about splitting dependencies, you should provide each different application with its own package definition, basically a setup.py script and some other details, including dependencies listed in some mix of requirements.txt for pip and/or environment.yaml for conda. +If you have Project A in some folder / repo and Project B in another, you want people to easily be able to do something like pip install or conda env create -f ProjectB_environment.yml or something, and voila, that application is installed. +Then when you deploy a specific application, have some CI tool like Jenkins build the container for that application using a FROM line to start from your thin Alpine / whatever container, and only perform conda install or pip install for the dependency file for that project, and not all the others. +This also has the benefit that multiple different projects can declare different version dependencies even among the same set of libraries. Maybe Project A is ready to upgrade to the latest and greatest pandas version, but Project B needs some refactoring before the team wants to test that upgrade. This way, when CI builds the container for Project B, it will have a Python dependency file with one set of versions, while in Project A's folder or repo of source code, it might have something different.",1.2,True,1,5753 +2018-10-09 15:27:34.223,Text classification by pattern,"Could you recomend me best way how to do it: i have a list phrases, for example [""free flower delivery"",""flower delivery Moscow"",""color + home delivery"",""flower delivery + delivery"",""order flowers + with delivery"",""color delivery""] and pattern - ""flower delivery"". I need to get list with phrases as close as possible to pattern. +Could you give some advice to how to do it?","Answer given by nflacco is correct.. In addition to that, have you tried edit distance? Try fuzzywuzzy (pip install fuzzywuzzy).. it uses Edit distance to give you a score, how near two sentences are",0.2012947653214861,False,1,5754 +2018-10-10 10:39:12.207,TensorFlow: Correct way of using steps in Stochastic Gradient Descent,"I am currently using TensorFlow tutorial's first_steps_with_tensor_flow.ipynb notebook to learn TF for implementing ML models. In the notebook, they have used Stochastic Gradient Descent (SGD) to optimize the loss function. Below is the snippet of the my_input_function: +def my_input_fn(features, targets, batch_size=1, shuffle=True, num_epochs=None): +Here, it can be seen that the batch_size is 1. The notebook uses a housing data set containing 17000 labeled examples for training. This means for SGD, I will be having 17000 batches. +LRmodel = linear_regressor.train(input_fn = lambda:my_input_fn(my_feature, + targets), steps=100) +I have three questions - + +Why is steps=100 in linear_regressor.train method above? Since we have 17000 batches and steps in ML means the count for evaluating one batch, in linear_regressor.train method steps = 17000 should be initialized, right? +Is number of batches equal to the number of steps/iterations in ML? +With my 17000 examples, if I keep my batch_size=100, steps=500, and num_epochs=5, what does this initialization mean and how does it correlate to 170 batches?","step is the literal meaning: means you refresh the parameters in your batch size; so for linear_regessor.train, it will train 100 times for this batch_size 1. +epoch means to refresh the whole data, which is 17,000 in your set.",-0.3869120172231254,False,1,5755 +2018-10-11 15:24:17.267,Writing unit tests in Python,"I have a task in which i have a csv file having some sample data. The task is to convert the data inside the csv file into other formats like JSON, HTML, YAML etc after applying some data validation rules. +Now i am also supposed to write some unit tests for this in pytest or the unittest module in Python. +My question is how do i actually write the unit tests for this since i am converting them to different JSON/HTML files ? Should i prepare some sample files and then do a comparison with them in my unit tests. +I think only the data validation part in the task can be tested using unittest and not the creation of files in different formats right ? +Any ideas would be immensely helpful. +Thanks in advance.","You should do functional tests, so testing the whole pipeline from a csv file to the end result, but unit tests is about checking that individual steps work. +So for instance, can you read a csv file properly? Does it fail as expected when you don't provide a csv file? Are you able to check each validation unit? Are they failing when they should? Are they passing valid data? +And of course, the result must be tested as well. Starting from a known internal representation, is the resulting json valid? Does it contain all the required data? Same for yaml, HTML. You should not test the formatting, but really what was output and if it's correct. +You should always test that valid data passes and that incorrect doesn't at each step of your work flow.",1.2,True,1,5756 +2018-10-12 12:28:16.983,How to get filtered rowCount in a QSortFilterProxyModel,"I use a QSortFilterProxyModel to filter a QSqlTableModel's data, and want to get the filtered rowCount. +But when I call the QSortFilterProxyModel.rowCount method, the QSqlTableModel's rowCount was returned. +So how can I get the filtered rowcount?",You should after set QSortFilterProxyModel filter to call proxymodel.rowCount。,0.0,False,1,5757 +2018-10-13 10:45:57.270,python 3.7 setting environment variable path,"I installed Anaconda 3 and wanted to execute python from the shell. It returned that it's either written wrong or does not exist. Apparently, I have to add a path to the environmentle variable. +Can someone tell how to do this? +Environment: Windows 10, 64 bit and python 3.7 +Ps: I know the web is full with that but I am notoriously afraid to make a mistake. And I did not find an exact entry for my environment. Thanks in advance. +Best Daniel","Windows: + +search for -->Edit the system environment variables +In Advanced tab, click Environment variabless +In System variables, Select PATH and click edit. Now Click new, ADD YOU PATH. +Click Apply and close. + +Now, check in command prompt",1.2,True,1,5758 +2018-10-14 02:29:15.473,"Given two lists of ints, how can we find the closes number in one list from the other one?","Given I have two different lists with ints. +a = [1, 4, 11, 20, 25] and b = [3, 10, 20] +I want to return a list of length len(b) that stores the closest number in a for each ints in b. +So, this should return [4, 11, 20]. +I can do this in brute force, but what is a more efficient way to do this? +EDIT: It would be great if I can do this with standard library, if needed, only.","Use binary search, assuming the lists are in order. +The brute force in this case is only O(n), so I wouldn't worry about it, just use brute force. +EDIT: +yeh it is O(len(a)*len(b)) (roughly O(n^2) +sorry stupid mistake. +Since these aren't necessarily sorted the fastest is still O(len(a)*len(b)) though. Sorting the lists (using timsort) would take O(nlogn), then binary search O(logn), which results in O(nlog^2n)*O(n)=O(n^2log^2n), which is slower then just O(n^2).",0.0,False,1,5759 +2018-10-14 18:17:29.503,Python tasks and DAGs with different conda environments,"Say that most of my DAGs and tasks in AirFlow are supposed to run Python code on the same machine as the AirFlow server. +Can I have different DAGs use different conda environments? If so, how should I do it? For example, can I use the Python Operator for that? Or would that restrict me to using the same conda environment that I used to install AirFlow. +More generally, where/how should I ideally activate the desired conda environment for each DAG or task?","The Python that is running the Airflow Worker code, is the one whose environment will be used to execute the code. +What you can do is have separate named queues for separate execution environments for different workers, so that only a specific machine or group of machines will execute a certain DAG.",1.2,True,1,5760 +2018-10-14 18:54:30.970,Is it possible to make my own encryption when sending data through sockets?,For example in python if I’m sending data through sockets could I make my own encryption algorithm to encrypt that data? Would it be unbreakable since only I know how it works?,"Yes you can. Would it be unbreakable? No. This is called security through obscurity. You're relying on the fact that nobody knows how it works. But can you really rely on that? +Someone is going to receive the data, and they'll have to decrypt it. The code must run on their machine for that to happen. If they have the code, they know how it works. Well, at least anyone with a lot of spare time and nothing else to do can easily reverse engineer it, and there goes your obscurity. +Is it feasable to make your own algorithm? Sure. A bit of XOR here, a bit of shuffling there... eventually you'll have an encryption algorithm. It probably wouldn't be a good one but it would do the job, at least until someone tries to break it, then it probably wouldn't last a day. +Does Python care? Do sockets care? No. You can do whatever you want with the data. It's just bits after all, what they mean is up to you. +Are you a cryptographer? No, otherwise you wouldn't be here asking this. So should you do it? No.",1.2,True,1,5761 +2018-10-14 19:10:42.147,imshow() with desired framerate with opencv,"Is there any workaround how to use cv2.imshow() with a specific framerate? Im capturing the video via VideoCapture and doing some easy postprocessing on them (both in a separeted thread, so it loads all frames in Queue and the main thread isn't slowed by the computation). I tryed to fix the framerate by calculating the time used for ""reading"" the image from the queue and then substract that value from number of miliseconds avalible for one frame: +if I have as input video with 50FPS and i want to playback it in real-time i do 1000/50 => 20ms per frame. +And then wait that time using cv2.WaitKey() +But still I get some laggy output. Which is slower then the source video","I don't believe there is such a function in opencv but maybe you could improve your method by adding a dynamic wait time using timers? timeit.default_timer() +calculate the time taken to process and subtract that from the expected framerate and maybe add a few ms buffer. +eg cv2.WaitKey((1000/50) - (time processing finished - time read started) - 10) +or you could have a more rigid timing eg script start time + frame# * 20ms - time processing finished +I haven't tried this personally so im not sure if it will actually work, also might be worth having a check so the number isnt below 1",1.2,True,1,5762 +2018-10-16 21:43:21.673,"Azure Machine Learning Studio execute python script, Theano unable to execute optimized C-implementations (for both CPU and GPU)","I am execute a python script in Azure machine learning studio. I am including other python scripts and python library, Theano. I can see the Theano get loaded and I got the proper result after script executed. But I saw the error message: + +WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string. + +Did anyone know how to solve this problem? Thanks!","I don't think you can fix that - the Python script environment in Azure ML Studio is rather locked down, you can't really configure it (except for choosing from a small selection of Anaconda/Python versions). +You might be better off using the new Azure ML service, which allows you considerably more configuration options (including using GPUs and the like).",1.2,True,1,5763 +2018-10-17 14:07:06.357,how to use pip install a package if there are two same version of python on windows,"I have two same versions of python on windows. Both are 3.6.4. I installed one of them, and the other one comes with Anaconda. +My question is how do I use pip to install a package for one of them? It looks like the common method will not work since the two python versions are the same.","Use virtualenv, conda environment or pipenv, it will help with managing packages for different projects.",0.0,False,2,5764 +2018-10-17 14:07:06.357,how to use pip install a package if there are two same version of python on windows,"I have two same versions of python on windows. Both are 3.6.4. I installed one of them, and the other one comes with Anaconda. +My question is how do I use pip to install a package for one of them? It looks like the common method will not work since the two python versions are the same.","pip points to only one installation because pip is a script from one python. +If you have one Python in your PATH, then it's that python and that pip that will be used.",0.2012947653214861,False,2,5764 +2018-10-18 03:14:15.287,How can i make computer read a python file instead of py?,"I have a problem with installing numpy with python 3.6 and i have windows 10 64 bit +Python 3.6.6 +But when i typed python on cmd this appears +Python is not recognized as an internal or external command +I typed py it solves problem but how can i install numpy +I tried to type commant set path =c:/python36 +And copy paste the actual path on cmd but it isnt work +I tried also to edit the enviromnent path through type a ; and c:/python 36 and restart but it isnt help this +I used pip install nupy and download pip but it isnt work","On Windows, the py command should be able to launch any Python version you have installed. Each Python installation has its own pip. To be sure you get the right one, use py -3.6 -m pip instead of just pip. + +You can use where pip and where pip3 to see which Python's pip they mean. Windows just finds the first one on your path. + +If you activate a virtualenv, then you you should get the right one for the virtualenv while the virtualenv is active.",0.0,False,2,5765 +2018-10-18 03:14:15.287,How can i make computer read a python file instead of py?,"I have a problem with installing numpy with python 3.6 and i have windows 10 64 bit +Python 3.6.6 +But when i typed python on cmd this appears +Python is not recognized as an internal or external command +I typed py it solves problem but how can i install numpy +I tried to type commant set path =c:/python36 +And copy paste the actual path on cmd but it isnt work +I tried also to edit the enviromnent path through type a ; and c:/python 36 and restart but it isnt help this +I used pip install nupy and download pip but it isnt work",Try pip3 install numpy. To install python 3 packages you should use pip3,0.0,False,2,5765 +2018-10-18 09:53:46.373,Is it possible to manipulate data from csv without the need for producing a new csv file?,"I know how to import and manipulate data from csv, but I always need to save to xlsx or so to see the changes. Is there a way to see 'live changes' as if I am already using Excel? +PS using pandas +Thanks!",This is not possible using pandas. This lib creates copy of your .csv / .xls file and stores it in RAM. So all changes are applied to file stored in you memory not on disk.,1.2,True,1,5766 +2018-10-19 09:04:38.457,how to remove zeros after decimal from string remove all zero after dot,"I have data frame with a object column lets say col1, which has values likes: +1.00, +1, +0.50, +1.54 +I want to have the output like the below: +1, +1, +0.5, +1.54 +basically, remove zeros after decimal values if it does not have any digit after zero. Please note that i need answer for dataframe. pd.set_option and round don't work for me.","A quick-and-dirty solution is to use ""%g"" % value, which will convert floats 1.5 to 1.5 but 1.0 to 1 and so on. The negative side-effect is that large numbers will be represented in scientific notation like 4.44e+07.",0.0,False,1,5767 +2018-10-19 10:34:41.947,Call Python functions from C# in Visual Studio Python support VS 2017,"This is related to new features Visual Studio has introduced - Python support, Machine Learning projects to support. +I have installed support and found that I can create a python project and can run it. However, I could not find how to call a python function from another C# file. +Example, I created a classifier.py from given project samples, Now I want to run the classifier and get results from another C# class. +If there is no such portability, then how is it different from creating a C# Process class object and running the Python.exe with our py file as a parameter.","As per the comments, python support has come in visual studio. Visual studio is supporting running python scripts and debugging. +However, calling one python function from c# function and vice versa is not supported yet. +Closing the thread. Thanks for suggestions.",1.2,True,1,5768 +2018-10-19 10:55:44.210,Running Jenkinsfile with multiple Python versions,"I have a multibranch pipeline set up in Jenkins that runs a Jenkinsfile, which uses pytest for testing scripts, and outputs the results using Cobertura plug-in and checks code quality with Pylint and Warnings plug-in. +I would like to test the code with Python 2 and Python 3 using virtualenv, but I do not know how to perform this in the Jenkinsfile, and Shining Panda plug-in will not work for multibranch pipelines (as far as I know). Any help would be appreciated.","You can do it even using vanilla Jenkins (without any plugins). 'Biggest' problem will be with proper parametrization. But let's start from the beginning. +2 versions of Python +When you install 2 versions of python on a single machine you will have 2 different exec files. For python2 you will have python and for python3 you will have python3. Even when you create virtualenv (use venv) you will have both of them. So you are able to run unittests agains both versions of python. It's just a matter of executing proper command from batch/bash script. +Jenkins +There are many ways of performing it: + +you can prepare separate jobs for both python 2 and 3 versions of tests and run them from jenkins file +you can define the whole pipeline in a single jenkins file where each python test is a different stage (they can be run one after another or concurrently)",0.3869120172231254,False,1,5769 +2018-10-20 01:58:46.053,How to find redundant paths (subpaths) in the trajectory of a moving object?,"I need to track a moving deformable object in a video (but only 2D space). How do I find the paths (subpaths) revisited by the object in the span of its whole trajectory? For instance, if the object traced a path, p0-p1-p2-...-p10, I want to find the number of cases the object traced either p0-...-p10 or a sub-path like p3-p4-p5. Here, p0,p1,...,p10 represent object positions (in (x,y) pixel coordinates at the respective instants). Also, how do I know at which frame(s) these paths (subpaths) are being revisited?","I would first create a detection procedure that outputs a list of points visited along with their video frame number. Then use list exploration functions to know how many redundant suites are found and where. +As you see I don't write your code. If you need anymore advise please ask!",0.0,False,1,5770 +2018-10-20 13:20:10.283,Python - How to run script continuously to look for files in Windows directory,"I got a requirement to parse the message files in .txt format real time as and when they arrive in incoming windows directory. The directory is in my local Windows Virtual Machine something like D:/MessageFiles/ +I wrote a Python script to parse the message files because it's a fixed width file and it parses all the files in the directory and generates the output. Once the files are successfully parsed, it will be moved to archive directory. Now, i would like to make this script run continuously so that it looks for the incoming message files in the directory D:/MessageFiles/ and perform the processing as and when it sees the new files in the path. +Can someone please let me know how to do this?","There are a few ways to do this, it depends on how fast you need it to archive the files. +If the frequency is low, for example every hour, you can try to use windows task scheduler to run the python script. +If we are talking high frequency, or you really want a python script running 24/7, you could put it in a while loop and at the end of the loop do time.sleep() +If you go with this, I would recommend not blindly parsing the entire directory on every run, but instead finding a way to check whether new files have been added to the directory (such as the amount of files perhaps, or the total size). And then if there is a fluctuation you can archive.",1.2,True,1,5771 +2018-10-20 15:04:32.733,PyOpenGL camera system,"I'm confused on how the PyOpenGL camera works or how to implement it. Am I meant to rotate and move the whole world around the camera or is there a different way? +I couldn't find anything that can help me and I don't know how to translate C to python. +I just need a way to transform the camera that can help me understand how it works.","To say it bluntly: There is no such thing as a ""camera"" in OpenGL (neither there is in DirectX, or Vulkan, or in any of the legacy 3D graphics APIs). The effects of a camera is understood as some parameter that contributes to the ultimate placement of geometry inside the viewport volume. +The sooner you understand that all that current GPUs do is offering massively accelerated computational resources to set the values of pixels in a 2D grid, where the region of the pixels changed are mere points, lines or triangles on a 2D plane onto which they are projected from an arbitrarily dimensioned, abstract space, the better. +You're not even moving around the world around the camera. Setting up transformations is actually errecting the stage in which ""the world"" will appear in the first place. Any notion of a ""camera"" is an abstraction created by a higher level framework, like a third party 3D engine or your own creation. +So instead of thinking in terms of a camera, which constrains your thinking, you should think about it this way: +What kind of transformations do I have to chain up, to give a tuple of numbers that are called ""position"" an actual meaning, by letting this position turn up at a certain place on the visible screen? +You really ought to think that way, because that is what's actually happening.",1.2,True,1,5772 +2018-10-21 13:11:30.197,Anaconda Installation on Azure Web App Services,"I install my python modules via pip for my Azure Web Apps. But some of python libraries that I need are only available in conda. I have been trying to install anaconda on Azure Web Apps (windows/linux), no success so far. Any suggestions/examples on how to use conda env on azure web apps?","Currently, Azure App Service only supports the official Python to be installed as extensions. Instead of using the normal App Service, I would suggest you to use a Webapp for Container so that you can deploy your web app as a docker container. I suppose this is the only solution until Microsoft supports Anaconda on App Service.",0.3869120172231254,False,1,5773 +2018-10-21 15:08:58.620,Why tokenize/preprocess words for language analysis?,"I am currently working on a Python tweet analyser and part of this will be to count common words. I have seen a number of tutorials on how to do this, and most tokenize the strings of text before further analysis. +Surely it would be easier to avoid this stage of preprocessing and count the words directly from the string - so why do this?","Perhaps I'm being overly correct, but doesn't tokenization simply refer to splitting up the input stream (of characters, in this case) based on delimiters to receive whatever is regarded as a ""token""? +Your tokens can be arbitrary: you can perform analysis on the word level where your tokens are words and the delimiter is any space or punctuation character. It's just as likely that you analyse n-grams, where your tokens correspond to a group of words and delimiting is done e.g. by sliding a window. +So in short, in order to analyse words in a stream of text, you need to tokenize to receive ""raw"" words to operate on. +Tokenization however is often followed by stemming and lemmatization to reduce noise. This becomes quite clear when thinking about sentiment analysis: if you see the tokens happy, happily and happiness, do you want to treat them each separately, or wouldn't you rather combine them to three instances of happy to better convey a stronger notion of ""being happy""?",1.2,True,2,5774 +2018-10-21 15:08:58.620,Why tokenize/preprocess words for language analysis?,"I am currently working on a Python tweet analyser and part of this will be to count common words. I have seen a number of tutorials on how to do this, and most tokenize the strings of text before further analysis. +Surely it would be easier to avoid this stage of preprocessing and count the words directly from the string - so why do this?","Tokenization is an easy way of understanding the lexicon/vocabulary in text processing. +A basic first step in analyzing language or patterns in text is to remove symbols/punctuations and stop words. With tokenization you are able to split the large chunks of text to identify and remove text which might not add value, in many cases, stop words like 'the','a','and', etc do not add much value in identifying words of interest. +Word frequencies are also very common in understanding the usage of words in text, Google's Ngram allows for language analysis and plots out the popularity/frequency of a word over the years. If you do not tokenize or split the strings, you will not have a basis to count the words that appear in a text. +Tokenization also allows you to run a more advanced analysis, for example tagging the part of speech or assigning sentiments to certain words. Also for machine learning, texts are mostly preprocessed to convert them to arrays which are used in te different layers of neural networks. Without tokenizing, the inputs will all be too distinct to run any analysis on.",0.0,False,2,5774 +2018-10-23 13:07:01.447,Shutdown (a script) one raspberry pi with another raspberry pi,"I am currently working on a school project. We need to be able to shutdown (and maybe restart) a pythonscript that is running on another raspberry pi using a button. +I thought that the easiest thing, might just be to shutdown the pi from the other pi. But I have no experience on this subject. +I don't need an exact guide (I appreciate all the help I can get) but does anyone know how one might do this?","Well first we should ask if the PI you are trying to shutdown is connect to a network ? (LAN or the internet, doesn't matter). +If the answer is yes, you can simply connect to your PI through SSH, and call shutdown.sh. +I don't know why you want another PI, you can do it through any device connected to the same network as your first PI (Wi-Fi or ethernet if LAN, or simply from anytwhere if it's open to the internet). +You could make a smartphone app, or any kind or code that can connect to SSH (all of them).",0.0,False,1,5775 +2018-10-23 15:25:12.317,"python+docker: docker volume mounting with bad perms, data silently missing","I'm running into an issue without volume mounting, combined with the creation of directories in python. +Essentially inside my container, I'm writing to some path /opt/…, and I may have to make the path (which I'm using os.makedirs for) +If I mount a host file path like -v /opt:/opt, with bad ""permissions"" where the docker container does not seem to be able to write to, the creation of the path inside the container DOES NOT FAIL. The makedirs(P) works, because inside the container, it can make the dir just fine, because it has sudo permissions. However, nothing gets written, silently, on the host at /opt/…. The data just isn't there, but no exception is ever raised. +If I mount a path with proper/open permissions, like -v /tmp:/opt, then the data shows up on the host machine at /tmp/… as expected. +So, how do I not silently fail if there are no write permissions on the host on the left side of the -v argument?\ +EDIT: my question is ""how do I detect this bad deployment scenario, crash, and fail fast inside the container, if the person who deploys the container, does it wrong""? Just silently not writing data isn't acceptable.","The bad mount is root on the host right, and the good mount is the user in the Docker group on the host? Can you check the user/group of the mounted /opt? It should be different than that of /tmp.",0.0,False,1,5776 +2018-10-24 06:17:42.420,Building comprehensive scraping program/database for real estate websites,"I have a project I’m exploring where I want to scrape the real estate broker websites in my country (30-40 websites of listings) and keep the information about each property in a database. +I have experimented a bit with scraping in python using both BeautifulSoup and Scrapy. +What I would Ideally like to achieve is a daily updated database that will find new properties and remove properties when they are sold. +Any pointers as to how to achieve this? +I am relatively new to programming and open to learning different languages and resources if python isn’t suitable. +Sorry if this forum isn’t intended for this kind of vague question :-)",Build a scraper and schedule a daily run. You can use scrapy and the daily run will update the database daily.,0.0,False,1,5777 +2018-10-24 09:41:09.793,Using convolution layer trained weights for different image size,"I want to use the first three convolution layers of vgg-16 to generate feature maps. +But i want to use it with variable image size,i.e not imagenet size of 224x224 or 256x256. Such as 480x640or any other randome image dimension. +As convolution layer are independent of image spatial size, how can I use the weights for varying image sizes? +So how do we use the pre-trained weights of vgg-16 upto the first three convolution layers. +Kindly let me know if that is possible.","As convolution layer are independent of image size +Actually it's more complicated than that. The kernel itself is independent of the image size because we apply it on each pixel. And indeed, the training of these kernels can be reused. +But this means that the output size is dependent on the image size, because this is the number of nodes that are fed out of the layer for each input pixel. So the dense layer is not adapted to your image, even if the feature extractors are independent. +So you need to preprocess your image to fit into the size of the first layer or you retrain your dense layers from scratch. +When people talk about ""transfer-learning"" is what people have done in segmentation for decades. You reuse the best feature extractors and then you train a dedicated model with these features.",1.2,True,1,5778 +2018-10-24 18:05:05.703,Display complex numbers in UI when using wxPython,"I know complex math and the necessary operations (either ""native"" Python, or through NumPy). My question has to do with how to display complex numbers in a UI using wxPython. All the questions I found dealing with Python and complex numbers have to do with manipulating complex data. +My original thought was to subclass wx.TextCtrl and override the set and get methods to apply and strip some formatting as needed, and concatenating an i (or j) to the imaginary part. +Am I going down the wrong path? I feel like displaying complex numbers is something that should already be done somewhere. +What would be the recommended pattern for this even when using another UI toolkit, as the problem is similar. Also read my comment below on why I would like to do this.","As Brian considered my first comment good advice, and he got no more answers, I am posting it as an answer. Please refer also to the other question comments discussing the issue. + +In any UI you display strings and you read strings from the user. Why + would you mix the type to string or string to type translation with + widgets functionality? Get them, convert and use, or ""print"" them to + string and show the string in the ui.",0.0,False,1,5779 +2018-10-24 21:37:53.237,Change file metadata using Apache Beam on a cloud database?,"Can you change the file metadata on a cloud database using Apache Beam? From what I understand, Beam is used to set up dataflow pipelines for Google Dataflow. But is it possible to use Beam to change the metadata if you have the necessary changes in a CSV file without setting up and running an entire new pipeline? If it is possible, how do you do it?","You could code Cloud Dataflow to handle this but I would not. A simple GCE instance would be easier to develop and run the job. An even better choice might be UDF (see below). +There are some guidelines for when Cloud Dataflow is appropriate: + +Your data is not tabular and you can not use SQL to do the analysis. +Large portions of the job are parallel -- in other words, you can process different subsets of the data on different machines. +Your logic involves custom functions, iterations, etc... +The distribution of the work varies across your data subsets. + +Since your task involves modifying a database, I am assuming a SQL database, it would be much easier and faster to write a UDF to process and modify the database.",0.0,False,1,5780 +2018-10-25 02:44:34.287,How to use Tensorflow Keras API,"Well I start learning Tensorflow but I notice there's so much confusion about how to use this thing.. +First, some tutorials present models using low level API tf.varibles, scopes...etc, but other tutorials use Keras instead and for example to use tensor board to invoke callbacks. +Second, what's the purpose of having ton of duplicate API, really what's the purpose behind using high level API like Keras when you have low level to build model like Lego blocks? +Finally, what's the true purpose of using eager execution?","You can use these APIs all together. E.g. if you have a regular dense network, but with an special layer you can use higher level API for dense layers (tf.layers and tf.keras) and low level API for your special layer. Furthermore, it is complex graphs are easier to define in low level APIs, e.g. if you want to share variables, etc. +Eager execution helps you for fast debugging, it evaluates tensors directly without a need of invoking a session.",0.0,False,1,5781 +2018-10-25 11:08:14.153,Keras flow_from_dataframe wrong data ordering,"I am using keras's data generator with flow_from_dataframe. for training it works just fine, but when using model.predict_generator on the test set, I discovered that the ordering of the generated results is different than the ordering of the ""id"" column in my dataframe. +shuffle=False does make the ordering of the generator consistent, but it is a different ordering than the dataframe. I also tried different batch sizes and the corresponding correct steps for the predict_generator function. (for example: batch_Size=1, steps=len(data)) +how can I make sure the labels predicted for my test set are ordered in the same way of my dataframe ""id"" column?","While I haven't found a way to decide the order in which the generator produces data, the order can be obtained with the generator.filenames property.",1.2,True,1,5782 +2018-10-25 15:16:07.853,Write python functions to operate over arbitrary axes,"I've been struggling with this problem in various guises for a long time, and never managed to find a good solution. +Basically if I want to write a function that performs an operation over a given, but arbitrary axis of an arbitrary rank array, in the style of (for example) np.mean(A,axis=some_axis), I have no idea in general how to do this. +The issue always seems to come down to the inflexibility of the slicing syntax; if I want to access the ith slice on the 3rd index, I can use A[:,:,i], but I can't generalise this to the nth index.","numpy functions use several approaches to do this: + +transpose axes to move the target axis to a known position, usually first or last; and if needed transpose the result +reshape (along with transpose) to reduce the problem simpler dimensions. If your focus is on the n'th dimension, it might not matter where the (:n) dimension are flattened or not. They are just 'going along for the ride'. +construct an indexing tuple. idx = (slice(None), slice(None), j); A[idx] is the equivalent of A[:,:,j]. Start with a list or array of the right size, fill with slices, fiddle with it, and then convert to a tuple (tuples are immutable). +Construct indices with indexing_tricks tools like np.r_, np.s_ etc. + +Study code that provides for axes. Compiled ufuncs won't help, but functions like tensordot, take_along_axis, apply_along_axis, np.cross are written in Python, and use one or more of these tricks.",1.2,True,1,5783 +2018-10-25 15:26:46.793,Highly variable execution times in Cython functions,"I have a performance measurement issue while executing a migration to Cython from C-compiled functions (through scipy.weave) called from a Python engine. +The new cython functions profiled end-to-end with cProfile (if not necessary I won't deep down in cython profiling) record cumulative measurement times highly variable. +Eg. the cumulate time of a cython function executed 9 times per 5 repetitions (after a warm-up of 5 executions - not took in consideration by the profiling function) is taking: + +in a first round 215,627339 seconds +in a second round 235,336131 seconds + +Each execution calls the functions many times with different, but fixed parameters. +Maybe this variability could depends on CPU loads of the test machine (a cloud-hosted dedicated one), but I wonder if such a variability (almost 10%) could depend someway by cython or lack of optimization (I already use hints on division, bounds check, wrap-around, ...). +Any idea on how to take reliable metrics?","First of all, you need to ensure that your measurement device is capable of measuring what you need: specifically, only the system resources you consume. UNIX's utime is one such command, although even that one still includes swap time. Check the documentation of your profiler: it should have capabilities to measure only the CPU time consumed by the function. If so, then your figures are due to something else. +Once you've controlled the external variations, you need to examine the internal. You've said nothing about the complexion of your function. Some (many?) functions have available short-cuts for data-driven trivialities, such as multiplication by 0 or 1. Some are dependent on an overt or covert iteration that varies with the data. You need to analyze the input data with respect to the algorithm. +One tool you can use is a line-oriented profiler to detail where the variations originate; seeing which lines take the extra time should help determine where the ""noise"" comes from.",0.2012947653214861,False,2,5784 +2018-10-25 15:26:46.793,Highly variable execution times in Cython functions,"I have a performance measurement issue while executing a migration to Cython from C-compiled functions (through scipy.weave) called from a Python engine. +The new cython functions profiled end-to-end with cProfile (if not necessary I won't deep down in cython profiling) record cumulative measurement times highly variable. +Eg. the cumulate time of a cython function executed 9 times per 5 repetitions (after a warm-up of 5 executions - not took in consideration by the profiling function) is taking: + +in a first round 215,627339 seconds +in a second round 235,336131 seconds + +Each execution calls the functions many times with different, but fixed parameters. +Maybe this variability could depends on CPU loads of the test machine (a cloud-hosted dedicated one), but I wonder if such a variability (almost 10%) could depend someway by cython or lack of optimization (I already use hints on division, bounds check, wrap-around, ...). +Any idea on how to take reliable metrics?",I'm not a performance expert but from my understanding the thing you should be measuring would be the average time it take per execution not the cumulative time? Other than that is your function doing any like reading from disk and/or making network requests?,0.0,False,2,5784 +2018-10-25 20:43:10.730,Kernel size change in convolutional neural networks,"I have been working on creating a convolutional neural network from scratch, and am a little confused on how to treat kernel size for hidden convolutional layers. For example, say I have an MNIST image as input (28 x 28) and put it through the following layers. +Convolutional layer with kernel_size = (5,5) with 32 output channels + +new dimension of throughput = (32, 28, 28) + +Max Pooling layer with pool_size (2,2) and step (2,2) + +new dimension of throughput = (32, 14, 14) + +If I now want to create a second convolutional layer with kernel size = (5x5) and 64 output channels, how do I proceed? Does this mean that I only need two new filters (2 x 32 existing channels) or does the kernel size change to be (32 x 5 x 5) since there are already 32 input channels? +Since the initial input was a 2D image, I do not know how to conduct convolution for the hidden layer since the input is now 3 dimensional (32 x 14 x 14).","you need 64 kernel, each with the size of (32,5,5) . +depth(#channels) of kernels, 32 in this case, or 3 for a RGB image, 1 for gray scale etc, should always match the input depth, but values are all the same. +e.g. if you have a 3x3 kernel like this : [-1 0 1; -2 0 2; -1 0 1] and now you want to convolve it with an input with N as depth or say channel, you just copy this 3x3 kernel N times in 3rd dimension, the following math is just like the 1 channel case, you sum all values in all N channels which your kernel window is currently on them after multiplying the kernel values with them and get the value of just 1 entry or pixel. so what you get as output in the end is a matrix with 1 channel:) how much depth you want your matrix for next layer to have? that's the number of kernels you should apply. hence in your case it would be a kernel with this size (64 x 32 x 5 x 5) which is actually 64 kernels with 32 channels for each and same 5x5 values in all cahnnels. +(""I am not a very confident english speaker hope you get what I said, it would be nice if someone edit this :)"")",0.0,False,1,5785 +2018-10-25 21:40:47.257,Python: I can not get pynput to install,"I'm trying to run a program with pynput. I tried installing it through terminal on Mac with pip. However, it still says it's unresolved on my ide PyCharm. Does anyone have any idea of how to install this?","I have three theories, but first: make sure it is installed by running python -c ""import pynput"" + +JetBrain's IDEs typically do not scan for package updates, so try restarting the IDE. +JetBrain's IDE might configure a python environment for you, this might cause you to have to manually import it in your run configuration. +You have two python versions installed and you installed the package on the opposite version you run script on. + +I think either 1 or 3 is the most likely.",0.0,False,1,5786 +2018-10-26 07:04:15.230,How to get the dimension of tensors at runtime?,"I can get the dimensions of tensors at graph construction time via manually printing shapes of tensors(tf.shape()) but how to get the shape of these tensors at session runtime? +The reason that I want shape of tensors at runtime is because at graph construction time shape of some tensors is coming as (?,8) and I cannot deduce the first dimension then.","You have to make the tensors an output of the graph. For example, if showme_tensor is the tensor you want to print, just run the graph like that : +_showme_tensor = sess.run(showme_tensor) +and then you can just print the output as you print a list. If you have different tensors to print, you can just add them like that : +_showme_tensor_1, _showme_tensor_2 = sess.run([showme_tensor_1, showme_tensor_2])",0.0,False,1,5787 +2018-10-27 10:53:32.190,python - pandas dataframe to powerpoint chart backend,"I have a pandas dataframe result which stores a result obtained from a sql query. I want to paste this result onto the chart backend of a specified chart in the selected presentation. Any idea how to do this? +P.S. The presentation is loaded using the module python-pptx","you will need to read a bit about python-pptx. +You need chart's index and slide index of the chart. Once you know them +get your chart object like this-> +chart = presentation.slides[slide_index].shapes[shape_index].chart +replacing data +chart.replace_data(new_chart_data) +reset_chart_data_labels(chart) +then when you save your presentation it will have updated the data. +usually, I uniquely name all my slides and charts in a template and then I have a function that will get me the chart's index and slide's index. (basically, I iterate through all slides, all shapes, and find a match for my named chart). +Here is a screenshot where I name a chart->[![screenshot][1]][1]. Naming slides is a bit more tricky and I will not delve into that but all you need is slide_index just count the slides 0 based and then you have the slide's index. +[1]: https://i.stack.imgur.com/aFQwb.png",0.0,False,1,5788 +2018-10-31 22:26:56.993,How to make Flask app up and running after server restart?,"What is the recommended way to run Flask app (e.g. via Gunicorn?) and how to make it up and running automatically after linux server (redhat) restart? +Thanks",have you looked at supervisord? it works reasonably well and handles restarting processes automatically if they fail as well as looking after error logs nicely,0.0,False,1,5789 +2018-11-01 03:08:27.057,cv2 show video stream & add overlay after another function finishes,"I am current working on a real time face detection project. +What I have done is that I capture the frame using cv2, do detection and then show result using cv2.imshow(), which result in a low fps. +I want a high fps video showing on the screen without lag and a low fps detection bounding box overlay. +Is there a solution to show the real time video stream (with the last detection result bounding box), and once a new detection is finished, show the new bounding box and the background was not delayed by the detection function. +Any help is appreciated! +Thanks!","A common approach would be to create a flag that allows the detection algorithim to only run once every couple of frames and save the predicted reigons of interest to a list, whilst creating bounding boxes for every frame. +So for example you have a face detection algorithim, process every 15th frame to detect faces, but in every frame create a bounding box from the predictions. Even though the predictions get updated every 15 frames. +Another approach could be to add an object tracking layer. Run your heavy algorithim to find the ROIs and then use the object tracking library to hold on to them till the next time it runs the detection algorithim. +Hope this made sense.",1.2,True,1,5790 +2018-11-01 07:22:44.353,What Is the Correct Mimetype (in and out) for a .Py File for Google Drive?,"I have a script that uploads files to Google Drive. I want to upload python files. I can do it manually and have it keep the file as .py correctly (and it's previewable), but no matter what mimetypes I try, I can't get my program to upload it correctly. It can upload the file as a .txt or as something GDrive can't recognize, but not as a .py file. I can't find an explicit mimetype for it (I found a reference for text/x-script.python but it doesn't work as an out mimetype). +Does anyone know how to correctly upload a .py file to Google Drive using REST?",Also this is a valid Python mimetype: text/x-script.python,-0.2012947653214861,False,1,5791 +2018-11-01 09:31:15.857,Running a python file in windows after removing old python files,So I am running python 3.6.5 on a school computer the most things are heavily restricted to do on a school computer and i can only use python on drive D. I cannot use batch either. I had python 2.7 on it last year until i deleted all the files and installed python 3.6.5 after that i couldn't double click on a .py file to open it as it said continue using E:\Python27\python(2.7).exe I had the old python of a USB which is why it asks this but know i would like to change that path the the new python file so how would i do that in windows,Just open your Python IDE and open the file manually.,0.0,False,1,5792 +2018-11-01 22:25:51.750,GROUPBY with showing all the columns,"I want to do a groupby of my MODELS by CITYS with keeping all the columns where i can print the percentage of each MODELS IN THIS CITY. +I put my dataframe in PHOTO below. +And i have written this code but i don""t know how to do ?? +for name,group in d_copy.groupby(['CITYS'])['MODELS']:","Did you try this : d_copy.groupby(['CITYS','MODELS']).mean() to have the average percentage of a model by city. +Then if you want to catch the percentages you have to convert it in DF and select the column : pd.DataFrame(d_copy.groupby(['CITYS','MODELS']).mean())['PERCENTAGE']",0.0,False,1,5793 +2018-11-03 05:34:23.617,Google Data Studio Connector and App Scripts,"I am working on a project for a client in which I need to load a lot of data into data studio. I am having trouble getting the deployment to work with my REST API. +The API has been tested with code locally but I need to know how to make it compatible with the code base in App Scripts. Has anyone else had experience with working around this? The endpoint is a Python Flask application. +Also, is there a limit on the amount of data that you can dump in a single response to the Data Studio? As a solution to my needs(needing to be able to load data for 300+ accounts) I have created a program that caches the data needed from each account and returns the whole payload at once. There are a lot of entries, so I was wondering if they had a limit to what can be uploaded at once. +Thank you in advance","I found the issue, it was a simple case of forgetting to add the url to the whitelist.",0.3869120172231254,False,1,5794 +2018-11-03 15:56:12.343,Multi-Line Combobox in Tkinter,"Is it possible to have a multi-line text entry field with drop down options? +I currently have a GUI with a multi-line Text widget where the user writes some comments, but I would like to have some pre-set options for these comments that the user can hit a drop-down button to select from. +As far as I can tell, the Combobox widget does not allow changing the height of the text-entry field, so it is effectively limited to one line (expanding the width arbitrarily is not an option). Therefore, what I think I need to do is sub-class the Text widget and somehow add functionality for a drop down to show these (potentially truncated) pre-set options. +I foresee a number of challenges with this route, and wanted to make sure I'm not missing anything obvious with the existing built-in widgets that could do what I need.","I don't think you are missing anything. Note that ttk.Combobox is a composite widget. It subclasses ttk.Entry and has ttk.Listbox attached. +To make multiline equivalent, subclass Text. as you suggested. Perhaps call it ComboText. Attach either a frame with multiple read-only Texts, or a Text with multiple entries, each with a separate tag. Pick a method to open the combotext and methods to close it, with or without copying a selection into the main text. Write up an initial doc describing how to operate the thing.",0.2012947653214861,False,1,5795 +2018-11-04 15:50:14.623,"Apache - if file does not exist, run script to create it, then serve it","How can I get this to happen in Apache (with python, on Debian if it matters)? + +User submits a form +Based on the form entries I calculate which html file to serve them (say 0101.html) +If 0101.html exists, redirect them directly to 0101.html +Otherwise, run a script to create 0101.html, then redirect them to it. + +Thanks! +Edit: I see there was a vote to close as too broad (though no comment or suggestion). I am just looking for a minimum working example of the Apache configuration files I would need. If you want the concrete way I think it will be done, I think apache just needs to check if 0101.html exists, if so serve it, otherwise run cgi/myprogram.py with input argument 0101.html. Hope this helps. If not, please suggest how I can make it more specific. Thank you.","Apache shouldn't care. Just serve a program that looks for the file. If it finds it it will read it (or whatever and) return results and if it doesn't find it, it will create and return the result. All can be done with a simple python file.",1.2,True,1,5796 +2018-11-04 18:53:52.133,AWS CLI upload failed: unknown encoding: idna,"I am trying to push some files up to s3 with the AWS CLI and I am running into an error: +upload failed: ... An HTTP Client raised and unhandled exception: unknown encoding: idna +I believe this is a Python specific problem but I am not sure how to enable this type of encoding for my python interpreter. I just freshly installed Python 3.6 and have verified that it being used by powershell and cmd. +$> python --version + Python 3.6.7 +If this isn't a Python specific problem, it might be helpful to know that I also just freshly installed the AWS CLI and have it properly configured. Let me know if there is anything else I am missing to help solve this problem. Thanks.","I had the same problem in Windows. +After investigating the problem, I realized that the problem is in the aws-cli installed using the MSI installer (x64). After removing ""AWS Command Line Interface"" from the list of installed programs and installing aws-cli using pip, the problem was solved. +I also tried to install MSI installer x32 and the problem was missing.",1.2,True,2,5797 +2018-11-04 18:53:52.133,AWS CLI upload failed: unknown encoding: idna,"I am trying to push some files up to s3 with the AWS CLI and I am running into an error: +upload failed: ... An HTTP Client raised and unhandled exception: unknown encoding: idna +I believe this is a Python specific problem but I am not sure how to enable this type of encoding for my python interpreter. I just freshly installed Python 3.6 and have verified that it being used by powershell and cmd. +$> python --version + Python 3.6.7 +If this isn't a Python specific problem, it might be helpful to know that I also just freshly installed the AWS CLI and have it properly configured. Let me know if there is anything else I am missing to help solve this problem. Thanks.","Even I was facing same issue. I was running it on Windows server 2008 R2. I was trying to upload around 500 files to s3 using below command. + +aws s3 cp sourcedir s3bucket --recursive --acl + bucket-owner-full-control --profile profilename + +It works well and uploads almost all files, but for initial 2 or 3 files, it used to fail with error: An HTTP Client raised and unhandled exception: unknown encoding: idna +This error was not consistent. The file for which upload failed, it might succeed if I try to run it again. It was quite weird. +Tried on trial and error basis and it started working well. +Solution: + +Uninstalled Python 3 and AWS CLI. +Installed Python 2.7.15 +Added python installed path in environment variable PATH. Also added pythoninstalledpath\scripts to PATH variable. +AWS CLI doesnt work well with MS Installer on Windows Server 2008, instead used PIP. + +Command: + +pip install awscli + +Note: for pip to work, do not forget to add pythoninstalledpath\scripts to PATH variable. +You should have following version: +Command: + +aws --version + +Output: aws-cli/1.16.72 Python/2.7.15 Windows/2008ServerR2 botocore/1.12.62 +Voila! The error is gone!",-0.1618299653758019,False,2,5797 +2018-11-05 10:20:35.477,Calling a Python function from HTML,"Im writing a webapplication, where im trying to display the connected USB devices. I found a Python function that does exactly what i want but i cant really figure out how to call the function from my HTML code, preferably on the click of a button.","simple answer: you can't. the code would have to be run client-side, and no browser would execute potentially malicious code automatically (and not every system has a python interpreter installed). +the only thing you can execute client-side (without the user taking action, e.g. downloading a program or browser add-on) is javascript.",1.2,True,1,5798 +2018-11-05 18:11:03.353,How to create Graphql server for microservices?,"We have several microservices on Golang and Python, On Golang we are writing finance operations and on Python online store logic, we want to create one API for our front-end and we don't know how to do it. +I have read about API gateway and would it be right if Golang will create its own GraphQL server, Python will create another one and they both will communicate with the third graphql server which will generate API for out front-end.","I do not know much details about your services, but great pattern I successfully used on different projects is as you mentioned GraphQL gateway. +You will create one service, I prefer to create it in Node.js where all requests from frontend will coming through. Then from GraphQL gateway you will request your microservices. This will be basically your only entry point into the backend system. Requests will be authenticated and you are able to unify access to your data and perform also some performance optimizations like implementing data loader's caching and batching to mitigate N+1 problem. In addition you will reduce complexity of having multiple APIs and leverage all the GraphQL benefits. +On my last project we had 7 different frontends and each was using the same GraphQL gateway and I was really happy with our approach. There are definitely some downsides as you need to keep in sync all your frontends and GraphQL gateway, therefore you need to be more aware of your breaking changes, but it is solvable with for example deprecated directive and by performing blue/green deployment with Kubernetes cluster. +The other option is to create the so-called backend for frontend in GraphQL. Right now I do not have enough information which solution would be best for you. You need to decide based on your frontend needs and business domain, but usually I prefer GraphQL gateway as GraphQL has great flexibility and the need to taylor your API to frontend is covered by GraphQL capabilities. Hope it helps David",1.2,True,1,5799 +2018-11-05 18:14:16.803,What should be the 5th dimension for the input to 3D-CNN while working with hyper-spectral images?,"I have a hyperspectral image having dimension S * S * L where S*S is the spatial size and L denotes the number of spectral bands. +Now the shape of my X (image array) is: (1, 145, 145, 200) where 1 is the number of examples, 145 is the length and width of the image and 200 is no. of channels of the image. +I want to input this small windows of this image (having dimension like W * W * L; W < S) into a 3D CNN, but for that, I need to have 5 dimensions in the following format: (batch, length, width, depth, channels). +It seems to me I am missing one of the spatial dimensions, how do I convert my image array into a 5-dimensional array without losing any information? +I am using python and Keras for the above.","What you want is a 2D CNN, not a 3D one. A 2D CNN already supports multiple channels, so you should have no problem using it with a hyperspectral image.",0.2012947653214861,False,2,5800 +2018-11-05 18:14:16.803,What should be the 5th dimension for the input to 3D-CNN while working with hyper-spectral images?,"I have a hyperspectral image having dimension S * S * L where S*S is the spatial size and L denotes the number of spectral bands. +Now the shape of my X (image array) is: (1, 145, 145, 200) where 1 is the number of examples, 145 is the length and width of the image and 200 is no. of channels of the image. +I want to input this small windows of this image (having dimension like W * W * L; W < S) into a 3D CNN, but for that, I need to have 5 dimensions in the following format: (batch, length, width, depth, channels). +It seems to me I am missing one of the spatial dimensions, how do I convert my image array into a 5-dimensional array without losing any information? +I am using python and Keras for the above.","If you want to convolve along the dimension of your channels, you should add a singleton dimension in the position of channel. If you don't want to convolve along the dimension of your channels, you should use a 2D CNN.",1.2,True,2,5800 +2018-11-06 05:41:57.087,Family tree in Python,"I need to model a four generational family tree starting with a couple. After that if I input a name of a person and a relation like 'brother' or 'sister' or 'parent' my code should output the person's brothers or sisters or parents. I have a fair bit of knowledge of python and self taught in DSA. I think I should model the data as a dictionary and code for a tree DS with two root nodes(i.e, the first couple). But I am not sure how to start. I just need to know how to start modelling the family tree and the direction of how to proceed to code. Thank you in advance!","There's plenty of ways to skin a cat, but I'd suggest to create: + +A Person class which holds relevant data about the individual (gender) and direct relationship data (parents, spouse, children). +A dictionary mapping names to Person elements. + +That should allow you to answer all of the necessary questions, and it's flexible enough to handle all kinds of family trees (including non-tree-shaped ones).",0.9999092042625952,False,1,5801 +2018-11-06 07:03:33.130,Tensorflow MixtureSameFamily and gaussian mixture model,"I am really new to Tensorflow as well as gaussian mixture model. +I have recently used tensorflow.contrib.distribution.MixtureSameFamily class for predicting probability density function which is derived from gaussian mixture of 4 components. +When I plotted the predicted density function using ""prob()"" function as Tensorflow tutorial explains, I found the plotted pdf with only one mode. I expected to see 4 modes as the mixture components are 4. +I would like to ask whether Tensorflow uses any global mode predicting algorithm in their MixtureSameFamily class. If not, I would also like to know how MixtureSameFamily class forms the pdf with statistical values. +Thank you very much.","I found an answer for above question thanks to my collegue. +The 4 components of gaussian mixture have had very similar means that the mixture seems like it has only one mode. +If I put four explicitly different values as means to the MixtureSameFamily class, I could get a plot of gaussian mixture with 4 different modes. +Thank you very much for reading this.",0.0,False,1,5802 +2018-11-07 04:43:09.720,How to run pylint plugin in Intellij IDEA?,"I have installed pylint plugin and restarted the Intellij IDEA. It is NOT external tool (so please avoid providing answers on running as an external tool as I know how to). +However I have no 'pylint' in the tool menu or the code menu. +Is it invoked by running 'Analyze'? or is there a way to run the pylint plugin on py files?","This is for the latest IntelliJ IDEA version 2018.3.5 (Community Edition): + +Type ""Command ,"" or click ""IntelliJ IDEA -> Preferences..."" +From the list on the left of the popped up window select ""Plugins"" +Make sure that on the right top the first tab ""Marketplace"" is picked if it's not +Search for ""Pylint"" and when the item is found, click the greed button ""Install"" associated with the found item + +The plugin should then be installed properly. +One can then turn on/off real-time Pylint scan via the same window by navigating in the list on the left: ""Editor -> Inspections"", then in the list on the right unfolding ""Pylint"" and finally checking/unchecking the corresponding checkbox on the right of the unfolded item. +One can also in the same window go the very last top-level item within the list on the left named ""Other Settings"" and unfold it. +Within it there's an item called ""Pylint"", click on it. +On the top right there should be a button ""Test"", click on it. +If in a few seconds to the left of the ""Test"" text there appears a green checkmark, then Pylint is installed correctly. +Finally, to access the actual Pylint window, click ""View""->""Tool Windows""->""Pylint""! +Enjoy!",0.9999092042625952,False,1,5803 +2018-11-08 02:59:54.810,nltk bags of words showing emotions,"i am working on NLP using python and nltk. +I was wondering whether is there any dataset which have bags of words which shows keywords relating to emotions such as happy, joy, anger, sadness and etc +from what i dug up in the nltk corpus, i see there are some sentiment analysis corpus which contain positive and negative review which doesn't exactly related to keywords showing emotions. +Is there anyway which i could build my own dictionary containing words which shows emotion for this purpose? is so, how do i do it and is there any collection of such words? +Any help would be greatly appreciated","I'm not aware of any dataset that associates sentiments to keywords, but you can easily built one starting from a generic sentiment analysis dataset. +1) Clean the datasets from the stopwords and all the terms that you don't want to associate to a sentiment. +2)Compute the count of each words in the two sentiment classes and normalize it. In this way you will associate a probability to each word to belong to a class. Let's suppose that you have 300 times the word ""love"" appearing in the positive sentences and the same word appearing 150 times in the negative sentences. Normalizing you have that the word ""love"" belongs with a probability of 66% (300/(150+300)) to the positive class and 33% to the negative one. +3) In order to make the dictionary more robust to the borderline terms you can set a threshold to consider neutral all the words with the max probability lower than the threshold. +This is an easy approach to build the dictionary that you are looking for. You could use more sophisticated approach as Term Frequency-Inverse Document Frequency.",0.0,False,1,5804 +2018-11-09 01:48:39.963,Operating the Celery Worker in the ECS Fargate,"I am working on a project using AWS ECS. I want to use Celery as a distributed task queue. Celery Worker can be build up as EC2 type, but because of the large amount of time that the instance is in the idle state, I think it would be cost-effective for AWS Fargate to run the job and quit immediately. +Do you have suggestions on how to use the Celery Worker efficiently in the AWS cloud?","Fargate launch type is going to take longer to spin up than EC2 launch type, because AWS is doing all the ""host things"" for you when you start the task, including the notoriously slow attaching of an ENI, and likely downloading the image from a Docker repo. Right now there's no contest, EC2 launch type is faster every time. +So it really depends on the type of work you want the workers to do. You can expect a new Fargate task to take a few minutes to enter a RUNNING state for the aforementioned reasons. EC2 launch, on the other hand, because the ENI is already in place on your host and the image is already downloaded (at best) or mostly downloaded (likely worst), will move from PENDING to RUNNING very quickly. + +Use EC2 launch type for steady workloads, use Fargate launch type for burst capacity +This is the current prevailing wisdom, often discussed as a cost factor because Fargate can't take advantage of the typical EC2 cost savings mechanisms like reserved instances and spot pricing. It's expensive to run Fargate all the time, compared to EC2. +To be clear, it's perfectly fine to run 100% in Fargate (we do), but you have to be willing to accept the downsides of doing that - slower scaling and cost. +Note you can run both launch types in the same cluster. Clusters are logical anyway, just a way to organize your resources. + +Example cluster +This example shows a static EC2 launch type service running 4 celery tasks. The number of tasks, specs, instance size and all doesn't really matter, do it up however you like. The important thing is - EC2 launch type service doesn't need to scale; the Fargate launch type service is able to scale from nothing running (during periods where there's little or no work to do) to as many workers as you can handle, based on your scaling rules. +EC2 launch type Celery service +Running 1 EC2 launch type t3.medium (2vcpu/4GB). +Min tasks: 2, Desired: 4, Max tasks: 4 +Running 4 celery tasks at 512/1024 in this EC2 launch type. +No scaling policies +Fargate launch type Celery service +Min tasks: 0, Desired: (x), Max tasks: 32 +Running (x) celery tasks (same task def as EC2 launch type) at 512/1024 +Add scaling policies to this service",1.2,True,1,5805 +2018-11-09 07:20:23.930,how do I insert some rows that I select from remote MySQL database to my local MySQL database,"My remote MySQL database and local MySQL database have the same table structure, and the remote and local MySQL database is utf-8charset.","You'd better merge value and sql template string and print it , make sure the sql is correct.",0.0,False,1,5806 +2018-11-09 16:42:21.617,Run external Python script that could only read/write only a subset of main app variables,"I have a Python application that simulates the behaviour of a system, let's say a car. +The application defines a quite large set of variables, some corresponding to real world parameters (the remaining fuel volume, the car speed, etc.) and others related to the simulator internal mechanics which are of no interest to the user. +Everything works fine, but currently the user can have no interaction with the simulation whatsoever during its execution: she just sets simulation parameters, lauchs the simulation, and waits for its termination. +I'd like the user (i.e. not the creator of the application) to be able to write Python scripts, outside of the app, that could read/write the variables associated with the real world parameters (and only these variables). +For instance, at t=23s (this condition I know how to check for), I'd like to execute user script gasLeak.py, that reads the remaining fuel value and sets it to half its current value. +To sum up, how is it possible, from a Python main app, to execute user-written Python scripts that can access and modifiy only a pre-defined subset of the main script variables. In a perfect world, I'd also like that modifications applied to user scripts during the running of the app to be taken into account without having to restart said app (something along the reloading of a module).",Make the user-written scripts read command-line arguments and print to stdout. Then you can call them with the subprocess module with the variables they need to know about as arguments and read their responses with subprocess.check_output.,0.0,False,1,5807 +2018-11-09 23:03:45.930,pytest-xdist generate random & uniqe ports for each test,"I'm using pytest-xdist plugin to run some test using the @pytest.mark.parametrize to run the same test with different parameters. +As part of these tests, I need to open/close web servers and the ports are generated at collection time. +xdist does the test collection on the slave and they are not synchronised, so how can I guarantee uniqueness for the port generation. +I can use the same port for each slave but I don't know how to archive this.","I figured that I did not give enough information regarding my issue. +What I did was to create one parameterized test using @pytest.mark.parametrize and before the test, I collect the list of parameters, the collection query a web server and receive a list of ""jobs"" to process. +Each test contains information on a port that he needs to bind to, do some work and exit because the tests are running in parallel I need to make sure that the ports will be different. +Eventually, I make sure that the job ids will be in the rand on 1024-65000 and used that for the port.",1.2,True,1,5808 +2018-11-10 23:45:59.803,how to detect if photo is mostly a document?,I think i am looking for something simpler than detecting a document boundaries in a photo. I am only trying to flag photos which are mostly of documents rather than just a normal scene photo. is this an easier problem to solve?,"Are the documents mostly white? If so, you could analyse the images for white content above a certain percentage. Generally text documents only have about 10% printed content on them in total.",0.0,False,1,5809 +2018-11-11 14:15:01.157,"Sending data to Django backend from RaspberryPi Sensor (frequency, bulk-update, robustness)","I’m currently working on a Raspberry Pi/Django project slightly more complex that i’m used to. (i either do local raspberry pi projects, or simple Django websites; never the two combined!) +The idea is two have two Raspberry Pi’s collecting information running a local Python script, that would each take input from one HDMI feed (i’ve got all that part figured out - I THINK) using image processing. Now i want these two Raspberry Pi’s (that don’t talk to each other) to connect to a backend server that would combine, store (and process) the information gathered by my two Pis +I’m expecting each Pi to be working on one frame per second, comparing it to the frame a second earlier (only a few different things he is looking out for) isolate any new event, and send it to the server. I’m therefore expecting no more than a dozen binary timestamped data points per second. +Now what is the smart way to do it here ? + +Do i make contact to the backend every second? Every 10 seconds? +How do i make these bulk HttpRequests ? Through a POST request? Through a simple text file that i send for the Django backend to process? (i have found some info about “bulk updates” for django but i’m not sure that covers it entirely) +How do i make it robust? How do i make sure that all data what successfully transmitted before deleting the log locally ? (if one call fails for a reason, or gets delayed, how do i make sure that the next one compensates for lost info? + +Basically, i’m asking advise for making a IOT based project, where a sensor gathers bulk information and want to send it to a backend server for processing, and how should that archiving process be designed. +PS: i expect the image processing part (at one fps) to be fast enough on my Pi Zero (as it is VERY simple); backlog at that level shouldn’t be an issue. +PPS: i’m using a django backend (even if it seems a little overkill) + a/ because i already know the framework pretty well + b/ because i’m expecting to build real-time performance indicators from the combined data points gathered, using django, and displaying them in (almost) real-time on a webpage. +Thank you very much !","This partly depends on just how resilient you need it to be. If you really can't afford for a single update to be lost, I would consider using a message queue such as RabbitMQ - the clients would add things directly to the queue and the server would pop them off in turn, with no need to involve HTTP requests at all. +Otherwise it would be much simpler to just POST each frame's data in some serialized format (ie JSON) and Django would simply deserialize and iterate through the list, saving each entry to the db. This should be fast enough for the rate you describe - I'd expect saving a dozen db entries to take significantly less than half a second - but this still leaves the problem of what to do if things get hung up for some reason. Setting a super-short timeout on the server will help, as would keeping the data to be posted until you have confirmation that it has been saved - and creating unique IDs in the client to ensure that the request is idempotent.",0.6730655149877884,False,1,5810 +2018-11-12 08:56:25.160,run python from Microsoft Dynamics,"I know i can access a Dynamics instance from a python script by using the oData API, but what about the other way around? Is it possible to somehow call a python script from within Dynamics and possible even pass arguments? +Would this require me to use custom js/c#/other code within Dynamics?","You won't be able to nativley execute a python script within Dynamics. +I would approach this by placing the Python script in a service that can be called via a web service call from Dynamics. You could make the call from form JavaScript or a Plugin using C#.",1.2,True,1,5811 +2018-11-12 20:04:05.643,Extracting URL from inside docx tables,"I'm pretty much stuck right now. +I wrote a parser in python3 using the python-docx library to extract all tables found in an existing .docx and store it in a python datastructure. +So far so good. Works as it should. +Now I have the problem that there are hyperlinks in these tables which I definitely need! Due to the structure (xml underneath) the docx library doesn't catch these. Neither the url nor the display text provided. I found many people having similar concerns about this, but most didn't seem to have 'just that' dilemma. +I thought about unpacking the .docx and scan the _ref document for the corresponding 'rid' and fill the actual data I have with the links found in the _ref xml. +Either way it seems seriously weary to do it that way, so I was wondering if there is a more pythonic way to do it or if somebody got good advise how to tackle this problem?","You can extract the links by parsing xml of docx file. +You can extract all text from the document by using document.element.getiterator() +Iterate all the tags of xml and extract its text. You will get all the missing data which python-docx failed to extract.",0.0,False,1,5812 +2018-11-12 23:39:45.557,"openpyxl how to read formula result after editing input data on the sheet? data_only=True gives me a ""None"" result","Using openpyxl, I'm able to read 2 numbers on a sheet, and also able to read their sum by loading the sheet with data_only=True. +However, when I alter the 2 numbers using openpyxl and then try to read the answer using data_only=True, it returns no output. How do I do this?",You can have either the value or the formula in openpyxl. It is precisely to avoid the confusion that this kind of edit could introduce that the library works like this. To evaluate the changed formulae you'll need to load the file in an app like MS Excel or LibreOffice that can evaluate the formulae and store the results.,0.1352210990936997,False,1,5813 +2018-11-13 01:35:08.450,inception v3 using tf.data?,"I'm using a bit of code that is derived from inception v3 as distributed by the Google folks, but it's now complaining that the queue runners used to read the data are deprecated (tf.train.string_input_producer in image_processing.py, and similar). Apparently I'm supposed to switch to tf.data for this kind of stuff. +Unfortunately, the documentation on tf.data isn't doing much to relieve my concern that I've got too much data to fit in memory, especially given that I want to batch it in a reusable way, etc. I'm confident that the tf.data stuff can do this; I just don't know how to do it. Can anyone point me to a full example of code that uses tf.data to deal with batches of data that won't all fit in memory? Ideally, it would simply be an updated version of the inception-v3 code, but I'd be happy to try and work with anything. Thanks!","Well, I eventually got this working. The various documents referenced in the comment on my question had what I needed, and I gradually figured out which parameters passed to queuerunners corresponded to which parameters in the tf.data stuff. +There was one gotcha that took a while for me to sort out. In the inception implementation, the number of examples used for validation is rounded up to be a multiple of the batch size; presumably the validation set is reshuffled and some examples are used more than once. (This does not strike me as great practice, but generally the number of validation instances is way larger than the batch size, so only a relative few are double counted.) +In the tf.data stuff, enabling shuffling and reuse is a separate thing and I didn't do it on the validation data. Then things broke because there weren't enough unique validation instances, and I had to track that down. +I hope this helps the next person with this issue. Unfortunately, my code has drifted quite far from Inception v3 and I doubt that it would be helpful for me to post my modification. Thanks!",0.3869120172231254,False,1,5814 +2018-11-13 20:39:25.877,how to reformat a text paragrath using python,"Hi I was wondering how I could format a large text file by adding line breaks after certain characters or words. For instance, everytime a comma was in the paragraph could I use python to make this output an extra linebreak.","you can use the ''.replace() method like so: +'roses can be blue, red, white'.replace(',' , ',\n') gives +'roses can be blue,\n red,\n white' efectively inserting '\n' after every ,",0.0,False,1,5815 +2018-11-14 23:48:25.957,Python detecting different extensions on files,"How do i make python listen for changes to a folder on my desktop, and every time a file was added, the program would read the file name and categorize it it based on the extension? +This is a part of a more detailed program but I don't know how to get started on this part. This part of the program detects when the user drags a file into a folder on his/her desktop and then moves that file to a different location based on the file extension.","Periodically read the files in the folder and compare to a set of files remaining after the last execution of your script. Use os.listdir() and isfile(). +Read the extension of new files and copy them to a directory based on internal rules. This is a simple string slice, e.g., filename[-3:] for 3-character extensions. +Remove moved files from your set of last results. Use os.rename() or shutil.move(). +Sleep until next execution is scheduled.",1.2,True,1,5816 +2018-11-15 02:12:27.683,How do I configure settings for my Python Flask app on GoDaddy,"This app is working fine on heroku but how do i configure it on godaddy using custom domain. +When i navigate to custom domain, it redirects to mcc.godaddy.com. +What all settings need to be changed.","The solution is to add a correct CNAME record and wait till the value you entered has propagated. +Go to DNS management and make following changes: +In the 'Host' field enter 'www' and in 'Points to' field add 'yourappname.herokuapp.com'",0.0,False,1,5817 +2018-11-15 03:51:30.570,Compare stock indices of different sizes Python,"I am using Python to try and do some macroeconomic analysis of different stock markets. I was wondering about how to properly compare indices of varying sizes. For instance, the Dow Jones is around 25,000 on the y-axis, while the Russel 2000 is only around 1,500. I know that the website tradingview makes it possible to compare these two in their online charter. What it does is shrink/enlarge a background chart so that it matches the other on a new y-axis. Is there some statistical method where I can do this same thing in Python?","I know that the website tradingview makes it possible to compare these two in their online charter. What it does is shrink/enlarge a background chart so that it matches the other on a new y-axis. + +These websites rescale them by fixing the initial starting points for both indices at, say, 100. I.e. if Dow is 25000 points and S&P is 2500, then Dow is divided by 250 to get to 100 initially and S&P by 25. Then you have two indices that start at 100 and you then can compare them side by side. +The other method (works good only if you have two series) - is to set y-axis on the right hand side for one series, and on the left hand side for the other one.",1.2,True,1,5818 +2018-11-15 06:53:57.707,How to convert 2D matrix to 3D tensor without blending corresponding entries?,"I have data with the shape of (3000, 4), the features are (product, store, week, quantity). Quantity is the target. +So I want to reconstruct this matrix to a tensor, without blending the corresponding quantities. +For example, if there are 30 product, 20 stores and 5 weeks, the shape of the tensor should be (5, 20, 30), with the corresponding quantity. Because there won't be an entry like (store A, product X, week 3) twice in entire data, so every store x product x week pair should have one corresponding quantity. +Any suggestions about how to achieve this, or there is any logical error? Thanks.","You can first go through each of your first three columns and count the number of different products, stores and weeks that you have. This will give you the shape of your new array, which you can create using numpy. Importantly now, you need to create a conversion matrix for each category. For example, if product is 'XXX', then you want to know to which row of the first dimension (as product is the first dimension of your array) 'XXX' corresponds; same idea for store and week. Once you have all of this, you can simply iterate through all lines of your existing array and assign the value of quantity to the correct location inside your new array based on the indices stored in your conversion matrices for each value of product, store and week. As you said, it makes sense because there is a one-to-one correspondence.",0.0,False,1,5819 +2018-11-15 11:02:06.533,Installing packages to Anaconda Environments,"I've been having an issue with Anaconda, on two separate Windows machines. +I've downloaded and installed Anaconda. I know the commands, how to install libraries, I've even installed tensorflow-gpu (which works). I also use Jupyter notebook and I'm quite familiar with it by this point. +The issue: +For some reason, when I create new environments and install libraries to that environment... it ALWAYS installs them to (base). Whenever I try to run code in a jupyter notebook that is located in an environment other than (base), it can't find any of the libraries I need... because it's installing them to (base) by default. +I always ensure that I've activated the correct environment before installing any libraries. But it doesn't seem to make a difference. +Can anyone help me with this... am I doing something wrong?","Kind of fixed my problem. It is to do with launching Jupyter notebook. +After switching environment via command prompt... the command 'jupyter notebook' runs jupyter notebook via the default python environment, regardless. +However, if I switch environments via anaconda navigator and launch jupyter notebook from there, it works perfectly. +Maybe I'm missing a command via the prompt?",1.2,True,1,5820 +2018-11-15 11:25:13.747,How Do I store downloaded pdf files to Mongo DB,"I download the some of pdf and stored in directory. Need to insert them into mongo database with python code so how could i do these. Need to store them by making three columns (pdf_name, pdf_ganerateDate, FlagOfWork)like that.","You can use GridFS. Please check this url http://api.mongodb.com/python/current/examples/gridfs.html. +It will help you to store any file to mongoDb and get them. In other collection you can save file metadata.",0.3869120172231254,False,1,5821 +2018-11-15 15:28:09.797,how to use pipenv to run file in current folder,"Using pipenv to create a virtual environment in a folder. +However, the environment seems to be in the path: + +/Users/....../.local/share/virtualenvs/...... + +And when I run the command pipenv run python train.py, I get the error: + +can't open file 'train.py': [Errno 2] No such file or directory + +How to run a file in the folder where I created the virtual environment?","You need to be in the same directory of the file you want to run then use: +pipenv run python train.py +Note: + +You may be at the project main directory while the file you need to run is inside a directory inside your project directory +If you use django to create your project, it will create two folders inside each other with the same name so as a best practice change the top directory name to 'yourname-project' then inside the directory 'yourname' run the pipenv run python train.py command",1.2,True,1,5822 +2018-11-15 20:21:37.897,xgboost feature importance of categorical variable,"I am using XGBClassifier to train in python and there are a handful of categorical variables in my training dataset. Originally, I planed to convert each of them into a few dummies before I throw in my data, but then the feature importance will be calculated for each dummy, not the original categorical ones. Since I also need to order all of my original variables (including numerical + categorical) by importance, I am wondering how to get importance of my original variables? Is it simply adding up?","You could probably get by with summing the individual categories' importances into their original, parent category. But, unless these features are high-cardinality, my two cents would be to report them individually. I tend to err on the side of being more explicit with reporting model performance/importance measures.",0.0,False,1,5823 +2018-11-15 20:22:49.817,How to run a briefly running Docker container on Azure on a daily basis?,"In the past, I've been using WebJobs to schedule small recurrent tasks that perform a specific background task, e.g., generating a daily summary of user activities. For each task, I've written a console application in C# that was published as an Azure Webjob. +Now I'd like to daily execute some Python code that is already working in a Docker container. I think I figured out how to get a container running in Azure. Right now, I want to minimize the operation cost since the container will only run for a duration of 5 minutes. Therefore, I'd like to somehow schedule that my container starts once per day (at 1am) and shuts down after completion. How can I achieve this setup in Azure?",I'd probably write a scheduled build job on vsts\whatever to run at 1am daily to launch a container on Azure Container Instances. Container should shutdown on its own when the program exists (so your program has to do that without help from outside).,1.2,True,1,5824 +2018-11-16 16:47:57.803,MongoDB - how can i set a documents limit to my capped collection?,"I'm fairly new to MongoDB. I need my Python script to query new entries from my Database in real time, but the only way to do this seems to be replica sets, but my Database is not a replica set, or with a Tailable cursor, which is only for capped collections. +From what i understood, a capped collection has a limit, but since i don't know how big my Database is gonna be and for when i'm gonna need to send data there, i am thinking of putting the limit to 3-4 million documents. Would this be possible?. +How can i do that?.","so do you want to increase the size of capped collection ? +if yes then if you know average document size then you may define size like: +db.createCollection(""sample"", { capped : true, size : 10000000, max : 5000000 } ) here 5000000 is max documents with size limit of 10000000 bytes",0.3869120172231254,False,1,5825 +2018-11-17 02:57:21.293,Import aar of Android library in Python,"I have wrote an Android library and build an aar file. And I want to write a python program to use the aar library. Is it possible to do that? If so, how to do that? Thanks",There is no way to include all dependencies to your aar file. So According to the open source licenses you can add their sources to your project.,0.0,False,1,5826 +2018-11-17 12:15:24.270,GraphQL/Graphene for backend calls in Django's templates,"I just installed Graphene on my Django project and would like to use it also for the back-end, templating. So far, I find just tutorials how to use it only for front-end, no mention about back-end. + +Should I suppose that it is not a good idea to use it instead of a SQL database? If yes, then why? Is there a downside in the speed in the comparison to a SQL databases like MySQL? +What's the best option how to retrieve the data for templates in Python? I mean, best for the performance. + +Thnx.","GraphQL is an API specification. It doesn't specify how data is stored, so it is not a replacement for a database. +If you're using GraphQL, you don't use Django templates to specify the GraphQL output, because GraphQL specifies the entire HTTP response from the web service, so this question doesn't make sense.",0.6730655149877884,False,1,5827 +2018-11-17 18:20:40.807,How to use F-score as error function to train neural networks?,"I am pretty new to neural networks. I am training a network in tensorflow, but the number of positive examples is much much less than negative examples in my dataset (it is a medical dataset). +So, I know that F-score calculated from precision and recall is a good measure of how well the model is trained. +I have used error functions like cross-entropy loss or MSE before, but they are all based on accuracy calculation (if I am not wrong). But how do I use this F-score as an error function? Is there a tensorflow function for that? Or I have to create a new one? +Thanks in advance.","the loss value and accuracy is a different concept. The loss value is used for training the NN. However, accuracy or other metrics is to value the training result.",0.0,False,1,5828 +2018-11-17 20:57:16.567,How to determine file path in Google colab?,"I mounted my drive using this : +from google.colab import drive +drive.mount('/content/drive/') +I have a file inside a folder that I want the path of how do I determine the path? +Say the folder that contains the file is named 'x' inside my drive",The path will be /content/drive/My\ Drive/x/the_file.,1.2,True,2,5829 +2018-11-17 20:57:16.567,How to determine file path in Google colab?,"I mounted my drive using this : +from google.colab import drive +drive.mount('/content/drive/') +I have a file inside a folder that I want the path of how do I determine the path? +Say the folder that contains the file is named 'x' inside my drive","The path as parameter for a function will be /content/drive/My Drive/x/the_file, so without backslash inside My Drive",0.5457054096481145,False,2,5829 +2018-11-17 23:12:26.597,virtualenv - Birds Eye View of Understanding,"Using Windows +Learning about virtualenv. Here is my understanding of it and a few question that I have. Please correct me if my understanding is incorrect. +virtualenv are environments where your pip dependencies and its selected version are stored for a particular project. A folder is made for your project and inside there are the dependencies. + +I was told you would not want to save your .py scripts in side of virtual ENV, if that's the case how do I access the virtual env when I want to run that project? Open it up in the command line under source ENV/bin/activate then cd my way to where my script is stored? +By running pip freeze that creates a requirements.txt file in that project folder that is just a txt. copy of the dependencies of that virtual env? +If I'm in a second virutalenv who do I import another virtualenv's requirements? I've been to the documentation but I still don't get it. +$ env1/bin/pip freeze > requirements.txt +$ env2/bin/pip install -r requirements.txt + +Guess I'm confused on the ""requirements"" description. Isn't best practice to always call our requirements, requirements.txt? If that's the case how does env2 know I'm want env1 requirements? +Thank you for any info or suggestions. Really appreciate the assistance. +I created a virtualenv C:\Users\admin\Documents\Enviorments>virtualenv django_1 +Using base prefix'c:\\users\\admin\\appdata\\local\\programs\\python\\python37-32' +New python executable in C:\Users\admin\Documents\Enviorments\django_1\Scripts\python.exe Installing setuptools, pip, wheel...done. +How do I activate it? source django_1/bin/activate doesn't work? +I've tried: source C:\Users\admin\Documents\Enviorments\django_1/bin/activate Every time I get : 'source' is not recognized as an internal or external command, operable program or batch file.","virtualenv simply creates a new Python environment for your project. Think of it as another copy of Python that you have in your system. Virutual environment is helpful for development, especially if you will need different versions of the same libraries. +Answer to your first question is, yes, for each project that you use virtualenv, you need to activate it first. After activating, when you run python script, not just your project's scripts, but any python script, will use dependencies and configuration of the active Python environment. +Answer to the second question, pip freeze > requirements.txt will create requirements file in active folder, not in your project folder. So, let's say in your cmd/terminal you are in C:\Desktop, then the requirements file will be created there. If you're in C\Desktop\myproject folder, the file will be created there. Requirements file will contain the packages installed on active virtualenv. +Answer to 3rd question is related to second. Simply, you need to write full path of the second requirements file. So if you are in first project and want to install packages from second virtualenv, you run it like env2/bin/pip install -r /path/to/my/first/requirements.txt. If in your terminal you are in active folder that does not have requirements.txt file, then running pip install will give you an error. So, running the command does not know which requirements file you want to use, you specify it. +I created a virtualenv +C:\Users\admin\Documents\Enviorments>virtualenv django_1 Using base prefix 'c:\\users\\admin\\appdata\\local\\programs\\python\\python37-32' New python executable in C:\Users\admin\Documents\Enviorments\django_1\Scripts\python.exe Installing setuptools, pip, wheel...done. +How do I activate it? source django_1/bin/activate doesn't work? +I've tried: source C:\Users\admin\Documents\Enviorments\django_1/bin/activate Every time I get : 'source' is not recognized as an internal or external command, operable program or batch file.",0.0,False,2,5830 +2018-11-17 23:12:26.597,virtualenv - Birds Eye View of Understanding,"Using Windows +Learning about virtualenv. Here is my understanding of it and a few question that I have. Please correct me if my understanding is incorrect. +virtualenv are environments where your pip dependencies and its selected version are stored for a particular project. A folder is made for your project and inside there are the dependencies. + +I was told you would not want to save your .py scripts in side of virtual ENV, if that's the case how do I access the virtual env when I want to run that project? Open it up in the command line under source ENV/bin/activate then cd my way to where my script is stored? +By running pip freeze that creates a requirements.txt file in that project folder that is just a txt. copy of the dependencies of that virtual env? +If I'm in a second virutalenv who do I import another virtualenv's requirements? I've been to the documentation but I still don't get it. +$ env1/bin/pip freeze > requirements.txt +$ env2/bin/pip install -r requirements.txt + +Guess I'm confused on the ""requirements"" description. Isn't best practice to always call our requirements, requirements.txt? If that's the case how does env2 know I'm want env1 requirements? +Thank you for any info or suggestions. Really appreciate the assistance. +I created a virtualenv C:\Users\admin\Documents\Enviorments>virtualenv django_1 +Using base prefix'c:\\users\\admin\\appdata\\local\\programs\\python\\python37-32' +New python executable in C:\Users\admin\Documents\Enviorments\django_1\Scripts\python.exe Installing setuptools, pip, wheel...done. +How do I activate it? source django_1/bin/activate doesn't work? +I've tried: source C:\Users\admin\Documents\Enviorments\django_1/bin/activate Every time I get : 'source' is not recognized as an internal or external command, operable program or batch file.","* disclaimer * I mainly use conda environments instead of virtualenv, but I believe that most of this is the same across both of them and is true to your case. + +You should be able to access your scripts from any environment you are in. If you have virtenvA and virtenvB then you can access your script from inside either of your environments. All you would do is activate one of them and then run python /path/to/my/script.py, but you need to make sure any dependent libraries are installed. +Correct, but for clarity the requirements file contains a list of the dependencies by name only. It doesn't contain any actual code or packages. You can print out a requirements file but it should just be a list which says package names and their version numbers. Like pandas 1.0.1 numpy 1.0.1 scipy 1.0.1 etc. +In the lines of code you have here you would export the dependencies list of env1 and then you would install these dependencies in env2. If env2 was empty then it will now just be a copy of env1, otherwise it will be the same but with all the packages of env1 added and if it had a different version number of some of the same packages then this would be overwritten",0.0,False,2,5830 +2018-11-19 08:19:34.017,How do I efficiently understand a framework with sparse documentation?,"I have the problem that for a project I need to work with a framework (Python), that has a poor documentation. I know what it does since it is the back end of a running application. I also know that no framework is good if the documentation is bad and that I should prob. code it myself. But, I have a time constraint. Therefore my question is: Is there a cooking recipe on how to understand a poorly documented framework? +What I tried until now is checking some functions and identify the organizational units in the framework but I am lacking a system to do it more effectively.","If I were you, with time constaraints, and bound to use a specific framework. I'll go in the following manner: + +List down the use cases I desire to implement using the framework +Identify the APIs provided by the framework that helps me implement the use cases +Prototype the usecases based on the available documentation and reading + +The prototyping is not implementing the entire use case, but to identify the building blocks around the case and implementing them. e.g., If my usecase is to fetch the Students, along with their courses, and if I were using Hibernate to implement, I would prototype the database accesss, validating how easily am I able to access the database using Hibernate, or how easily I am able to get the relational data by means of joining/aggregation etc. +The prototyping will help me figure out the possible limitations/bugs in the framework. If the limitations are more of show-stoppers, I will implement the supporting APIs myself; or I can take a call to scrap out the entire framework and write one for myself; whichever makes more sense.",0.3869120172231254,False,1,5831 +2018-11-20 02:45:03.200,Python concurrent.futures.ThreadPoolExecutor max_workers,"I am searching for a long time on net. But no use. Please help or try to give me some ideas how to achieve this. +When I use python module concurrent.futures.ThreadPoolExecutor(max_workers=None), I want to know the max_workers how much the number of suitable. +I've read the official document. +I still don't know the number of suitable when I coding. + +Changed in version 3.5: If max_worker is None or not give, it will default to the number of processors on the machine, multiplied by 5, assuming that ThreadPoolExecutor is often used to overlap I/O instead of CPU work and the number of workers should be higher than the number of workers for ProcessPoolExecutor. + +How to understand ""max_workers"" better? +For the first time to ask questions, thank you very much.","max_worker, you can take it as threads number. +If you want to make the best of CPUs, you should keep it running (instead of sleeping). +Ideally if you set it to None, there will be ( CPU number * 5) threads at most. On average, each CPU has 5 thread to schedule. Then if one of them falls into sleep, another thread will be scheduled.",0.9999092042625952,False,1,5832 +2018-11-20 20:23:47.973,wget with subprocess.call(),"I'm working on a domain fronting project. Basically I'm trying to use the subprocess.call() function to interpret the following command: +wget -O - https://fronteddomain.example --header 'Host: targetdomain.example' +With the proper domains, I know how to domain front, that is not the problem. Just need some help with writing using the python subprocess.call() function with wget.","I figured it out using curl: +call([""curl"", ""-s"", ""-H"" ""Host: targetdomain.example"", ""-H"", ""Connection: close"", ""frontdomain.example""])",1.2,True,1,5833 +2018-11-20 23:58:45.450,How to install Poppler to be used on AWS Lambda,"I have to run pdf2image on my Python Lambda Function in AWS, but it requires poppler and poppler-utils to be installed on the machine. +I have tried to search in many different places how to do that but could not find anything or anyone that have done that using lambda functions. +Would any of you know how to generate poppler binaries, put it on my Lambda package and tell Lambda to use that? +Thank you all.","Hi @Alex Albracht thanks for compiled easy instructions! They helped a lot. But I really struggled with getting the lambda function find the poppler path. So, I'll try to add that up with an effort to make it clear. +The binary files should go in a zip folder having structure as: +poppler.zip -> bin/poppler +where poppler folder contains the binary files. This zip folder can be then uploaded as a layer in AWS lambda. +For pdf2image to work, it needs poppler path. This should be included in the lambda function in the format - ""/opt/bin/poppler"". +For example, +poppler_path = ""/opt/bin/poppler"" +pages = convert_from_path(PDF_file, 500, poppler_path=poppler_path)",0.0,False,1,5834 +2018-11-21 13:30:25.713,"CPLEX Error 1016: Promotional version , use academic version CPLEX","I am using python with clpex, when I finished my model I run the program and it throws me the following error: +CplexSolverError: CPLEX Error 1016: Promotional version. Problem size limits exceeded. +I have the IBM Academic CPLEX installed, how can I make python recognize this and not the promotional version?","you can go to the direction you install CPLEX. For Example, D:\Cplex +After that you will see a foler name cplex, then you click on that, --> python --> choose the version of your python ( Ex: 3.6 ), then choose the folder x64_win64, you will see another file name cplex. +You copy this file into your python site packakges ^^ and then you will not be restricted",1.2,True,1,5835 +2018-11-23 22:49:20.307,How can i create a persistent data chart with Flask and Javascript?,"I want to add a real-time chart to my Flask webapp. This chart, other than current updated data, should contain historical data too. +At the moment i can create the chart and i can make it real time but i have no idea how to make the data 'persistent', so i can't see what the chart looked like days or weeks ago. +I'm using a Javascript charting library, while Data is being sent from my Flask script, but what it's not really clear is how i can ""store"" my data on Javascript. At the moment, indeed, the chart will reset each time the page is loaded. +How would it be possible to accomplish that? Is there an example for it?","You can try to store the data in a database and or in a file and extract from there . +You can also try to use dash or you can make on the right side a menu with dates like 21 september and see the chart from that day . +For dash you can look on YouTube at Sentdex",0.0,False,1,5836 +2018-11-25 13:55:55.643,How do I count how many items are in a specific row in my RDD,"as you can tell I’m fairly new to using Pyspark Python my RDD is set out as follows: +(ID, First name, Last name, Address) +(ID, First name, Last name, Address) +(ID, First name, Last name, Address) +(ID, First name, Last name, Address) +(ID, First name, Last name, Address) + Is there anyway I can count how many of these records I have stored within my RDD such as count all the IDs in the RDD. So that the output would tell me I have 5 of them. +I have tried using RDD.count() but that just seems to return how many items I have in my dataset in total.","If you have RDD of tuples like RDD[(ID, First name, Last name, Address)] then you can perform below operation to do different types of counting. + +Count the total number of elements/Rows in your RDD. +rdd.count() +Count Distinct IDs from your above RDD. Select the ID element and then do a distinct on top of it. +rdd.map(lambda x : x[0]).distinct().count() + +Hope it helps to do the different sort of counting. +Let me know if you need any further help here. +Regards, +Neeraj",0.0,False,1,5837 +2018-11-25 19:22:29.680,Adding charts to a Flask webapp,"I created a web app with Flask where I'll be showing data, so I need charts for it. +The problem is that I don't really know how to do that, so I'm trying to find the best way to do that. I tried to use a Javascript charting library on my frontend and send the data to the chart using SocketIO, but the problem is that I need to send that data frequently and at a certain point I'll be having a lot of data, so sending each time a huge load of data through AJAX/SocketIO would not be the best thing to do. +To solve this, I had this idea: could I generate the chart from my backend, instead of sending data to the frontend? I think it would be the better thing to do, since I won't have to send the data to the frontend each time and there won't be a need to generate a ton of data each time the page is loaded, since the chart will be processed on the frontend. +So would it be possible to generate a chart from my Flask code in Python and visualize it on my webpage? Is there a good library do that?",Try to use dash is a python library for web charts,1.2,True,1,5838 +2018-11-25 22:35:57.257,How to strip off left side of binary number in Python?,"I got this binary number 101111111111000 +I need to strip off the 8 most significant bits and have 11111000 at the end. +I tried to make 101111111111000 << 8, but this results in 10111111111100000000000, it hasn't the same effect as >> which strips the lower bits. So how can this be done? The final result MUST BE binary type.","To achieve this for a number x with n digits, one can use this +x&(2**(len(bin(x))-2-8)-1) +-2 to strip 0b, -8 to strip leftmost +Simply said it ands your number with just enough 1s that the 8 leftmost bits are set to 0.",0.0,False,1,5839 +2018-11-26 06:17:56.463,how do I clear a printed line and replace it with updated variable IDLE,"I need to clear a printed line, but so far I have found no good answers for using python 3.7, IDLE on windows 10. I am trying to make a simple code that prints a changing variable. But I don't want tons of new lines being printed. I want to try and get it all on one line. +Is it possible to print a variable that has been updated later on in the code? +Do remember I am doing this in IDLE, not kali or something like that. +Thanks for all your help in advance.","The Python language definition defines when bytes will be sent to a file, such as sys.stdout, the default file for print. It does not define what the connected device does with the bytes. +When running code from IDLE, sys.stdout is initially connected to IDLE's Shell window. Shell is not a terminal and does not interpret terminal control codes other than '\n'. The reasons are a) IDLE is aimed at program development, by programmers, rather than program running by users, and developers sometimes need to see all the output from a program; and b) IDLE is cross-platform, while terminal behaviors are various, depending on the system, settings, and current modes (such as insert versus overwrite). +However, I am planning to add an option to run code in an IDLE editor with sys.stdout directed to the local system terminal/console.",0.3869120172231254,False,1,5840 +2018-11-27 09:51:12.057,how to run python in eclipse with both py2 and py3?,"pre: + +I installed both python2.7 and python 3.70 +eclipse installed pydev, and configured two interpreters for each py version +I have a project with some py scripts + +question: +I choose one py file, I want run it in py2, then i want it run in py3(manually). +I know that each file cound has it's run configuration, but it could only choose one interpreter a time. +I also know that py.exe could help you get the right version of python. +I tried to add an interpreter with py.exe, but pydev keeps telling me that ""python stdlibs"" is necessary for a interpreter while only python3's lib shows up. +so, is there a way just like right click the file and choose ""run use interpreter xxx""? +or, does pydev has the ability to choose interpreters by ""#! python2""/""#! python3"" at file head?","I didn't understand what's the actual workflow you want... +Do you want to run each file on a different interpreter (say you have mod1.py and want to run it always on py2 and then mod2.py should be run always on py3) or do you want to run the same file on multiple interpreters (i.e.: you have mod1.py and want to run it both on py2 and py3) or something else? +So, please give more information on what's your actual problem and what you want to achieve... + +Options to run a single file in multiple interpreters: + +Always run with the default interpreter (so, make a regular run -- F9 to run the current editor -- change the default interpreter -- using Ctrl+shift+Alt+I -- and then rerun with Ctrl+F11). +Create a .sh/.bat which will always do 2 launches (initially configure it to just be a wrapper to launch with one python, then, after properly configuring it inside of PyDev that way change it to launch python 2 times, one with py2 and another with py3 -- note that I haven't tested, but it should work in theory).",0.3869120172231254,False,1,5841 +2018-11-27 23:32:32.593,Python regex to identify capitalised single word lines in a text abstract,"I am looking for a way to extract words from text if they match the following conditions: +1) are capitalised +and +2) appear on a new line on their own (i.e. no other text on the same line). +I am able to extract all capitalised words with this code: + caps=re.findall(r""\b[A-Z]+\b"", mytext) +but can't figure out how to implement the second condition. Any help will be greatly appreciated.",please try following statements \r\n at the begining of your regex expression,-0.2012947653214861,False,1,5842 +2018-11-28 12:15:31.400,Python and Dart Integration in Flutter Mobile Application,"Can i do these two things: + +Is there any library in dart for Sentiment Analysis? +Can I use Python (for Sentiment Analysis) in dart? + +My main motive for these questions is that I'm working on an application in a flutter and I use sentiment analysis and I have no idea that how I do that. +Can anyone please help me to solve this Problem.? +Or is there any way that I can do text sentiment analysis in the flutter app?","You can create an api using Python then serve it your mobile app (FLUTTER) using http requests. +I",0.6730655149877884,False,1,5843 +2018-11-28 15:25:07.900,Why is LocationLocal: Relative Alt dropping into negative values on a stationary drone?,"I'm running the Set_Attitude_Target example on an Intel Aero with Ardupilot. The code is working as intended but on top of a clear sensor error, that becomes more evident the longer I run the experiment. +In short, the altitude report from the example is reporting that in LocationLocal there is a relative altitude of -0.01, which gets smaller and smaller the longer the drone stays on. +If the drone takes off, say, 1 meter, then the relative altitude is less than that, so the difference is being taken out. +I ran the same example with the throttle set to a low value so the drone would stay stationary while ""trying to take off"" with insufficient thrust. For the 5 seconds that the drone was trying to take off, as well as after it gave up, disarmed and continued to run the code, the console read incremental losses to altitude, until I stopped it at -1 meter. +Where is this sensor error coming from and how do I remedy it?","As per Agustinus Baskara's comment on the original post, it would appear the built-in sensor is simply that bad - it can't be improved upon with software.",0.0,False,1,5844 +2018-11-29 00:38:11.560,The loss function and evaluation metric of XGBoost,"I am confused now about the loss functions used in XGBoost. Here is how I feel confused: + +we have objective, which is the loss function needs to be minimized; eval_metric: the metric used to represent the learning result. These two are totally unrelated (if we don't consider such as for classification only logloss and mlogloss can be used as eval_metric). Is this correct? If I am, then for a classification problem, how you can use rmse as a performance metric? +take two options for objective as an example, reg:logistic and binary:logistic. For 0/1 classifications, usually binary logistic loss, or cross entropy should be considered as the loss function, right? So which of the two options is for this loss function, and what's the value of the other one? Say, if binary:logistic represents the cross entropy loss function, then what does reg:logistic do? +what's the difference between multi:softmax and multi:softprob? Do they use the same loss function and just differ in the output format? If so, that should be the same for reg:logistic and binary:logistic as well, right? + +supplement for the 2nd problem +say, the loss function for 0/1 classification problem should be +L = sum(y_i*log(P_i)+(1-y_i)*log(P_i)). So if I need to choose binary:logistic here, or reg:logistic to let xgboost classifier to use L loss function. If it is binary:logistic, then what loss function reg:logistic uses?","'binary:logistic' uses -(y*log(y_pred) + (1-y)*(log(1-y_pred))) +'reg:logistic' uses (y - y_pred)^2 +To get a total estimation of error we sum all errors and divide by number of samples. + +You can find this in the basics. When looking on Linear regression VS Logistic regression. +Linear regression uses (y - y_pred)^2 as the Cost Function +Logistic regression uses -(y*log(y_pred) + (y-1)*(log(1-y_pred))) as the Cost function + +Evaluation metrics are completely different thing. They design to evaluate your model. You can be confused by them because it is logical to use some evaluation metrics that are the same as the loss function, like MSE in regression problems. However, in binary problems it is not always wise to look at the logloss. My experience have thought me (in classification problems) to generally look on AUC ROC. +EDIT + +according to xgboost documentation: + +reg:linear: linear regression + + +reg:logistic: logistic regression + + +binary:logistic: logistic regression for binary classification, output +probability + +So I'm guessing: +reg:linear: is as we said, (y - y_pred)^2 +reg:logistic is -(y*log(y_pred) + (y-1)*(log(1-y_pred))) and rounding predictions with 0.5 threshhold +binary:logistic is plain -(y*log(y_pred) + (1-y)*(log(1-y_pred))) (returns the probability) +You can test it out and see if it do as I've edited. If so, I will update the answer, otherwise, I'll just delete it :<",0.9999665971563038,False,1,5845 +2018-11-29 09:16:08.143,"After I modified my Python code in Pycharm, how to deploy the change to my Portainer?","Perhaps it is a basic question but I am really not a profession in Portainer. +I have a local Portainer, a Pycharm to manage the Python code. What should I do after I modified my code and deploy this change to the local Portainer? +Thx","If you have mounted the folder where your code resides directly in the container the changes will be also be applied in your container so no further action is required. +If you have not mounted the folder to your container (for example if you copy the code when you build the image), you would have to rebuild the image. Of course this is a lot more work so I would recommend using the mounted volumes.",0.0,False,1,5846 +2018-11-30 04:23:07.330,"Sqlalchemy before_execute event - how to pass some external variable, say app user id?","I am trying to obtain an application variable (app user id) in before_execute(conn, clauseelement, multiparam, param) method. The app user id is stored in python http request object which I do not have any access to in the db event. +Is there any way to associate a piece of sqlalchemy external data somewhere to fetch it in before_execute event later? +Appreciate your time and help.","Answering my own question here with a possible solution :) + +From http request copied the piece of data to session object +Since the session binding was at engine level, copied the data from session to connection object in SessionEvent.after_begin(session, transaction, connection). [Had it been Connection level binding, we could have directly set the objects from session object to connection object.] + +Now the data is available in connection object and in before_execute() too.",0.0,False,1,5847 +2018-11-30 05:17:50.717,Session cookie is too large flask application,"I'm trying to load certain data using sessions (locally) and it has been working for some time but, now I get the following warning and my data that was loaded through sessions is no longer being loaded. + +The ""b'session'"" cookie is too large: the value was 13083 bytes but + the header required 44 extra bytes. The final size was 13127 bytes but + the limitis 4093 bytes. Browsers may silently ignore cookies larger + than this. + +I have tried using session.clear(). I also opened up chrome developer tools and tried deleting the cookies associated with 127.0.0.1:5000. I have also tried using a different secret key to use with the session. +It would be greatly appreciated if I could get some help on this, since I have been searching for a solution for many hours. +Edit: +I am not looking to increase my limit by switching to server-side sessions. Instead, I would like to know how I could clear my client-side session data so I can reuse it. +Edit #2: +I figured it out. I forgot that I pushed way more data to my database, so every time a query was performed, the session would fill up immediately.","It looks like you are using the client-side type of session that is set by default with Flask which has a limited capacity of 4KB. You can use a server-side type session that will not have this limit, for example, by using a back-end file system (you save the session data in a file system in the server, not in the browser). To do so, set the configuration variable 'SESSION_TYPE' to 'filesystem'. +You can check other alternatives for the 'SESSION_TYPE' variable in the Flask documentation.",1.2,True,1,5848 +2018-11-30 12:32:27.360,not having to load a dataset over and over,"Currently in R, once you load a dataset (for example with read.csv), Rstudio saves it as a variable in the global environment. This ensures you don't have to load the dataset every single time you do a particular test or change. +With Python, I do not know which text editor/IDE will allow me to do this. E.G - I want to load a dataset once, and then subsequently do all sorts of things with it, instead of having to load it every time I run the script. +Any points as to how to do this would be very useful","It depends how large your data set is. +For relatively smaller datasets you could look at installing Anaconda Python Jupyter notebooks. Really great for working with data and visualisation once the dataset is loaded. For larger datasets you can write some functions / generators to iterate efficiently through the dataset.",0.0,False,1,5849 +2018-11-30 14:16:09.813,pymysql - Get value from a query,"I am executing the query using pymysql in python. + +select (sum(acc_Value)) from accInfo where acc_Name = 'ABC' + +The purpose of the query is to get the sum of all the values in acc_Value column for all the rows matchin acc_Name = 'ABC'. +The output i am getting when using cur.fetchone() is + +(Decimal('256830696'),) + +Now how to get that value ""256830696"" alone in python. +Thanks in advance.","It's a tuple, just take the 0th index",-0.3869120172231254,False,1,5850 +2018-12-01 14:09:56.980,Saving objects from tk canvas,"I'm trying to make a save function in a program im doing for bubbling/ballooning drawings. The only thing I can't get to work is save a ""work copy"". As if a drawing gets revision changes, you don't need to redo all the work. Just load the work copy, and add/remove/re-arrage bubbles. +I'm using tkinter and canvas. And creates ovals and text for bubbles. But I can't figure out any good way to save the info from the oval/text objects. +I tried to pickle the whole canvas, but that seems like it won't work after some googeling. +And pickle every object when created seems to only save the object id. 1, 2 etc. And that also won't work since some bubbles will be moved and receive new coordinates. They might also have a different color, size etc. +In my next approach I'm thinking of saving the whole ""can.create_oval( x1, y1, x2, y2, fill = fillC, outli...."" as a string to a txt and make the function to recreate a with eval() +Any one have any good suggestion on how to approach this?","There is no built-in way to save and restore the canvas. However, the canvas has methods you can use to get all of the information about the items on the canvas. You can use these methods to save this information to a file and then read this file back and recreate the objects. + +find_all - will return an ordered list of object ids for all objects on the canvas +type - will return the type of the object as a string (""rectangle"", ""circle"", ""text"", etc) +itemconfig - returns a dictionary with all of the configuration values for the object. The values in the dictionary are a list of values which includes the default value of the option at index 3 and the current value at index 4. You can use this to save only the option values that have been explicitly changed from the default. +gettags - returns a list of tags associated with the object",1.2,True,1,5851 +2018-12-03 01:15:30.087,Different sized vectors in word2vec,"I am trying to generate three different sized output vectors namely 25d, 50d and 75d. I am trying to do so by training the same dataset using the word2vec model. I am not sure how I can get three vectors of different sizes using the same training dataset. Can someone please help me get started on this? I am very new to machine learning and word2vec. Thanks","You run the code for one model three times, each time supplying a different vector_size parameter to the model initialization.",1.2,True,1,5852 +2018-12-03 03:23:29.990,data-item-url is on localhost instead of pythonanywhere (wagtail + snipcart project),"So instead of having data-item-url=""https://miglopes.pythonanywhere.com/ra%C3%A7%C3%A3o-de-c%C3%A3o-purina-junior-10kg/"" +it keeps on appearing +data-item-url=""http://localhost/ra%C3%A7%C3%A3o-de-c%C3%A3o-purina-junior-10kg/"" +how do i remove the localhost so my snipcart can work on checkout?","Without more details of where this tag is coming from it's hard to know for sure... but most likely you need to update your site's hostname in the Wagtail admin, under Settings -> Sites.",0.0,False,1,5853 +2018-12-03 21:09:40.843,Using MFCC's for voice recognition,"I'm currently using the Fourier transformation in conjunction with Keras for voice recogition (speaker identification). I have heard MFCC is a better option for voice recognition, but I am not sure how to use it. +I am using librosa in python (3) to extract 20 MFCC features. My question is: which MFCC features should I use for speaker identification? +In addition to this I am unsure on how to implement these features. What I would do is to get the necessary features and make one long vector input for a neural network. However, it is also possible to display colors, so could image recognition also be possible, or is this more aimed at speech, and not speaker recognition? +In short, I am unsure where I should start, as I am not very experienced with image recognition and have no idea where to start. +Thanks in advance!!","You can use MFCCs with dense layers / multilayer perceptron, but probably a Convolutional Neural Network on the mel-spectrogram will perform better, assuming that you have enough training data.",0.0,False,1,5854 +2018-12-04 18:22:55.240,How to add text to a file in python3,"Let's say i have the following file, +dummy_file.txt(contents below) +first line +third line +how can i add a line to that file right in the middle so the end result is: +first line +second line +third line +I have looked into opening the file with the append option, however that adds the line to the end of the file.","The standard file methods don't support inserting into the middle of a file. You need to read the file, add your new data to the data that you read in, and then re-write the whole file.",1.2,True,1,5855 +2018-12-05 08:13:04.893,DataFrame view in PyCharm when using pyspark,"I create a pyspark dataframe and i want to see it in the SciView tab in PyCharm when i debug my code (like I used to do when i have worked with pandas). +It says ""Nothing to show"" (the dataframe exists, I can see it when I use the show() command). +someone knows how to do it or maybe there is no integration between pycharm and pyspark dataframe in this case?","Pycharm does not support spark dataframes, you should call the toPandas() method on the dataframe. As @abhiieor mentioned in a comment, be aware that you can potentially collect a lot of data, you should first limit() the number of rows returned.",1.2,True,1,5856 +2018-12-08 01:12:11.607,"Is it possible to trigger a script or program if any data is updated in a database, like MySQL?","It doesn't have to be exactly a trigger inside the database. I just want to know how I should design this, so that when changes are made inside MySQL or SQL server, some script could be triggered.","One Way would be to keep a counter on the last updated row in the database, and then you need to keep polling(Checking) the database through python for new records in short intervals. +If the value in the counter is increased then you could use the subprocess module to call another Python script.",0.0,False,1,5857 +2018-12-09 22:47:38.660,Error for word2vec with GoogleNews-vectors-negative300.bin,"the version of python is 3.6 +I tried to execute my code but, there are still some errors as below: +Traceback (most recent call last): + +File + ""C:\Users\tmdgu\Desktop\NLP-master1\NLP-master\Ontology_Construction.py"", + line 55, in + , binary=True) +File ""E:\Program + Files\Python\Python35-32\lib\site-packages\gensim\models\word2vec.py"", + line 1282, in load_word2vec_format + raise DeprecationWarning(""Deprecated. Use gensim.models.KeyedVectors.load_word2vec_format instead."") +DeprecationWarning: Deprecated. Use + gensim.models.KeyedVectors.load_word2vec_format instead. + +how to fix the code? or is the path to data wrong?","This is just a warning, not a fatal error. Your code likely still works. +""Deprecation"" means a function's use has been marked by the authors as no longer encouraged. +The function typically still works, but may not for much longer – becoming unreliable or unavailable in some future library release. Often, there's a newer, more-preferred way to do the same thing, so you don't trigger the warning message. +Your warning message points you at the now-preferred way to load word-vectors of that format: use KeyedVectors.load_word2vec_format() instead. +Did you try using that, instead of whatever line of code (not shown in your question) that you were trying before seeing the warning?",0.6730655149877884,False,1,5858 +2018-12-11 00:40:44.053,Use of Breakpoint Method,"I am new to python and am unsure of how the breakpoint method works. Does it open the debugger for the IDE or some built-in debugger? +Additionally, I was wondering how that debugger would be able to be operated. +For example, I use Spyder, does that mean that if I use the breakpoint() method, Spyder's debugger will open, through which I could the Debugger dropdown menu, or would some other debugger open? +I would also like to know how this function works in conjunction with the breakpointhook() method.","No, debugger will not open itself automatically as a consequence of setting a breakpoint. +So you have first set a breakpoint (or more of them), and then manually launch a debugger. +After this, the debugger will perform your code as usually, but will stop performing instructions when it reaches a breakpoint - the instruction at the breakpoint itself it will not perform. It will pause just before it, given you an opportunity to perform some debug tasks, as + +inspect variable values, +set variables manually to other values, +continue performing instructions step by step (i. e. only the next instruction), +continue performing instructions to the next breakpoint, +prematurely stop debugging your program. + +This is the common scenario for all debuggers of all programming languages (and their IDEs). +For IDEs, launching a debugger will + +enable or reveal debugging instructions in their menu system, +show a toolbar for them and will, +enable hot keys for them. + +Without setting at least one breakpoint, most debuggers perform the whole program without a pause (as launching it without a debugger), so you will have no opportunity to perform any debugging task. +(Some IDEs have an option to launch a debugger in the ""first instruction, then a pause"" mode, so you need not set breakpoints in advance in this case.) + +Yes, the breakpoint() built-in function (introduced in Python 3.7) stops executing your program, enters it in the debugging mode, and you may use Spyder's debugger drop-down menu. +(It isn't a Spyders' debugger, only its drop-down menu; the used debugger will be still the pdb, i. e. the default Python DeBugger.) +The connection between the breakpoint() built-in function and the breakpointhook() function (from the sys built-in module) is very straightforward - the first one directly calls the second one. +The natural question is why we need two functions with the exactly same behavior? +The answer is in the design - the breakpoint() function may be changed indirectly, by changing the behavior of the breakpointhook() function. +For example, IDE creators may change the behavior of the breakpointhook() function so that it will launch their own debugger, not the pdb one.",1.2,True,1,5859 +2018-12-11 01:14:39.167,Is there an appropriate version of Pygame for Python 3.7 installed with Anaconda?,"I'm new to programming and I just downloaded Anaconda a few days ago for Windows 64-bit. I came across the Invent with Python book and decided I wanted to work through it so I downloaded that too. I ended up running into a couple issues with it not working (somehow I ended up with Spyder (Python 2.7) and end=' ' wasn't doing what it was supposed to so I uninstalled and reinstalled Anaconda -- though originally I did download the 3.7 version). It looked as if I had the 2.7 version of Pygame. I'm looking around and I don't see a Pygame version for Python 3.7 that is compatible with Anaconda. The only ones I saw were for Mac or not meant to work with Anaconda. This is all pretty new to me so I'm not sure what my options are. Thanks in advance. +Also, how do I delete the incorrect Pygame version?","just use pip install pygame & python will look for a version compatible with your installation. +If you're using Anaconda and pip doesn't work on CMD prompt, try using the Anaconda prompt from start menu.",0.6730655149877884,False,1,5860 +2018-12-11 17:54:00.677,python-hypothesis: Retrieving or reformatting a falsifying example,"Is it possible to retrieve or reformat the falsifying example after a test failure? The point is to show the example data in a different format - data generated by the strategy is easy to work with in the code but not really user friendly, so I'm looking at how to display it in a different form. Even a post-mortem tool working with the example database would be enough, but there does not seem to be any API allowing that, or am I missing something?","Even a post-mortem tool working with the example database would be enough, but there does not seem to be any API allowing that, or am I missing something? + +The example database uses a private format and only records the choices a strategy made to generate the falsifying example, so there's no way to extract the data of the example short of re-running the test. +Stuart's recommendation of hypothesis.note(...) is a good one.",0.0,False,1,5861 +2018-12-11 19:43:33.823,Template rest one day from the date,"In my view.py I obtain a date from my MSSQL database in this format 2018-12-06 00:00:00.000 so I pass that value as context like datedb and in my html page I render it like this {{datedb|date:""c""}} but it shows the date with one day less like this: + +2018-12-05T18:00:00-06:00 + +Is the 06 not the 05 day. +why is this happening? how can I show the right date?","One way of solve the problem was chage to USE_TZ = False has Willem said in the comments, but that gives another error so I found the way to do it just adding in the template this {% load tz %} and using the flter |utc on the date variables like datedb|utc|date:'Y-m-d'.",1.2,True,1,5862 +2018-12-12 12:15:09.190,Add full anaconda package list to existing conda environment,"I know how to add single packages and I know that the conda create command supports adding a new environment with all anaconda packages installed. +But how can I add all anaconda packages to an existing environment?","I was able to solve the problem as following: + +Create a helper env with anaconda: conda create -n env_name anaconda +Activate that env conda activate env_name +Export packages into specification file: conda list --explicit > spec-file.txt +Activate the target environment: activate target_env_name +Import that specification file: conda install --file spec-file.txt",0.3869120172231254,False,1,5863 +2018-12-12 17:20:31.293,how to compare two text document with tfidf vectorizer?,"I have two different text which I want to compare using tfidf vectorization. +What I am doing is: + +tokenizing each document +vectorizing using TFIDFVectorizer.fit_transform(tokens_list) + +Now the vectors that I get after step 2 are of different shape. +But as per the concept, we should have the same shape for both the vectors. Only then the vectors can be compared. +What am I doing wrong? Please help. +Thanks in advance.","As G. Anderson already pointed out, and to help the future guys on this, when we use the fit function of TFIDFVectorizer on document D1, it means that for the D1, the bag of words are constructed. +The transform() function computes the tfidf frequency of each word in the bag of word. +Now our aim is to compare the document D2 with D1. It means we want to see how many words of D1 match up with D2. Thats why we perform fit_transform() on D1 and then only the transform() function on D2 would apply the bag of words of D1 and count the inverse frequency of tokens in D2. +This would give the relative comparison of D1 against D2.",1.2,True,1,5864 +2018-12-13 13:43:34.987,"python, dictionaries how to get the first value of the first key","So basically I have a dictionary with x and y values and I want to be able to get only the x value of the first coordinate and only the y value of the first coordinate and then the same with the second coordinate and so on, so that I can use it in an if-statement.","if the values are ordered in columns just use + +x=your_variable[:,0] y=your_variable[:,1] + +i think",0.3869120172231254,False,1,5865 +2018-12-15 21:55:17.020,how to install tkinter with Pycharm?,"I used sudo apt-get install python3.6-tk and it works fine. Tkinter works if I open python in terminal, but I cannot get it installed on my Pycharm project. pip install command says it cannot find Tkinter. I cannot find python-tk in the list of possible installs either. +Is there a way to get Tkinter just standard into every virtualenv when I make a new project in Pycharm? +Edit: on Linux Mint +Edit2: It is a clear problem of Pycharm not getting tkinter guys. If I run my local python file from terminal it works fine. Just that for some reason Pycharm cannot find anything tkinter related.","Python already has tkinter installed. It is a base module, like random or time, therefore you don't need to install it.",-0.0679224682270276,False,1,5866 +2018-12-18 01:57:32.877,Print output to console while redirect the output to a file in linux,"I am using python in linux and tried to use command line to print out the output log while redirecting the output and error to a txt.file. However, after I searched and tried the methods such as +python [program] 2>&1 | tee output.log +But it just redirected the output the the output.log and the print content disappeared. I wonder how I could print the output to console while save/redirect them to output.log ? It would be useful if we hope to tune the parameter while having notice on the output loss and parameter.","You can create a screen like this: screen -L and then run the python script in this screen which would give the output to the console and also would save it the file: screenlog.0. You could leave the screen by using Ctrl+A+D while the script is running and check the script output by reattaching to the screen by screen -r. Also, in the screen, you won't be able to scroll past the current screen view.",0.0,False,1,5867 +2018-12-18 10:17:19.160,Regex for Sentences in python,"I have one more Query +here is two sentences + +[1,12:12] call basic_while1() Error Code: 1046. No database selected +[1,12:12] call add() Asdfjgg Error Code: 1046. No database selected +[1,12:12] call add() +[1,12:12] +Error Code: 1046. No database selected +now I want to get output like this +['1','12:12',""call basic_while1""] , ['1','12:12', 'call add() Asdfjgg'],['1','12:12', 'call add()'],['1','12:12'],['','','',' Error Code: 1046. No database selected'] + +I used this r'^\[(\d+),(\s[0-9:]+)\]\s+(.+) this is my main regex then as per my concern I modified it but It didn't help me +I want to cut everything exact before ""Error Code"" +how to do that?","basically you asked to get everything before the ""Error Code"" + +I want to cut everything exact before ""Error Code"" + +so it is simple, try: find = re.search('((.)+)(\sError Code)*',s) and find.group(1) will give you '[1,12:12] call add() Asdfjgg' which is what you wanted. +if after you got that string you want list that you requested : +desired_list = find.group(1).replace('[','').replace(']','').replace(',',' ').split()",0.0,False,1,5868 +2018-12-18 23:09:13.550,install numpy on python 3.5 Mac OS High sierra,"I wanted to install the numpy package for python 3.5 on my Mac OS High Sierra, but I can't seem to make it work. +I have it on python2.7, but I would also like to install it for the next versions. +Currently, I have installed python 2.7, python 3.5, and python 3.7. +I tried to install numpy using: + +brew install numpy --with-python3 (no error) +sudo port install py35-numpy@1.15.4 (no error) +sudo port install py37-numpy@1.15.4 (no error) +pip3.5 install numpy (gives ""Could not find a version that satisfies the requirement numpy (from versions: ) +No matching distribution found for numpy"" ) + +I can tell that it is not installed because when I type python3 and then import numpy as np gives ""ModuleNotFoundError: No module named 'numpy'"" +Any ideas on how to make it work? +Thanks in advance.","First, you need to activate the virtual environment for the version of python you wish to run. After you have done that then just run ""pip install numpy"" or ""pip3 install numpy"". +If you used Anaconda to install python then, after activating your environment, type conda install numpy.",1.2,True,2,5869 +2018-12-18 23:09:13.550,install numpy on python 3.5 Mac OS High sierra,"I wanted to install the numpy package for python 3.5 on my Mac OS High Sierra, but I can't seem to make it work. +I have it on python2.7, but I would also like to install it for the next versions. +Currently, I have installed python 2.7, python 3.5, and python 3.7. +I tried to install numpy using: + +brew install numpy --with-python3 (no error) +sudo port install py35-numpy@1.15.4 (no error) +sudo port install py37-numpy@1.15.4 (no error) +pip3.5 install numpy (gives ""Could not find a version that satisfies the requirement numpy (from versions: ) +No matching distribution found for numpy"" ) + +I can tell that it is not installed because when I type python3 and then import numpy as np gives ""ModuleNotFoundError: No module named 'numpy'"" +Any ideas on how to make it work? +Thanks in advance.","If running pip3.5 --version or pip3 --version works, what is the output when you run pip3 freeze? If there is no output, it indicates that there are no packages installed for the Python 3 environment and you should be able to install numpy with pip3 install numpy.",0.0,False,2,5869 +2018-12-19 15:33:16.960,Python Vscode extension - can't change remote jupyter notebook kernel,"I've got the updated Python VSCode extension installed and it works great. I'm able to use the URL with the token to connect to a remote Jupyter notebook. I just cannot seem to figure out how to change the kernel on the remote notebook for use in VSCode. +If I connect to the remote notebook through a web browser, I can see my two environments through the GUI and change kernels. Is there a similar option in the VSCode extension?","The command that worked for me in vscode: +Notebook: Select Notebook Kernel",0.0,False,2,5870 +2018-12-19 15:33:16.960,Python Vscode extension - can't change remote jupyter notebook kernel,"I've got the updated Python VSCode extension installed and it works great. I'm able to use the URL with the token to connect to a remote Jupyter notebook. I just cannot seem to figure out how to change the kernel on the remote notebook for use in VSCode. +If I connect to the remote notebook through a web browser, I can see my two environments through the GUI and change kernels. Is there a similar option in the VSCode extension?","Run the following command in vscode: +Python: Select interpreter to start Jupyter server +It will allow you to choose the kernel that you want.",0.0,False,2,5870 +2018-12-21 02:43:43.240,Backtesting a Universe of Stocks,"I would like to develop a trend following strategy via back-testing a universe of stocks; lets just say all NYSE or S&P500 equities. I am asking this question today because I am unsure how to handle the storage/organization of the massive amounts of historical price data. +After multiple hours of research I am here, asking for your experience and awareness. I would be extremely grateful for any information/awareness you can share on this topic + +Personal Experience background: +-I know how to code. Was a Electrical Engineering major, not a CS major. +-I know how to pull in stock data for individual tickers into excel. +Familiar with using filtering and custom studies on ThinkOrSwim. +Applied Context: +From 1995 to today lets evaluate the best performing equities on a relative strength/momentum basis. We will look to compare many technical characteristics to develop a strategy. The key to this is having data for a universe of stocks that we can run backtests on using python, C#, R, or any other coding language. We can then determine possible strategies by assesing the returns, the omega ratio, median excess returns, and Jensen's alpha (measured weekly) of entries and exits that are technical driven. + +Here's where I am having trouble figuring out what the next step is: +-Loading data for all S&P500 companies into a single excel workbook is just not gonna work. Its too much data for excel to handle I feel like. Each ticker is going to have multiple MB of price data. +-What is the best way to get and then store the price data for each ticker in the universe? Are we looking at something like SQL or Microsoft access here? I dont know; I dont have enough awareness on the subject of handling lots of data like this. What are you thoughts? + +I have used ToS to filter stocks based off of true/false parameters over a period of time in the past; however the capabilities of ToS are limited. +I would like a more flexible backtesting engine like code written in python or C#. Not sure if Rscript is of any use. - Maybe, there are libraries out there that I do not have awareness of that would make this all possible? If there are let me know. +I am aware that Quantopia and other web based Quant platforms are around. Are these my best bets for backtesting? Any thoughts on them? + +Am I making this too complicated? +Backtesting a strategy on a single equity or several equities isnt a problem in excel, ToS, or even Tradingview. But with lots of data Im not sure what the best option is for storing that data and then using a python script or something to perform the back test. + +Random Final thought:-Ultimately would like to explore some AI assistance with optimizing strategies that were created based off parameters. I know this is a thing but not sure where to learn more about this. If you do please let me know. + +Thank you guys. I hope this wasn't too much. If you can share any knowledge to increase my awareness on the topic I would really appreciate it. +Twitter:@b_gumm","The amout of data is too much for EXCEL or CALC. Even if you want to screen only 500 Stocks from S&P 500, you will get 2,2 Millions of rows (approx. 220 days/year * 20 years * 500 stocks). For this amount of data, you should use a SQL Database like MySQL. It is performant enough to handle this amount of data. But you have to find a way for updating. If you get the complete time series daily and store it into your database, this process can take approx. 1 hour. You could also use delta downloads but be aware of corporate actions (e.g. splits). +I don't know Quantopia, but I know a similar backtesting service where I have created a python backtesting script last year. The outcome was quite different to what I have expected. The research result was that the backtesting service was calculating wrong results because of wrong data. So be cautious about the results.",0.0,False,1,5871 +2018-12-21 11:15:31.803,Date Range for Facebook Graph API request on posts level,"I am working on a tool for my company created to get data from our Facebook publications. It has not been working for a while, so I have to get all the historical data from June to November 2018. +My two scripts (one that get title and type of publication, and the other that get the number of link clicks) are working well to get data from last pushes, but when I try to add a date range in my Graph API request, I have some issues: + +the regular query is [page_id]/posts?fields=id,created_time,link,type,name +the query for historical data is [page_id]/posts?fields=id,created_time,link,type,name,since=1529280000&until=1529712000, as the API is supposed to work with unixtime +I get perfect results for regular use, but the results for historical data only shows video publications in Graph API Explorer, with a debug message saying: + + +The since field does not exist on the PagePost object. + +Same for ""until"" field when not using ""since"". I tried to replace ""posts/"" with ""feed/"" but it returned the exact same result... +Do you have any idea of how to get all the publications from a Page I own on a certain date range?","So it seems that it is not possible to request this kind of data unfortunately, third party services must be used...",0.0,False,1,5872 +2018-12-23 03:14:14.787,Pyautogui mouse click on different resolution,"I'm writing a script for automatizing some tasks at my job. However, I need to make my script portable and try it on different screen resolution. +So far right now I've tried to multiply my coordinate with the ratio between the old and new resolutions, but this doesn't work properly. +Do you know how I can convert my X, Y coordinates for mouse's clicks make it works on different resolution?","Quick question: Are you trying to get it to click on certain buttons? (i.e. buttons that look the same on every computer you plug it into) And by portable, do you mean on a thumb drive (usb)? +You may be able to take an image of the button (i.e. cropping a screenshot), pass it on to the opencv module, one of the modules has an Image within Image searching ability. you can pass that image along with a screenshot (using pyautogui.screenshot()) and it will return the (x,y) coordinates of the button, pass that on to pyautogui.moveto(x,y) and pyautogui.click(), it might be able to work. you might have to describe the action you are trying to get Pyautogui to do a little better.",0.3869120172231254,False,1,5873 +2018-12-24 13:58:52.250,extracting text just after a particular tag using beautifulsoup?,"I need to extract the text just after strong tag from html page given below? how can i do it using beautiful soup. It is causing me problem as it doesn't have any class or id so only way to select this tag is using text. +{strong}Name:{/strong} Sam smith{br} +Required result +Sam smith","Thanks for all your answers but i was able to do this by following: +b_el = soup.find('strong',text='Name:') +print b_el.next_sibling +This works fine for me. This prints just next sibling how can i print next 2 sibling is there anyway ?",-0.3869120172231254,False,1,5874 +2018-12-25 10:26:24.547,How to train your own model in AWS Sagemaker?,"I just started with AWS and I want to train my own model with own dataset. I have my model as keras model with tensorflow backend in Python. I read some documentations, they say I need a Docker image to load my model. So, how do I convert keras model into Docker image. I searched through internet but found nothing that explained the process clearly. How to make docker image of keras model, how to load it to sagemaker. And also how to load my data from a h5 file into S3 bucket for training? Can anyone please help me in getting clear explanation?","You can convert your Keras model to a tf.estimator and train using the TensorFlow framework estimators in Sagemaker. +This conversion is pretty basic though, I reimplemented my models in TensorFlow using the tf.keras API which makes the model nearly identical and train with the Sagemaker TF estimator in script mode. +My initial approach using pure Keras models was based on bring-your-own-algo containers similar to the answer by Matthew Arthur.",0.0,False,1,5875 +2018-12-25 21:14:39.453,Installing Python Dependencies locally in project,"I am coming from NodeJS and learning Python and was wondering how to properly install the packages in requirements.txt file locally in the project. +For node, this is done by managing and installing the packages in package.json via npm install. However, the convention for Python project seems to be to add packages to a directory called lib. When I do pip install -r requirements.txt I think this does a global install on my computer, similar to nodes npm install -g global install. How can I install the dependencies of my requirements.txt file in a folder called lib?","use this command +pip install -r requirements.txt -t ",1.2,True,1,5876 +2018-12-26 11:44:32.850,P4Python check if file is modified after check-out,I need to check-in the file which is in client workspace. Before check-in i need to verify if the file has been changed. Please tell me how to check this.,Use the p4 diff -sr command. This will do a diff of opened files and return the names of ones that are unchanged.,1.2,True,1,5877 +2018-12-26 21:26:16.360,How can I source two paths for the ROS environmental variable at the same time?,"I have a problem with using the rqt_image_view package in ROS. Each time when I type rqt_image_view or rosrun rqt_image_view rqt_image_view in terminal, it will return: + +Traceback (most recent call last): + File ""/opt/ros/kinetic/bin/rqt_image_view"", line 16, in + plugin_argument_provider=add_arguments)) + File ""/opt/ros/kinetic/lib/python2.7/dist-packages/rqt_gui/main.py"", line 59, in main + return super(Main, self).main(argv, standalone=standalone, plugin_argument_provider=plugin_argument_provider, plugin_manager_settings_prefix=str(hash(os.environ['ROS_PACKAGE_PATH']))) + File ""/opt/ros/kinetic/lib/python2.7/dist-packages/qt_gui/main.py"", line 338, in main + from python_qt_binding import QT_BINDING + ImportError: cannot import name QT_BINDING + +In the /.bashrc file, I have source : + +source /opt/ros/kinetic/setup.bash + source /home/kelu/Dropbox/GET_Lab/leap_ws/devel/setup.bash --extend + source /eda/gazebo/setup.bash --extend + +They are the default path of ROS, my own working space, the robot simulator of our university. I must use all of them. I have already finished many projects with this environmental variable setting. However, when I want to use the package rqt_image_view today, it returns the above error info. +When I run echo $ROS_PACKAGE_PATH, I get the return: + +/eda/gazebo/ros/kinetic/share:/home/kelu/Dropbox/GET_Lab/leap_ws/src:/opt/ros/kinetic/share + +And echo $PATH + +/usr/local/cuda/bin:/opt/ros/kinetic/bin:/usr/local/cuda/bin:/usr/local/cuda/bin:/home/kelu/bin:/home/kelu/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin + +Then I only source the /opt/ros/kinetic/setup.bash ,the rqt_image_view package runs!! +It seems that, if I want to use rqt_image_view, then I can not source both /opt/ros/kinetic/setup.bash and /home/kelu/Dropbox/GET_Lab/leap_ws/devel/setup.bash at the same time. +Could someone tell me how to fix this problem? I have already search 5 hours in google and haven't find a solution.","Different solutions to try: + +It sounds like the first path /eda/gazebo/ros/kinetic/share or /home/kelu/Dropbox/GET_Lab/leap_ws/src has an rqt_image_view package that is being used. Try to remove that dependency. +Have you tried switching the source files being sourced? This depends on how the rqt_image_view package was built, such as by source or through a package manager. + +Initially, it sounds like there is a problem with the paths being searched or wrong package being run since the package works with the default ROS environment setup.",0.0,False,1,5878 +2018-12-27 09:49:47.840,how to constrain scipy curve_fit in positive result,"I'm using scipy curve_fit to curve a line for retention. however, I found the result line may produce negative number. how can i add some constrain? +the 'bounds' only constrain parameters not the results y","One of the simpler ways to handle negative value in y, is to make a log transformation. Get the best fit for log transformed y, then do exponential transformation for actual error in the fit or for any new value prediction.",0.0,False,1,5879 +2018-12-27 10:57:53.617,Vpython using Spyder : how to prevent browser tab from opening?,"I am using vpython library in spyder. After importing the library when I call simple function like print('x') or carry out any assignment operation and execute the program, immediately a browser tab named localhost and port address opens up and I get the output in console {if I used print function}. +I would like to know if there is any option to prevent the tab from opening and is it possible to make the tab open only when it is required. +PS : I am using windows 10, chrome as browser, python 3.5 and spyder 3.1.4.",There is work in progress to prevent the opening of a browser tab when there are no 3D objects or graph to display. I don't know when this will be released.,0.0,False,1,5880 +2018-12-27 16:54:21.267,ImportError: cannot import name 'AFAVSignature',"I get this error after already having installed autofocus when I try to run a .py file from the command line that contains the line: +from autofocus import Autofocus2D +Output: +ImportError: cannot import name 'AFAVSignature' +Is anyne familiar with this package and how to import it? +Thanks","It doesn't look like the library is supported for python 3. I was getting the same error, but removed that line from init.py and found that there was another error with of something like 'print e' not working, so I put the line back in and imported with python2 and it worked.",0.0,False,1,5881 +2018-12-28 00:04:02.473,how can I find out which python virtual environment I am using?,I have several virtual environment in my computer and sometimes I am in doubt about which python virtual environment I am using. Is there an easy way to find out which virtual environment I am connected to?,"Usually it's set to display in your prompt. You can also try typing in which python or which pip in your terminal to see if it points to you venv location, and which one. (Use where instead of which on Windows.)",0.9974579674738372,False,2,5882 +2018-12-28 00:04:02.473,how can I find out which python virtual environment I am using?,I have several virtual environment in my computer and sometimes I am in doubt about which python virtual environment I am using. Is there an easy way to find out which virtual environment I am connected to?,"From a shell prompt, you can just do echo $VIRTUAL_ENV (or in Windows cmd.exe, echo %VIRTUAL_ENV%). +From within Python, sys.prefix provides the root of your Python installation (the virtual environment if active), and sys.executable tells you which Python executable is running your script.",0.9903904942256808,False,2,5882 +2018-12-30 14:34:30.510,how to delete django relation and rebuild model,"ive made a mistake with my django and messed up my model +I want to delete it & then recreate it - how do I do that? +I get this when I try to migrate - i just want to drop it +relation ""netshock_todo"" already exists +Thanks in advance","Delete all of your migrations file except __init__.py +Then go to database and find migrations table, delete all row in migrations table. Then run makemigrations and migrate command",1.2,True,1,5883 +2018-12-31 14:33:34.473,Scrapy shell doesn't crawl web page,"I am trying to use Scrapy shell to try and figure out the selectors for zone-h.org. I run scrapy shell 'webpage' afterwards I tried to view the content to be sure that it is downloaded. But all I can see is a dash icon (-). It doesn't download the page. I tried to enter the website to check if my connection to the website is somehow blocked, but it was reachable. I tried setting user agent to something more generic like chrome but no luck there either. The website is blocking me somehow but I don't know how can I bypass it. I digged through the the website if they block crawling and it doesn't say it is forbidden to crawl it. Can anyone help out?","Can you use scrapy shell ""webpage"" on another webpage that you know works/doesn't block scraping? +Have you tried using the view(response) command to open up what scrapy sees in a web browser? +When you go to the webpage using a normal browser, are you redirected to another, final homepage? +- if so, try using the final homepage's URL in your scrapy shell command +Do you have firewalls that could interfere with a Python/commandline app from connecting to the internet?",0.0,False,1,5884 +2019-01-03 23:22:36.667,How to add to pythonpath in virtualenvironment,"On my windows machine I created a virtual environement in conda where I run python 3.6. I want to permanently add a folder to the virtual python path environment. If I append something to sys.path it is lost on exiting python. +Outside of my virtual enviroment I can just add to user variables by going to advanced system settings. I have no idea how to do this within my virtual enviroment. +Any help is much appreciated.","If you are on Windows 10+, this should work: +1) Click on the Windows button on the screen or on the keyboard, both in the bottom left section. +2) Type ""Environment Variables"" (without the quotation marks, of course). +3) Click on the option that says something like ""Edit the System Environment Variables"" +4) Click on the ""Advanced Tab,"" and then click ""Environment Variables"" (Near the bottom) +5) Click ""Path"" in the top box - it should be the 3rd option - and then click ""Edit"" (the top one) +6) Click ""New"" at the top, and then add the path to the folder you want to create. +7) Click ""Ok"" at the bottom of all the pages that were opened as a result of the above-described actions to save. +That should work, please let me know in the comments if it doesn't.",-0.2012947653214861,False,1,5885 +2019-01-04 08:03:05.297,Do Dash apps reload all data upon client log in?,"I'm wondering about how a dash app works in terms of loading data, parsing and doing initial calcs when serving to a client who logs onto the website. +For instance, my app initially loads a bunch of static local csv data, parses a bunch of dates and loads them into a few pandas data frames. This data is then displayed on a map for the client. +Does the app have to reload/parse all of this data every time a client logs onto the website? Or does the dash server load all the data only the first time it is instantiated and then just dish it out every time a client logs on? +If the data reloads every time, I would then use quick parsers like udatetime, but if not, id prefer to use a convenient parser like pendulum which isn't as efficient (but wouldn't matter if it only parses once). +I hope that question makes sense. Thanks in advance!","The only thing that is called on every page load is the function you can assign to app.layout. This is useful if you want to display dynamic content like the current date on your page. +Everything else is just executed once when the app is starting. +This means if you load your data outside the app.layout (which I assume is the case) everything is loaded just once.",1.2,True,1,5886 +2019-01-05 23:50:56.660,How do i implement Logic to Django?,"So I have an assignment to build a web interface for a smart sensor, +I've already written the python code to read the data from the sensor and write it into sqlite3, control the sensor etc. +I've built the HTML, CSS template and implemented it into Django. +My goal is to run the sensor reading script pararel to the Django interface on the same server, so the server will do all the communication with the sensor and the user will be able to read and configure the sensor from the web interface. (Same logic as modern routers - control and configure from a web interface) +Q: Where do I put my sensor_ctl.py script in my Django project and how I make it to run independent on the server. (To read sensor data 24/7) +Q: Where in my Django project I use my classes and method from sensor_ctl.py to write/read data to my djangos database instead of the local sqlite3 database (That I've used to test sensor_ctl.py)","Place your code in app/appname/management/commands folder. Use Official guide for management commands. Then you will be able to use your custom command like this: +./manage getsensorinfo +So when you will have this command registered, you can just put in in cron and it will be executed every minute. +Secondly you need to rewrite your code to use django ORM models like this: +Stat.objects.create(temp1=60,temp2=70) instead of INSERT into....",1.2,True,1,5887 +2019-01-06 02:49:09.817,How does selenium work with hosting services?,"I have a Flask app that uses selenium to get data from a website. I have spent 10+ hours trying to get heroku to work with it, but no success. My main problem is selenium. with heroku, there is a ""buildpack"" that you use to get selenium working with it, but with all the other hosting services, I have found no information. I just would like to know how to get selenium to work with any other recommended service than heroku. Thank you.","You need hosting service that able to install Chrome, chromedriver and other dependencies. Find for Virtual Private hosting (VPS), or Dedicated Server or Cloud Hosting but not Shared hosting.",0.0,False,1,5888 +2019-01-06 10:28:46.997,How do I root in python (other than square root)?,"I'm trying to make a calculator in python, so when you type x (root) y it will give you the x root of y, e.g. 4 (root) 625 = 5. +I'm aware of how to do math.sqrt() but is there a way to do other roots?","If you want to 625^(1/4){which is the same as 4th root of 625} +then you type 625**(1/4) +** is the operator for exponents in python. +print(625**(1/4)) +Output: +5.0 +To generalize: +if you want to find the xth root of y, you do: +y**(1/x)",0.6730655149877884,False,1,5889 +2019-01-08 17:44:43.800,TF-IDF + Multiple Regression Prediction Problem,"I have a dataset of ~10,000 rows of vehicles sold on a portal similar to Craigslist. The columns include price, mileage, no. of previous owners, how soon the car gets sold (in days), and most importantly a body of text that describes the vehicle (e.g. ""accident free, serviced regularly""). +I would like to find out which keywords, when included, will result in the car getting sold sooner. However I understand how soon a car gets sold also depends on the other factors especially price and mileage. +Running a TfidfVectorizer in scikit-learn resulted in very poor prediction accuracy. Not sure if I should try including price, mileage, etc. in the regression model as well, as it seems pretty complicated. Currently am considering repeating the TF-IDF regression on a particular segment of the data that is sufficiently huge (perhaps Toyotas priced at $10k-$20k). +The last resort is to plot two histograms, one of vehicle listings containing a specific word/phrase and another for those that do not. The limitation here would be that the words that I choose to plot will be based on my subjective opinion. +Are there other ways to find out which keywords could potentially be important? Thanks in advance.","As you mentioned you could only so much with the body of text, which signifies the amount of influence of text on selling the cars. +Even though the model gives very poor prediction accuracy, you could ahead to see the feature importance, to understand what are the words that drive the sales. +Include phrases in your tfidf vectorizer by setting ngram_range parameter as (1,2) +This might gives you a small indication of what phrases influence the sales of a car. +If would also suggest you to set norm parameter of tfidf as None, to check if has influence. By default, it applies l2 norm. +The difference would come based the classification model, which you are using. Try changing the model also as a last option.",1.2,True,1,5890 +2019-01-09 15:12:08.163,"Linux Jupyter Notebook : ""The kernel appears to have died. It will restart automatically""","I am using the PYNQ Linux on Zedboard and when I tried to run a code on Jupyter Notebook to load a model.h5 I got an error message: +""The kernel appears to have died. It will restart automatically"" +I tried to upgrade keras and Jupyter but still have the same error +I don't know how to fix this problem ?",Model is too large to be loaded into memory so kernel has died.,0.0,False,1,5891 +2019-01-09 22:59:39.340,Difference between Python Interpreter and IDLE?,"For homework in my basic python class, we have to start python interpreter in interactive mode and type a statement. Then, we have to open IDLE and type a statement. I understand how to write statements in both, but can't quite tell them apart? I see that there are to different desktop apps for python, one being the python 3.7 (32-bit), and the other being IDLE. Which one is the interpreter, and how do I get it in interactive mode? Also, when I do open IDLE do I put my statement directly in IDLE or, do I open a 'new file' and do it like that? I'm just a bit confused about the differences between them all. But I do really want to learn this language! Please help!","Python unlike some languages can be written one line at a time with you getting feedback after every line . This is called interactive mode. You will know you are in interactive mode if you see "">>>"" on the far left side of the window. This mode is really only useful for doing small tasks you don't think will come up again. +Most developers write a whole program at once then save it with a name that ends in "".py"" and run it in an interpreter to get the results.",1.2,True,1,5892 +2019-01-10 15:30:10.413,How to handle SQL dump with Python,"I received a data dump of the SQL database. +The data is formatted in an .sql file and is quite large (3.3 GB). I have no idea where to go from here. I have no access to the actual database and I don't know how to handle this .sql file in Python. +Can anyone help me? I am looking for specific steps to take so I can use this SQL file in Python and analyze the data. +TLDR; Received an .sql file and no clue how to process/analyze the data that's in the file in Python. Need help in necessary steps to make the .sql usable in Python.","It would be an extraordinarily difficult process to try to construct any sort of Python program that would be capable of parsing the SQL syntax of any such of a dump-file and to try to do anything whatsoever useful with it. +""No. Absolutely not. Absolute nonsense."" (And I have over 30 years of experience, including senior management.) You need to go back to your team, and/or to your manager, and look for a credible way to achieve your business objective ... because, ""this isn't it."" +The only credible thing that you can do with this file is to load it into another mySQL database ... and, well, ""couldn't you have just accessed the database from which this dump came?"" Maybe so, maybe not, but ""one wonders."" +Anyhow – your team and its management need to ""circle the wagons"" and talk about your credible options. Because, the task that you've been given, in my professional opinion, ""isn't one."" Don't waste time – yours, or theirs.",0.2012947653214861,False,2,5893 +2019-01-10 15:30:10.413,How to handle SQL dump with Python,"I received a data dump of the SQL database. +The data is formatted in an .sql file and is quite large (3.3 GB). I have no idea where to go from here. I have no access to the actual database and I don't know how to handle this .sql file in Python. +Can anyone help me? I am looking for specific steps to take so I can use this SQL file in Python and analyze the data. +TLDR; Received an .sql file and no clue how to process/analyze the data that's in the file in Python. Need help in necessary steps to make the .sql usable in Python.","Eventually I had to install MAMP to create a local mysql server. I imported the SQL dump with a program like SQLyog that let's you edit SQL databases. +This made it possible to import the SQL database in Python using SQLAlchemy, MySQLconnector and Pandas.",0.3869120172231254,False,2,5893 +2019-01-10 18:42:54.360,Interfacing a QR code recognition to a django database,"I'm coming to you with the following issue: +I have a bunch of physical boxes onto which I still stick QR codes generated using a python module named qrcode. In a nutshell, what I would like to do is everytime someone wants to take the object contained in a box, he scans the qr code with his phone, then takes it and put it back when he is done, not forgetting to scan the QR code again. +Pretty simple, isn't it? +I already have a django table containing all my objects. +Now my question is related to the design. I suspect the easiest way to achieve that is to have a POST request link in the QR code which will create a new entry in a table with the name of the object that has been picked or put back, the time (I would like to store this information). +If that's the correct way to do, how would you approach it? I'm not too sure I see how to make a POST request with a QR code. Would you have any idea? +Thanks. +PS: Another alternative I can think of would be to a link in the QR code to a form with a dummy button the user would click on. Once clicked the button would update the database. But I would fine a solution without any button more convenient...","The question boils down to a few choices: (a) what data do you want to encode into the QR code; (b) what app will you use to scan the QR code; and (c) how do you want the app to use / respond to the encoded data. +If you want your users to use off-the-shelf QR code readers (like free smartphone apps), then encoding a full URL to the appropriate API on your backend makes sense. Whether this should be a GET or POST depends on the QR code reader. I'd expect most to use GET, but you should verify that for your choice of app. That should be functionally fine, if you don't have any concerns about who should be able to scan the code. +If you want more control, e.g. you'd like to keep track of who scanned the code or other info not available to the server side just from a static URL request, you need a different approach. Something like, store the item ID (not URL) in the QR code; create your own simple QR code scanner app (many good examples exist) and add a little extra logic to that client, like requiring the user to log in with an ID + password, and build the URL dynamically from the item ID and the user ID. Many security variations possible (like JWT token) -- how you do that won't be dictated by the contents of the QR code. You could do a lot of other things in that QR code scanner / client, like add GPS location, ask the user to indicate why or where they're taking the item, etc. +So you can choose between a simple way with no controls, and a more complex way that would allow you to layer in whatever other controls and extra data you need.",1.2,True,1,5894 +2019-01-11 08:09:37.980,How can I read a file having different column for each rows?,"my data looks like this. +0 199 1028 251 1449 847 1483 1314 23 1066 604 398 225 552 1512 1598 +1 1214 910 631 422 503 183 887 342 794 590 392 874 1223 314 276 1411 +2 1199 700 1717 450 1043 540 552 101 359 219 64 781 953 +10 1707 1019 463 827 675 874 470 943 667 237 1440 892 677 631 425 +How can I read this file structure in python? I want to extract a specific column from rows. For example, If I want to extract value in the second row, second column, how can I do that? I've tried 'loadtxt' using data type string. But it requires string index slicing, so that I could not proceed because each column has different digits. Moreover, each row has a different number of columns. Can you guys help me? +Thanks in advance.","Use something like this to split it +split2=[] +split1=txt.split(""\n"") +for item in split1: + split2.append(item.split("" ""))",0.0,False,1,5895 +2019-01-11 11:02:30.650,How to align training and test set when using pandas `get_dummies` with `drop_first=True`?,"I have a data set from telecom company having lots of categorical features. I used the pandas.get_dummies method to convert them into one hot encoded format with drop_first=True option. Now how can I use the predict function, test input data needs to be encoded in the same way, as the drop_first=True option also dropped some columns, how can I ensure that encoding takes place in similar fashion. +Data set shape before encoding : (7043, 21) +Data set shape after encoding : (7043, 31)","When not using drop_first=True you have two options: + +Perform the one-hot encoding before splitting the data in training and test set. (Or combine the data sets, perform the one-hot encoding, and split the data sets again). +Align the data sets after one-hot encoding: an inner join removes the features that are not present in one of the sets (they would be useless anyway). train, test = train.align(test, join='inner', axis=1) + +You noted (correctly) that method 2 may not do what you expect because you are using drop_first=True. So you are left with method 1.",0.3869120172231254,False,1,5896 +2019-01-11 19:30:04.483,Python anytree application challenges with my jupyter notebook ​,"I am working in python 3.7.0 through a 5.6.0 jupyter notebook inside Anaconda Navigator 1.9.2 running in a windows 7 environment. It seems like I am assuming a lot of overhead, and from the jupyter notebook, python doesn’t see the anytree application module that I’ve installed. (Anytree is working fine with python from my command prompt.) +I would appreciate either 1) IDE recommendations or 2) advise as to how to make my Anaconda installation better integrated. +​","The core problem with my python IDE environment was that I could not utilize the functions in the anytree module. The anytree functions worked fine from the command prompt python, but I only saw error messages from any of the Anaconda IDE portals. +Solution: +1) From the windows start menu, I opened Anaconda Navigator, ""run as administrator."" +2) Select Environments. My application only has the single environment, “base”, +3.) Open selection “terminal”, and you then have a command terminal window in that environment. +4.) Execute [ conda install -c techtron anytree ] and the anytree module functions are now available. +5.) Execute [ conda update –n base –all ] and all the modules are updated to be current.",1.2,True,1,5897 +2019-01-12 03:01:39.153,How do I get VS Code to recognize modules in virtual environment?,"I set up a virtual environment in python 3.7.2 using ""python -m venv foldername"". I installed PIL in that folder. Importing PIL works from the terminal, but when I try to import it in VS code, I get an ImportError. Does anyone know how to get VS code to recognize that module? +I've tried switching interpreters, but the problem persists.","I ended up changing the python.venvpath setting to a different folder, and then moving the virtual env folder(The one with my project in it) to that folder. After restarting VS code, it worked.",0.0,False,1,5898 +2019-01-15 06:52:45.623,Good resources for video processing in Python?,"I am using the yolov3 model running on several surveillance cameras. Besides this I also run tensorflow models on these surveillaince streams. I feel a little lost when it comes to using anything but opencv for rtsp streaming. +So far I haven't seen people use anything but opencv in python. Are there any places I should be looking into. Please feel free to chime in. +Sorry if the question is a bit vague, but I really don't know how to put this better. Feel free to edit mods.",Of course are the alternatives to OpenCV in python if it comes to video capture but in my experience none of them preformed better,1.2,True,1,5899 +2019-01-15 06:54:00.607,Automate File loading from s3 to snowflake,"In s3 bucket daily new JSON files are dumping , i have to create solution which pick the latest file when it arrives PARSE the JSON and load it to Snowflake Datawarehouse. may someone please share your thoughts how can we achieve","There are some aspects to be considered such as is it a batch or streaming data , do you want retry loading the file in case there is wrong data or format or do you want to make it a generic process to be able to handle different file formats/ file types(csv/json) and stages. +In our case we have built a generic s3 to Snowflake load using Python and Luigi and also implemented the same using SSIS but for csv/txt file only.",0.0,False,1,5900 +2019-01-15 20:16:34.613,pythonnet clr is not recognized in jupyter notebook,"I have installed pythonnet to use clr package for a specific API, which only works with clr in python. Although in my python script (using command or regular .py files) it works without any issues, in jupyter notebook, import clr gives this error, ModuleNotFoundError: No module named 'clr'. Any idea how to address this issue?","since you are intended to use clr in jupyter, in jupyter cell, you could also +!pip install pythonnet for the first time and every later time if the vm is frequently nuked",0.0,False,2,5901 +2019-01-15 20:16:34.613,pythonnet clr is not recognized in jupyter notebook,"I have installed pythonnet to use clr package for a specific API, which only works with clr in python. Although in my python script (using command or regular .py files) it works without any issues, in jupyter notebook, import clr gives this error, ModuleNotFoundError: No module named 'clr'. Any idea how to address this issue?",Here is simple suggestion: compare sys.path in both cases and see the differences. Your ipython kernel in jupyter is probably searching in different directories than in normal python process.,1.2,True,2,5901 +2019-01-15 20:47:18.657,"Tried importing Java 8 JDK for PySpark, but PySpark still won't let me start a session","Ok here's my basic information before I go on: +MacBook Pro: OS X 10.14.2 +Python Version: 3.6.7 +Java JDK: V8.u201 +I'm trying to install the Apache Spark Python API (PySpark) on my computer. I did a conda installation: conda install -c conda-forge pyspark +It appeared that the module itself was properly downloaded because I can import it and call methods from it. However, opening the interactive shell with myuser$ pyspark gives the error: +No Java runtime present, requesting install. +Ok that's fine. I went to Java's download page to get the current JDK, in order to have it run, and downloaded it on Safari. Chrome apparently doesn't support certain plugins for it to work (although initially I did try to install it with Chrome). Still didn't work. +Ok, I just decided to start trying to use it. +from pyspark.sql import SparkSession It seemed to import the module correctly because it was auto recognizing SparkSession's methods. However, +spark = SparkSession.builder.getOrCreate() gave the error: +Exception: Java gateway process exited before sending its port number +Reinstalling the JDK doesn't seem to fix the issue, and now I'm stuck with a module that doesn't seem to work because of an issue with Java that I'm not seeing. Any ideas of how to fix this problem? Any and all help is appreciated.",This problem is coming with spark 2.4. please try spark 2.3.,0.0,False,1,5902 +2019-01-16 08:53:00.437,Install python packages offline on server,I want to install some packages on the server which does not access to internet. so I have to take packages and send them to the server. But I do not know how can I install them.,"Download the package from website and extract the tar ball. +run python setup.py install",-0.2012947653214861,False,1,5903 +2019-01-17 08:51:46.440,Dask: delayed vs futures and task graph generation,"I have a few basic questions on Dask: + +Is it correct that I have to use Futures when I want to use dask for distributed computations (i.e. on a cluster)? +In that case, i.e. when working with futures, are task graphs still the way to reason about computations. If yes, how do I create them. +How can I generally, i.e. no matter if working with a future or with a delayed, get the dictionary associated with a task graph? + +As an edit: +My application is that I want to parallelize a for loop either on my local machine or on a cluster (i.e. it should work on a cluster). +As a second edit: +I think I am also somewhat unclear regarding the relation between Futures and delayed computations. +Thx","1) Yup. If you're sending the data through a network, you have to have some way of asking the computer doing the computing for you how's that number-crunching coming along, and Futures represent more or less exactly that. +2) No. With Futures, you're executing the functions eagerly - spinning up the computations as soon as you can, then waiting for the results to come back (from another thread/process locally, or from some remote you've offloaded the job onto). The relevant abstraction here would be a Queque (Priority Queque, specifically). +3) For a Delayed instance, for instance, you could do some_delayed.dask, or for an Array, Array.dask; optionally wrap the whole thing in either dict() or vars(). I don't know for sure if it's reliably set up this way for every single API, though (I would assume so, but you know what they say about what assuming makes of the two of us...). +4) The simplest analogy would probably be: Delayed is essentially a fancy Python yield wrapper over a function; Future is essentially a fancy async/await wrapper over a function.",1.2,True,1,5904 +2019-01-19 00:00:55.483,Python how to get labels of a generated adjacency matrix from networkx graph?,"If i've an networkx graph from a python dataframe and i've generated the adjacency matrix from it. +So basically, how to get labels of that adjacency matrix ?","Assuming you refer to nodes' labels, networkx only keeps the the indices when extracting a graph's adjacency matrix. Networkx represents each node as an index, and you can add more attributes if you wish. All node's attributes except for the index are kept in a dictionary. When generating graph's adjacency matrix only the indices are kept, so if you only wish to keep a single string per node, consider indexing nodes by that string when generating your graph.",1.2,True,2,5905 +2019-01-19 00:00:55.483,Python how to get labels of a generated adjacency matrix from networkx graph?,"If i've an networkx graph from a python dataframe and i've generated the adjacency matrix from it. +So basically, how to get labels of that adjacency matrix ?","If the adjacency matrix is generated without passing the nodeList, then you can call G.nodes to obtain the default NodeList, which should correspond to the rows of the adjacency matrix.",-0.2012947653214861,False,2,5905 +2019-01-20 12:48:34.697,How to wait for some time between user inputs in tkinter?,"I am making a GUI program where the user can draw on a canvas in Tkinter. What I want to do is that I want the user to be able to draw on the canvas and when the user releases the Mouse-1, the program should wait for 1 second and clear the canvas. If the user starts drawing within that 1 second, the canvas should stay as it is. +I am able to get the user input fine. The draw function in my program is bound to B1-Motion. +I have tried things like inducing a time delay but I don't know how to check whether the user has started to draw again. +How do I check whether the user has started to draw again?","You can bind the mouse click event to a function that sets a bool to True or False, then using after to call a function after 1 second which depending on that bool clears the screen.",1.2,True,1,5906 +2019-01-21 21:13:07.617,Persistent Machine Learning,"I have a super basic machine learning question. I've been working through various tutorials and online classes on machine learning and the various techniques to learning how to use it, but what I'm not seeing is the persistent application piece. +So, for example, I train a network to recognize what a garden gnome looks like, but, after I run the training set and validate with test data, how do I persist the network so that I can feed it an individual picture and have it tell me whether the picture is of a garden gnome or not? Every tutorial seems to have you run through the training/validation sets without any notion as of how to host the network in a meaningful way for future use. +Thanks!",Use python pickle library to dump your trained model on your hard drive and load model and test for persistent results.,0.0,False,1,5907 +2019-01-21 23:31:10.607,Is it possible to extract an SSRS report embedded in the body of an email and export to csv?,"We currently are receiving reports via email (I believe they are SSRS reports) which are embedded in the email body rather than attached. The reports look like images or snapshots; however, when I copy and paste the ""image"" of a report into Excel, the column/row format is retained and it pastes into Excel perfectly, with the columns and rows getting pasted into distinct columns and rows accordingly. So it isn't truly an image, as there is a structure to the embedded report. +Right now, someone has to manually copy and paste each report into excel (step 1), then import the report into a table in SQL Server (step 2). There are 8 such reports every day, so the manual copy/pasting from the email into excel is very time consuming. +The question is: is there a way - any way - to automate step 1 so that we don't have to manually copy and paste each report into excel? Is there some way to use python or some other language to detect the format of the reports in the emails, and extract them into .csv or excel files? +I have no code to show as this is more of a question of - is this even possible? And if so, any hints as to how to accomplish it would be greatly appreciated.","The most efficient solution is to have the SSRS administrator (or you, if you have permissions) set the subscription to send as CSV. To change this in SSRS right click the report and then click manage. Select ""Subscriptions"" on the left and then click edit next to the subscription you want to change. Scroll down to Delivery Options and select CSV in the Render Format dropdown. Viola, you receive your report in the correct format and don't have to do any weird extraction.",0.0,False,1,5908 +2019-01-22 05:44:57.673,How to install sympy package in python,"I am a beginner to python, I wanted to symbolic computations. I came to know with sympy installation into our pc we can do symbolic computation. I have installed python 3.6 and I am using anaconda nagavitor, through which I am using spyder as an editor. now I want to install symbolic package sympy how to do that. +I checked some post which says use 'conda install sympy'. but where to type this? I typed this in spyder editor and I am getting syntax error. thankyou","To use conda install, open the Anaconda Prompt and enter the conda install sympy command. +Alternatively, navigate to the scripts sub-directory in the Anaconda directory, and run pip install sympy.",0.0,False,2,5909 +2019-01-22 05:44:57.673,How to install sympy package in python,"I am a beginner to python, I wanted to symbolic computations. I came to know with sympy installation into our pc we can do symbolic computation. I have installed python 3.6 and I am using anaconda nagavitor, through which I am using spyder as an editor. now I want to install symbolic package sympy how to do that. +I checked some post which says use 'conda install sympy'. but where to type this? I typed this in spyder editor and I am getting syntax error. thankyou","In anaconda navigator: + +Click Environments (on the left) +Choose your environment (if you have more than one) +On the middle pick ""All"" from dropbox (""installed"" by default) +Write sympy in search-box on the right +Check the package that showed out +Click apply",0.1352210990936997,False,2,5909 +2019-01-22 18:26:43.977,tkinter.root.destroy and cv2.imshow - X Windows system error,"I found this rather annoying bug and I couldn’t find anything other than a unanswered question on the opencv website, hopefully someone with more knowledge about the two libraries will be able to point me in the right direction. +I won’t provide code because that would be beside the point of learning what causes the crash. +If I draw a tkinter window and then root.destroy() it, trying to draw a cv2.imshow window will result in a X Window System error as soon as the cv2.waitKey delay is over. I’ve tried to replicate in different ways and it always gets to the error (error_code 3 request_code 15 minor_code 0). +It is worth noting that a root.quit() command won’t cause the same issue (as it is my understanding this method will simply exit the main loop rather than destroying the widgets). Also, while any cv2.imshow call will fail, trying to draw a new tkinter window will work just fine. +What resources are being shared among the two libraries? What does root.destroy() cause in the X environment to prevent any cv2 window to be drawn? +Debian Jessie - Python 3.4 - OpenCV 3.2.0","When you destroy the root window, it destroys all children windows as well. If cv2 uses a tkinter window or child window of the root window, it will fail if you destroy the root window.",0.0,False,1,5910 +2019-01-22 23:09:52.430,How do I use Pyinstaller to make a Mac file on Windows?,"I am on Windows and I am trying to figure how to use Pyinstaller to make a file (on Windows) for a Mac. +I have no trouble with Windows I am just not sure how I would make a file for another OS on it. +What I tried in cmd was: pyinstaller -F myfile.py and I am not sure what to change to make a Mac compatible file.",Not Possible without using a Virtual Machine,0.0,False,1,5911 +2019-01-23 03:02:55.387,Parsing list of URLs with regex patterns,"I have a large text file of URLs (>1 million URLs). The URLs represent product pages across several different domains. +I'm trying to parse out the SKU and product name from each URL, such as: + +www.amazon.com/totes-Mens-Mike-Duck-Boot/dp/B01HQR3ODE/ + + +totes-Mens-Mike-Duck-Boot +B01HQR3ODE + +www.bestbuy.com/site/apple-airpods-white/5577872.p?skuId=5577872 + + +apple-airpods-white +5577872 + + +I already have the individual regex patterns figured out for parsing out the two components of the URL (product name and SKU) for all of the domains in my list. This is nearly 100 different patterns. +While I've figured out how to test this one URL/pattern at a time, I'm having trouble figuring out how to architect a script which will read in my entire list, then go through and parse each line based on the relevant regex pattern. Any suggestions how to best tackle this? +If my input is one column (URL), my desired output is 4 columns (URL, domain, product_name, SKU).","While it is possible to roll this all into one massive regex, that might not be the easiest approach. Instead, I would use a two-pass strategy. Make a dict of domain names to the regex pattern that works for that domain. In the first pass, detect the domain for the line using a single regex that works for all URLs. Then use the discovered domain to lookup the appropriate regex in your dict to extract the fields for that domain.",0.2012947653214861,False,1,5912 +2019-01-24 09:30:09.097,Python Azure function processing blob storage,"I am trying to make a pipeline using Data Factory In MS Azure of processing data in blob storage and then running a python processing code/algorithm on the data and then sending it to another source. +My question here is, how can I do the same in Azure function apps? Or is there a better way to do it? +Thanks in advance. +Shyam",I created a Flask API and called my python code through that. And then put it in Azure as a web app and called the blob.,0.0,False,1,5913 +2019-01-24 11:46:02.647,Django Admin Interface - Privileges On Development Server,"I have an old project running (Django 1.6.5, Python 2.7) live for several years. I have to make some changes and have set up a working development environment with all the right django and python requirements (packages, versions, etc.) +Everything is running fine, except when I am trying to make changes inside the admin panel. I can log on fine and looking at the database (sqlite3) I see my user has superuser privileges. However django says ""You have no permissions to change anything"" and thus not even displaying any of the models registered for the admin interface. +I am using the same database that is running on the live server. There I have no issues at all (Live server also running in development mode with DEBUG=True has no issues) -> I can only see the history (My Change Log) - Nothing else +I have also created a new superuser - but same problem here. +I'd appreciate any pointers (Maybe how to debug this?)","Finally, I found the issue: +admin.autodiscover() +was commented out in the project's urls.py for some reason. (I may have done that trying to get the project to work in a more recent version of django) - So admin.site.register was never called and the app_dict never filled. index.html template of django.contrib.admin then returns + +You don't have permission to edit anything. + +or it's equivalent translation (which I find confusing, given that the permissions are correct, only no models were added to the admin dictionary. +I hope this may help anyone running into a similar problem",0.0,False,1,5914 +2019-01-24 19:31:18.407,How to handle EULA pop-up window that appears only on first login?,"I am new to Selenium. The web interface of our product pops up a EULA agreement which the user has to scroll down and accept before proceeding. This happens ONLY on initial login using that browser for that user. +I looked at the Selenium API but I am unable to figure out which one to use and how to use it. +Would much appreciate any suggestions in this regard. +I have played around with the IDE for Chrome but even over there I don't see anything that I can use for this. I am aware there is an 'if' command but I don't know how to use it to do something like: +if EULA-pops-up: + Scroll down and click 'accept' +proceed with rest of test.","You may disable the EULA if that is an option for you, I am sure there is a way to do it in registries as well : +C:\Program Files (x86)\Google\Chrome\Application there should be a file called master_preferences. +Open the file and setting: +require_eula to false",0.0,False,1,5915 +2019-01-25 09:21:41.077,Predicting values using trained MNB Classifier,"I am trying to train a model for sentiment analysis and below is my trained Multinomial Naive Bayes Classifier returning an accuracy of 84%. +I have been unable to figure out how to use the trained model to predict the sentiment of a sentence. For example, I now want to use the trained model to predict the sentiment of the phrase ""I hate you"". +I am new to this area and any help is highly appreciated.","I don't know the dataset and what is semantic of individual dictionaries, but you are training your model on a dataset which has form as follows: +[[{""word"":True, ""word2"": False}, 'neg'], [{""word"":True, ""word2"": False}, 'pos']] + +That means your input is in form of a dictionary, and output in form of 'neg' label. If you want to predict you need to input a dictionary in a form: + +{""I"": True, ""Hate"": False, ""you"": True}. + +Then: + +MNB_classifier.classify({""love"": True}) +>> 'neg' +or +MNB_classifier.classify_many([{""love"": True}]) +>> ['neg']",1.2,True,1,5916 +2019-01-25 11:29:23.027,Deliver python external libraries with script,"I want to use my script that uses pandas library on another linux machine where is no internet access or pip installed. +Is there a way how to deliver the script with all dependencies? +Thanks",or set needed dependices in script manually by appending sys.modules and pack together all the needed files.,0.0,False,1,5917 +2019-01-26 14:14:21.693,importing an entire folder of .py files into google colab,"I have a folder of . py files(a package made by me) which i have uploaded into my google drive. +I have mounted my google drive in colab but I still can not import the folder in my notebook as i do in my pc. +I know how to upload a single .py file into google colab and import it into my code, but i have no idea about how to upload a folder of .py files and import it in notebook and this is what i need to do. +This is the code i used to mount drive: + +from google.colab import drive +drive.mount('/content/drive') +!ls 'drive/My Drive'","I found how to do it. +after uploading all modules and packages into the directory which my notebook file is in, I changed colab's directory from ""/content"" to this directory and then i simply imported the modules and packages(folder of .py files) into my code",1.2,True,1,5918 +2019-01-27 06:38:41.497,How to redirect -progress option output of ffmpeg to stderr?,"I'm writing my own wraping for ffmpeg on Python 3.7.2 now and want to use it's ""-progress"" option to read current progress since it's highly machine-readable. The problem is ""-progress"" option of ffmpeg accepts as its parameter file names and urls only. But I don't want to create additional files not to setup the whole web-server for this purpose. +I've google a lot about it, but all the ""progress bars for ffmpeg"" projects rely on generic stderr output of ffmpeg only. Other answers here on Stackoverflow and on Superuser are being satisfied with just ""-v quiet -stats"", since ""progress"" is not very convenient name for parameter to google exactly it's cases. +The best solution would be to force ffmpeg write it's ""-progress"" output to separate pipe, since there is some useful data in stderr as well regarding file being encoded and I don't want to throw it away with ""-v quiet"". Though if there is a way to redirect ""-progress"" output to stderr, it would be cool as well! Any pipe would be ok actually, I just can't figure out how to make ffmpeg write it's ""-progress"" not to file in Windows. I tried ""ffmpeg -progress stderr ..."", but it just create the file with this name.","-progress pipe:1 will write out to stdout, pipe:2 to stderr. If you aren't streaming from ffmpeg, use stdout.",1.2,True,1,5919 +2019-01-28 14:38:40.990,How can I check how often all list elements from a list B occur in a list A?,"I have a python list A and a python list B with words as list elements. I need to check how often the list elements from list B are contained in list A. Is there a python method or how can I implement this efficient? +The python intersection method only tells me that a list element from list B occurs in list A, but not how often.","You could convert list B to a set, so that checking if the element is in B is faster. +Then create a dictionary to count the amount of times that the element is in A if the element is also in the set of B +As mentioned in the comments collections.Counter does the ""heavy lifting"" for you",0.0,False,1,5920 +2019-01-29 07:42:00.640,Can't install packages via pip or npm,"I'm trying to install some packages globally on my Mac. But I'm not able to install them via npm or pip, because I'll always get the message that the packages does not exist. For Python, I solved this by always using a virtualenv. But now I'm trying to install the @vue/cli via npm, but I'm not able to access it. The commands are working fine, but I'm just not able to access it. I think it has something to do with my $PATH, but I don't know how to fix that. +If I look in my Finder, I can find the @vue folder in /users/.../node_modules/. Does someone know how I can access this folder with the vue command in Terminal?","If it's a PATH problem: +1) Open up Terminal. +2) Run the following command: +sudo nano /etc/paths +3) Enter your password, when prompted. +4) Check if the correct paths exist in the file or not. +5) Fix, if needed +6) Hit Control-X to quit. +7) Enter “Y” to save the modified buffer. +Everything, should work fine now. If it doesn't try re-installing NPM/PIP.",1.2,True,1,5921 +2019-01-31 10:19:40.180,"How to get disk space total, used and free using Python 2.7 without PSUtil","Is there a way I get can the following disk statistics in Python without using PSUtil? + +Total disk space +Used disk space +Free disk space + +All the examples I have found seem to use PSUtil which I am unable to use for this application. +My device is a Raspberry PI with a single SD card. I would like to get the total size of the storage, how much has been used and how much is remaining. +Please note I am using Python 2.7.",You can do this with the os.statvfs function.,0.2012947653214861,False,1,5922 +2019-02-01 14:09:13.800,How can a same entity function as a parameter as well as an object?,"In the below operation, we are using a as an object as well as an argument. +a = ""Hello, World!"" + +print(a.lower()) -> a as an object +print(len(a)) -> a as a parameter + +May I know how exactly each operations differs in the way they are accessing a?","Everything in python (everything that can go on the rhs of an assignment) is an object, so what you can pass as an argument to a function IS an object, always. Actually, those are totally orthogonal concepts: you don't ""use"" something ""as an object"" - it IS an object - but you can indeed ""use it"" (pass it) as an argument to a function / method / whatever callable. + +May I know how exactly each operations differs in the way they are accessing a? + +Not by much actually (except for the fact they do different things with a)... +a.lower() is only syntactic sugar for str.lower(a) (obj.method() is syntactic sugar for type(obj).method(obj), so in both cases you are ""using a as an argument"".",0.3869120172231254,False,1,5923 +2019-02-02 02:41:43.413,Loading and using a trained TensorFlow model in Python,"I trained a model in TensorFlow using the tf.estimator API, more specifically using tf.estimator.train_and_evaluate. I have the output directory of the training. How do I load my model from this and then use it? +I have tried using the tf.train.Saver class by loading the most recent ckpt file and restoring the session. However, then to call sess.run() I need to know what the name of the output node of the graph is so I can pass this to the fetches argument. What is the name/how can I access this output node? Is there a better way to load and use the trained model? +Note that I have already trained and saved the model in a ckpt file, so please do not suggest that I use the simple_save function.","(Answering my own question) I realized that the easiest way to do this was to use the tf.estimator API. By initializing an estimator that warm starts from the model directory, it's possible to just call estimator.predict and pass the correct args (predict_fn) and get the predictions immediately. It's not required to deal with the graph variables in any way.",0.0,False,1,5924 +2019-02-02 08:14:24.520,Best way to map words with multiple spellings to a list of key words?,"I have a pile of ngrams of variable spelling, and I want to map each ngram to it's best match word out of a list of known desired outputs. +For example, ['mob', 'MOB', 'mobi', 'MOBIL', 'Mobile] maps to a desired output of 'mobile'. +Each input from ['desk', 'Desk+Tab', 'Tab+Desk', 'Desktop', 'dsk'] maps to a desired output of 'desktop' +I have about 30 of these 'output' words, and a pile of about a few million ngrams (much fewer unique). +My current best idea was to get all unique ngrams, copy and paste that into Excel and manually build a mapping table, took too long and isn't extensible. +Second idea was something with fuzzy (fuzzy-wuzzy) matching but it didn't match well. +I'm not experienced in Natural Language terminology or libraries at all so I can't find an answer to how this might be done better, faster and more extensibly when the number of unique ngrams increases or 'output' words change. +Any advice?","The classical approach would be, to build a ""Feature Matrix"" for each ngram. Each word maps to an Output which is a categorical value between 0 and 29 (one for each class) +Features can for example be the cosine similarity given by fuzzy wuzzy but typically you need many more. Then you train a classification model based on the created features. This model can typically be anything, a neural network, a boosted tree, etc.",0.1352210990936997,False,1,5925 +2019-02-04 21:09:00.383,Use VRAM (graphics card memory) in pygame for images,"I'm programming a 2D game with Python and Pygame and now I want to use my internal graphics memory to load images to. +I have an Intel HD graphics card (2GB VRAM) and a Nvidia GeForce (4GB VRAM). +I want to use one of them to load images from the hard drive to it (to use the images from there). +I thought it might be a good idea as I don't (almost) need the VRAM otherwise. +Can you tell me if and how it is possible? I do not need GPU-Acceleration.","You have to create your window with the FULLSCREEN, DOUBLEBUF and HWSURFACE flags. +Then you can create and use a hardware surface by creating it with the HWSURFACE flag. +You'll also have to use pygame.display.flip() instead of pygame.display.update(). +But even pygame itself discourages using hardware surfaces, since they have a bunch of disadvantages, like +- no mouse cursor +- only working in fullscreen (at least that's what pygame's documentation says) +- you can't easily manipulate the surfaces +- they may not work on all platforms +(and I never got transparency to work with them). +And it's not even clear if you really get a notable performance boot. +Maybe they'll work better in a future pygame release when pygame switches to SDL 2 and uses SDL_TEXTURE instead of SDL_HWSURFACE, who knows....",1.2,True,1,5926 +2019-02-05 02:42:03.343,Installed Anaconda to macOS that has Python2.7 and 3.7. Pandas only importing to 2.7; how can I import to 3.7?,"New to coding; I just downloaded the full Anaconda package for Python 3.7 onto my Mac. However, I can't successfully import Pandas into my program on SublimeText when running my Python3.7 build. It DOES work though, when I change the build to Python 2.7. Any idea how I can get it to properly import when running 3.7 on SublimeText? I'd just like to be able to execute the code within Sublime. +Thanks!","Uninstall python 2.7. Unless you use it, its better to uninstall it.",0.0,False,1,5927 +2019-02-05 12:40:24.703,How to check learning feasibility on a binary classification problem with Hoeffding's inequality/VC dimension with Python?,"I have a simple binary classification problem, and I want to assess the learning feasibility using Hoeffding's Inequality and also if possible VC dimension. +I understand the theory but, I am still stuck on how to implement it in Python. +I understand that In-sample Error (Ein) is the training Error. Out of sample Error(Eout) is the error on the test subsample I guess. +But how do I plot the difference between these two errors with the Hoeffdings bound?","Well here is how I handled it : I generate multiple train/test samples, run the algorithm on them, calculate Ein as the train set error, Eout estimated by the test set error, calculate how many times their differnces exceeds the value of epsilon (for a range of epsilons). And then I plot the curve of these rates of exceeding epsilon and the curve of the right side of the Hoeffding's /VC inequality so I see if the differences curve is always under the Hoeffding/VC's Bound curve, this informs me about the learning feasiblity.",1.2,True,1,5928 +2019-02-06 20:20:54.933,python keeps saying that 'imput is undefined. how do I fix this?,"Please help me with this. I'd really appreciate it. I have tried alot of things but nothing is working, Please suggest any ideas you have. +This is what it keeps saying: + name = imput('hello') +NameError: name 'imput' is not defined","You misspelled input as imput. imput() is not a function that python recognizes - thus, it assumes it's the name of some variable, searches for wherever that variable was declared, and finds nothing. So it says ""this is undefined"" and raises an error.",1.2,True,1,5929 +2019-02-07 02:36:18.047,Understanding each component of a web application architecture,"Here is a scenario for a system where I am trying to understand what is what: +I'm Joe, a novice programmer and I'm broke. I've got a Flask app and one physical machine. Since I'm broke, I cannot afford another machine for each piece of my system, thus the web server, application and database all live on my one machine. +I've never deployed an app before, but I know that a server can refer to a machine or software. From here on, lets call the physical machine the Rack. I've loaded an instance of MongoDB on my machine and I know that is the Database Server. In order to handle API requests, I need something on the rack that will handle HTTP/S requests, so I install and run an instance of NGINX on it and I know that this is the Web Server. However, my web server doesnt know how to run the app, so I do some research and learn about WSGI and come to find out I need another component. So I install and run an instance of Gunicorn and I know that this is the WSGI Server. +At this point I have a rack that is home to a web server to handle API calls (really just acts as a reverse proxy and pushes requests to the WSGI server), a WSGI server that serves up dynamic content from my app and a database server that stores client information used by the app. +I think I've got my head on straight, then my friend asks ""Where is your Application Server?"" +Is there an application server is this configuration? Do I need one?","Any basic server architecture has three layers. On one end is the web server, which fulfills requests from clients. The other end is the database server, where the data resides. +In between these two is the application server. It consists of the business logic required to interact with the web server to receive the request, and then with the database server to perform operations. +In your configuration, the WSGI serve/Flask app is the application server. +Most application servers can double up as web servers.",0.0,False,1,5930 +2019-02-07 04:21:01.713,How keras model H5 works in theory,After training the trained model will be saved as H5 format. But I didn't know how that H5 file can be used as classifier to classifying new data. How H5 model works in theory when classifying new data?,"When you save your model as h5-file, you save the model structure, all its parameters and further informations like state of your optimizer and so on. It is just an efficient way to save huge amounts of information. You could use json or xml file formats to do this as well. +You can't classifiy anything only using this file (it is not executable). You have to rebuild the graph as a tensorflow graph from this file. To do so you simply use the load_model() function from keras, which returns a keras.models.Model object. Then you can use this object to classifiy new data, with keras predict() function.",0.2012947653214861,False,1,5931 +2019-02-07 19:36:54.707,Using pyautogui with multiple monitors,"I'm trying to use the pyautogui module for python to automate mouse clicks and movements. However, it doesn't seem to be able to recognise any monitor other than my main one, which means i'm not able to input any actions on any of my other screens, and that is a huge problem for the project i am working on. +I've searched google for 2 hours but i can't find any straight answers on whether or not it's actually possible to work around. If anyone could either tell me that it is or isn't possible, tell me how to do it if it is, or suggest an equally effective alternative (for python) i would be extremely grateful.",not sure if this is clear but I subtracted an extended monitor's horizontal resolution from 0 because my 2nd monitor is on the left of my primary display. That allowed me to avoid the out of bounds warning. my answer probably isn't the clearest but I figured I would chime in to let folks know it actually can work.,0.0,False,1,5932 +2019-02-07 21:14:35.190,How to encrypt(?) a document to prove it was made at a certain time?,"So, a bit of a strange question, but let's say that I have a document (jupyter notebook) and I want to be able to prove to someone that it was made before a certain date, or that it was created on a certain date - does anyone have any ideas as to how I'd achieve that? +It would need to be a solution that couldn't be technically re-engineered after the fact (faking the creation date). +Keen to hear your thoughts :) !","email it to yourself or a trusted party – dandavis yesterday +Good solution. +Thanks!",0.0,False,1,5933 +2019-02-08 03:38:25.450,How to reset Colab after the following CUDA error 'Cuda assert fails: device-side assert triggered'?,"I'm running my Jupyter Notebook using Pytorch on Google Colab. After I received the 'Cuda assert fails: device-side assert triggered' I am unable to run any other code that uses my pytorch module. Does anyone know how to reset my code so that my Pytorch functions that were working before can still run? +I've already tried implementing CUDA_LAUNCH_BLOCKING=1but my code still doesn't work as the Assert is still triggered!","You need to reset the Colab notebook. To run existing Pytorch modules that used to work before, you have to do the following: + +Go to 'Runtime' in the tool bar +Click 'Restart and Run all' + +This will reset your CUDA assert and flush out the module so that you can have another shot at avoiding the error!",1.2,True,1,5934 +2019-02-08 07:38:41.967,How change hostpython for use python3 on MacOS for compile Python+Kivy project for Xcode,"I use toolchain from Kivy for compile Python + Kivy project on MacOS, but by default, toolchain use python2 recipes but I need change to python3. +I´m googling but I don't find how I can do this. +Any idea? +Thanks","For example, recipe ""ios"" and ""pyobjc"" dependency is changed from depends = [""python""] to depends = [""python3""]. (__init__.py in each packages in receipe folder in kivy-ios package) +These recipes are loaded from your request implicitly or explicitly +This description of the problem recipes is equal to require hostpython2/python2. then conflict with python3. +The dependency of each recipe can be traced from output of kivy-ios. ""hostpython"" or ""python"" in output(console) were equaled to hostpython2 or python2.(now ver.)",0.0,False,2,5935 +2019-02-08 07:38:41.967,How change hostpython for use python3 on MacOS for compile Python+Kivy project for Xcode,"I use toolchain from Kivy for compile Python + Kivy project on MacOS, but by default, toolchain use python2 recipes but I need change to python3. +I´m googling but I don't find how I can do this. +Any idea? +Thanks","your kivy installation is likely fine already. Your kivy-ios installation is not. Completely remove your kivy-ios folder on your computer, then do git clone git://github.com/kivy/kivy-ios to reinstall kivy-ios. Then try using toolchain.py to build python3 instead of python 2 +This solution work for me. Thanks very much Erik.",1.2,True,2,5935 +2019-02-09 15:50:20.647,How to reach streaming learning in Neural network?,"As title, I know there're some model supporting streaming learning like classification model. And the model has function partial_fit() +Now I'm studying regression model like SVR and RF regressor...etc in scikit. +But most of regression models doesn't support partial_fit . +So I want to reach the same effect in neural network. If in tensorflow, how to do like that? Is there any keyword?","There is no some special function for it in TensorFlow. You make a single training pass over a new chunk of data. And then another training pass over another new chunk of data, etc till you reach the end of the data stream (which, hopefully, will never happen).",0.0,False,1,5936 +2019-02-10 09:38:54.947,How to pickle or save a WxPython FontData Object,"I've been coding a text editor, and it has the function to change the default font displayed in the wx.stc.SyledTextCtrl. +I would like to be able to save the font as a user preference, and I have so far been unable to save it. +The exact object type is . +Would anyone know how to pickle/save this?","Probably due to its nature, you cannot pickle a wx.Font. +Your remaining option is to store its constituent parts. +Personally, I store facename, point size, weight, slant, underline, text colour and background colour. +How you store them is your own decision. +I use 2 different options depending on the code. + +Store the entries in an sqlite3 database, which allows for multiple +indexed entries. +Store the entries in an .ini file using +configobj + +Both sqlite3 and configobj are available in the standard python libraries.",1.2,True,1,5937 +2019-02-10 09:51:41.193,how to decode gzip string in JS,"I have one Django app and in the view of that I am using gzip_str(str) method to compress data and send back to the browser. Now I want to get the original string back in the browser. How can I decode the string in JS. +P.S. I have found few questions here related to the javascript decode of gzip string but I could not figure out how to use those. Please tell me how can I decode and get the original string.","Serve the string with an appropriate Content-Encoding, then the browser will decode it for you.",0.0,False,1,5938 +2019-02-10 15:03:18.307,How to remove unwanted python packages from the Base environment in Anaconda,"I am using Anaconda. I would like to know how to remove or uninstall unwanted packages from the base environment. I am using another environment for my coding purpose. +I tried to update my environment by using yml file (Not base environment). Unexpectedly some packages installed by yml into the base environment. So now it has 200 python packages which have another environment also. I want to clear unwanted packages in the base environment and I am not using any packages in the base environment. Also, my memory is full because of this. +Please give me a solution to remove unwanted packages in the base environment in anaconda. +It is very hard to remove one by one each package, therefore, I am looking for a better solution.","Please use the below code: +conda uninstall -n base ",0.0,False,1,5939 +2019-02-11 00:05:55.277,Pythonic way to split project into modules?,"Say, there is a module a which, among all other stuff, exposes some submodule a.b. +AFAICS, it is desired to maintain modules in such a fashion that one types import a, import a.b and then invokes something b-specific in a following way: a.b.b_specific_function() or a.a_specific_function(). +The questions I'd like to ask is how to achive such effect? +There is directory a and there is source-code file a.py inside of it. Seems to be logical choice, thought it would look like import a.a then, rather than import a. The only way I see is to put a.py's code to the __init__.py in the a directory, thought it is definitely wrong... +So how do I keep my namespaces clean?",You can put the code into __init__.py. There is nothing wrong with this for a small subpackage. If the code grows large it is also common to have a submodule with a repeated name like a/a.py and then inside __init__.py import it using from .a import *.,1.2,True,1,5940 +2019-02-11 11:28:57.127,Fastest way in numpy to sum over upper triangular elements with the least memory,"I need to perform a summation of the kind i Configure IDLE => Settings => Highlights there is a highlight setting for builtin names (default purple), including a few non-functions like Ellipsis. There is another setting for the names in def (function) and class statements (default blue). You can make def (and class) names be purple also. +This will not make function names purple when used because the colorizer does not know what the name will be bound to when the code is run.",1.2,True,1,5949 +2019-02-17 13:30:30.583,Count number of Triggers in a given Span of Time,"I've been working for a while with some cheap PIR modules and a raspberry pi 3. My aim is to use 4 of these guys to understand if a room is empty, and turn off some lights in case. +Now, this lovely sensors aren't really precise. They false trigger from time to time, and they don't trigger right after their status has changed, and this makes things much harder. +I thought I could solve the problem measuring a sort of ""density of triggers"", meaning how many triggers occurred during the last 60 seconds or something. +My question is how could I implement effectively this solution? I thought to build a sort of container and fill it with elements with a timer or something, but I'm not really sure this would do the trick. +Thank you!",How are you powering PIR sensors? They should be powered with 5V. I had similar problem with false triggers when I was powered PIR sensor with only 3.3V.,0.0,False,1,5950 +2019-02-18 02:33:10.543,"While debugging in pycharm, how to debug only through a certain iteration of the for loop?","I have a for loop in Python in Pycharm IDE. I have 20 iterations of the for loop. However, the bug seems to be coming from the dataset looped during the 18th iteration. Is it possible to skip the first 17 values of the for loop, and solely jump to debug the 18th iteration? +Currently, I have been going through all 17 iterations to reach the 18th. The logic encompassed in the for loop is quite intricate and long. Hence, every cycle of debug through each iteration takes a very long. +Is there some way to skip to the desired iteration in Pycharm without going in in-depth debugging of the previous iterations?",You can set a break point with a condition (i == 17 [right click on the breakpoint to put it]) at the start of the loop.,-0.1352210990936997,False,1,5951 +2019-02-18 17:11:25.750,How to evaluate the path to a python script to be executed within Jupyter Notebook,"Note: I am not simply asking how to execute a Python script within Jupyter, but how to evaluate a python variable which would then result in the full path of the Python script I was to execute. +In my particular scenario, some previous cell on my notebook generates a path based on some condition. +Example on two possible cases: + +script_path = /project_A/load.py +script_path = /project_B/load.py + +Then some time later, I have a cell where I just want to execute the script. Usually, I would just do: +%run -i /project_A/load.py +but I want to keep the cell's code generic by doing something like: +%run -i script_path +where script_path is a Python variable whose value is based on the conditions that are evaluated earlier in my Jupyter notebook. +The above would not work because Jupyter would then complain that it cannot find script_path.py. +Any clues how I can have a Python variable passed to the %run magic?","One hacky way would be to change the directory via %cd path +and then run the script with %run -i file.py +E: I know that this is not exactly what you were asking but maybe it helps with your problem.",0.0,False,1,5952 +2019-02-19 09:11:19.870,How to use pretrained word2vec vectors in doc2vec model?,"I am trying to implement doc2vec, but I am not sure how the input for the model should look like if I have pretrained word2vec vectors. +The problem is, that I am not sure how to theoretically use pretrained word2vec vectors for doc2vec. I imagine, that I could prefill the hidden layer with the vectors and the rest of the hidden layer fill with random numbers +Another idea is to use the vector as input for word instead of a one-hot-encoding but I am not sure if the output vectors for docs would make sense. +Thank you for your answer!","You might think that Doc2Vec (aka the 'Paragraph Vector' algorithm of Mikolov/Le) requires word-vectors as a 1st step. That's a common belief, and perhaps somewhat intuitive, by analogy to how humans learn a new language: understand the smaller units before the larger, then compose the meaning of the larger from the smaller. +But that's a common misconception, and Doc2Vec doesn't do that. +One mode, pure PV-DBOW (dm=0 in gensim), doesn't use conventional per-word input vectors at all. And, this mode is often one of the fastest-training and best-performing options. +The other mode, PV-DM (dm=1 in gensim, the default) does make use of neighboring word-vectors, in combination with doc-vectors in a manner analgous to word2vec's CBOW mode – but any word-vectors it needs will be trained-up simultaneously with doc-vectors. They are not trained 1st in a separate step, so there's not a easy splice-in point where you could provide word-vectors from elsewhere. +(You can mix skip-gram word-training into the PV-DBOW, with dbow_words=1 in gensim, but that will train word-vectors from scratch in an interleaved, shared-model process.) +To the extent you could pre-seed a model with word-vectors from elsewhere, it wouldn't necessarily improve results: it could easily send their quality sideways or worse. It might in some lucky well-managed cases speed model convergence, or be a way to enforce vector-space-compatibility with an earlier vector-set, but not without extra gotchas and caveats that aren't a part of the original algorithms, or well-described practices.",1.2,True,1,5953 +2019-02-21 02:24:51.223,How to convert every other character in a string to ascii in Python?,"I know how to convert characters to ascii and stuff, and I'm making my first encryption algorithm just as a little fun project, nothing serious. I was wondering if there was a way to convert every other character in a string to ascii, I know this is similar to some other questions but I don't think it's a duplicate. Also P.S. I'm fairly new to Python :)",Use ord() function to get ascii value of a character. You can then do a chr() of that value to get the character.,0.0,False,1,5954 +2019-02-21 05:36:13.653,Run python script by PHP from another server,"I am making APIs. +I'm using CentOS for web server, and another windows server 2016 for API server. +I'm trying to make things work between web server and window server. +My logic is like following flow. +1) Fill the data form and click button from web server +2) Send data to windows server +3) Python script runs and makes more data +4) More made data must send back to web server +5) Web server gets more made datas +6) BAMM! Datas append on browser! +I had made python scripts. +but I can't decide how to make datas go between two servers.. +Should I use ajax Curl in web server? +I was planning to send a POST type request by Curl from web server to Windows server. +But I don't know how to receipt those datas in windows server. +Please help! Thank you in advance.","First option: (Recommended) +You can create the python side as an API endpoint and from the PHP server, you need to call the python API. +Second option: +You can create the python side just like a normal webpage and whenever you call that page from PHP server you pass the params along with HTTP request, and after receiving data in python you print the data in JSON format.",1.2,True,1,5955 +2019-02-21 11:00:17.487,Kivy Android App - Switching screens with a swipe,"Every example I've found thus-far for development with Kivy in regards to switching screens is always done using a button, Although the user experience doesn't feel very ""native"" or ""Smooth"" for the kind of app I would like to develop. +I was hoping to incorperate swiping the screen to change the active screen. +I can sort of imagine how to do this by tracking the users on_touch_down() and on_touch_up() cords (spos) and if the difference is great enough, switch over to the next screen in a list of screens, although I can't envision how this could be implemented within the kv language +perhaps some examples could help me wrap my head around this better? +P.S. +I want to keep as much UI code within the kv language file as possible to prevent my project from producing a speghetti-code sort of feel to it. I'm also rather new to Kivy development altogether so I appologize if this question has an official answer somewhere and I just missed it.","You might want to use a Carousel instead of ScreenManager, but if you want that logic while using the ScreenManager, you'll certainly have to write some python code to manage that in a subclass of it, then use it in kv as a normal ScreenManager. Using previous and next properties to get the right screen to switch to depending on the action. This kind of logic is better done in python, and that doesn't prevent using the widgets in kv after.",1.2,True,1,5956 +2019-02-21 14:37:29.177,is it possible to code in python inside android studio?,"is it possible to code in python inside android studio? +how can I do it. +I have an android app that I am try to develop. and I want to code some part in python. +Thanks for the help +how can I do it. +I have an android app that I am try to develop. and I want to code some part in python. +Thanks for the help","If you mean coding part of your Android application in python (and another part for example in Java) it's not possible for now. However, you can write Python script and include it in your project, then write in your application part that will invoke it somehow. Also, you can use Android Studio as a text editor for Python scripts. To develop apps for Android in Python you have to use a proper library for it.",1.2,True,1,5957 +2019-02-22 09:08:55.793,"How to create .cpython-37 file, within __pycache__","I'm working on a project with a few scripts in the same directory, a pychache folder has been created within that directory, it contains compiled versions of two of my scripts. This has happened by accident I do not know how I did it. One thing I do know is I have imported functions between the two scripts that have been compiled. +I would like a third compiled python script for a separate file however I do not want to import any modules(if this is even the case). Does anyone know how I can manually create a .cpython-37 file? Any help is appreciated.","There is really no reason to worry about __pycache__ or *.pyc files - these are created and managed by the Python interpreter when it needs them and you cannot / should not worry about manually creating them. They contain a cached version of the compiled Python bytecode. Creating them manually makes no sense (and I am not aware of a way to do that), and you should probably let the interpreter decide when it makes sense to cache the bytecode and when it doesn't. +In Python 3.x, __pycache__ directories are created for modules when they are imported by a different module. AFAIK Python will not create a __pycache__ entry when a script is ran directly (e.g. a ""main"" script), only when it is imported as a module.",1.2,True,1,5958 +2019-02-22 10:05:07.620,Install python packages in windows server 2016 which has no internet connection,"I need to install python packages in a windows server 2016 sandbox for running a developed python model in production.This doesn't have internet connection. +My laptop is windows 2010 and the model is now running in my machine and need to push this to the server. +My question is how can i install all the required packages in my server which has no internet connection. +Thanks +Mithun","A simply way is to install the same python version on another machine having internet access, and use normally pip on that machine. This will download a bunch of files and installs them cleanly under Lib\site_packages of your Python installation. +You can they copy that folder to the server Python installation. If you want to be able to later add packages, you should keep both installations in sync: do not add or remove any package on the laptop without syncing with the server.",0.0,False,1,5959 +2019-02-22 18:47:07.843,How to write unit tests for text parser?,"For background, I am somewhat of a self-taught Python developer with only some formal training with a few CS courses in school. +In my job right now, I am working on a Python program that will automatically parse information from a very large text file (thousands of lines) that's a output result of a simulation software. I would like to be doing test driven development (TDD) but I am having a hard time understanding how to write proper unit tests. +My trouble is, the output of some of my functions (units) are massive data structures that are parsed versions of the text file. I could go through and create those outputs manually and then test but it would take a lot of time. The whole point of a parser is to save time and create structured outputs. Only testing I've been doing so far is trial and error manually which is also cumbersome. +So my question is, are there more intuitive ways to create tests for parsers? +Thank you in advance for any help!","Usually parsers are tested using a regression testing system. You create sample input sets and verify that the output is correct. Then you put the input and output in libraries. Each time you modify the code, you run the regression test system over the library to see if anything changes.",0.6730655149877884,False,1,5960 +2019-02-22 20:17:16.640,Specific reasons to favor pip vs. conda when installing Python packages,"I use miniconda as my default python installation. What is the current (2019) wisdom regarding when to install something with conda vs. pip? +My usual behavior is to install everything with pip, and only using conda if a package is not available through pip or the pip version doesn't work correctly. +Are there advantages to always favoring conda install? Are there issues associated with mixing the two installers? What factors should I be considering? + +OBJECTIVITY: This is not an opinion-based question! My question is when I have the option to install a python package with pip or conda, how do I make an informed decision? Not ""tell me which is better, but ""Why would I use one over the other, and will oscillating back & forth cause problems / inefficiencies?""","This is what I do: + +Activate your conda virutal env +Use pip to install into your virtual env +If you face any compatibility issues, use conda + +I recently ran into this when numpy / matplotlib freaked out and I used the conda build to resolve the issue.",0.3275988531455109,False,1,5961 +2019-02-24 14:21:54.997,how can I use python 3.6 if I have python 3.7?,"I'm trying to make a discord bot, and I read that I need to have an older version of Python so my code will work. I've tried using ""import discord"" on IDLE but an error message keeps on coming up. How can I use Python 3.6 and keep Python 3.7 on my Windows 10 computer?","Install in different folder than your old Python 3.6 then update path +Using Virtualenv and or Pyenv +Using Docker + +Hope it help!",0.0,False,2,5962 +2019-02-24 14:21:54.997,how can I use python 3.6 if I have python 3.7?,"I'm trying to make a discord bot, and I read that I need to have an older version of Python so my code will work. I've tried using ""import discord"" on IDLE but an error message keeps on coming up. How can I use Python 3.6 and keep Python 3.7 on my Windows 10 computer?","Just install it in different folder (e.g. if current one is in C:\Users\noob\AppData\Local\Programs\Python\Python37, install 3.6. to C:\Users\noob\AppData\Local\Programs\Python\Python36). +Now, when you'll want to run a script, right click the file and under ""edit with IDLE"" will be multiple versions to choose. Works on my machine :)",0.0,False,2,5962 +2019-02-25 15:00:24.023,"Is a Pyramid ""model"" also a Pyramid ""resource""?","I'm currently in the process of learning how to use the Python Pyramid web framework, and have found the documentation to be quite excellent. +I have, however, hit a stumbling block when it comes to distinguishing the idea of a ""model"" (i.e. a class defined under SQLAlchemy's declarative system) from the idea of a ""resource"" (i.e. a means of defining access control lists on views for use with Pyramid's auth system). +I understand the above statements seem to show that I already understand the difference, but I'm having trouble understanding whether I should be making models resources (by adding the __acl__ attribute directly in the model class) or creating a separate resource class (which has the proper __parent__ and __name__ attributes) which represents the access to a view which uses the model. +Any guidance is appreciated.","I'm having trouble understanding whether I should be making models resources (by adding the acl attribute directly in the model class) or creating a separate resource class + +The answer depends on what level of coupling you want to have. For a simple app, I would recommend making models resources just for simplicity sake. But for a complex app with a high level of cohesion and low level of coupling it would be better to have models separated from resources.",0.2012947653214861,False,1,5963 +2019-02-25 22:42:31.903,Python Gtk3 - Custom Statusbar w/ Progressbar,"Currently I am working to learn how to use Gtk3 with Python 3.6. So far I have been able to use a combination of resources to piece together a project I am working on, some old 2.0 references, some 3.0 shallow reference guides, and using the python3 interpreters help function. +However I am stuck at how I could customise the statusbar to display a progressbar. Would I have to modify the contents of the statusbar to add it to the end(so it shows up at the right side), or is it better to build my own statusbar? +Also how could I modify the progressbars color? Nothing in the materials list a method/property for it.","GtkStatusbar is a subclass of GtkBox. You can use any GtkBox method including pack_start and pack_end or even add, which is a method of GtkContainer. +Thus you can simply add you progressbar to statusbar.",1.2,True,1,5964 +2019-02-26 04:59:25.937,Can a consumer read records from a partition that stores data of particular key value?,Instead of creating many topics I'm creating a partition for each consumer and store data using a key. So is there a way to make a consumer in a consumer group read from partition that stores data of a specific key. If so can you suggest how it can done using kafka-python (or any other library).,"Instead of using the subscription and the related consumer group logic, you can use the ""assign"" logic (it's provided by the Kafka consumer Java client for example). +While with subscription to a topic and being part of a consumer group, the partitions are automatically assigned to consumers and re-balanced when a new consumer joins or leaves, it's different using assign. +With assign, the consumer asks to be assigned to a specific partition. It's not part of any consumer group. It's also mean that you are in charge of handling rebalancing if a consumer dies: for example, if consumer 1 get assigned partition 1 but at some point it crashes, the partition 1 won't be reassigned automatically to another consumer. It's up to you writing and handling the logic for restarting the consumer (or another one) for getting messages from partition 1.",0.0,False,1,5965 +2019-02-26 08:57:02.207,how to increase fps for raspberry pi for object detection,"I'm having low fps for real-time object detection on my raspberry pi +I trained the yolo-darkflow object detection on my own data set using my laptop windows 10 .. when I tested the model for real-time detection on my laptop with webcam it worked fine with high fps +However when trying to test it on my raspberry pi, which runs on Raspbian OS, it gives very low fps rate that is about 0.3 , but when I only try to use the webcam without the yolo it works fine with fast frames.. also when I use Tensorflow API for object detection with webcam on pi it also works fine with high fps +can someone suggest me something please? is the reason related to the yolo models or opencv or phthon? how can I make the fps rate higher and faster for object detection with webcam?","My detector on raspberry pi without any accelerator can reach 5 FPS. +I used SSD mobilenet, and quantize it after training. +Tensorflow Lite supplies a object detection demo can reach about 8 FPS on raspberry pi 4.",0.0,False,2,5966 +2019-02-26 08:57:02.207,how to increase fps for raspberry pi for object detection,"I'm having low fps for real-time object detection on my raspberry pi +I trained the yolo-darkflow object detection on my own data set using my laptop windows 10 .. when I tested the model for real-time detection on my laptop with webcam it worked fine with high fps +However when trying to test it on my raspberry pi, which runs on Raspbian OS, it gives very low fps rate that is about 0.3 , but when I only try to use the webcam without the yolo it works fine with fast frames.. also when I use Tensorflow API for object detection with webcam on pi it also works fine with high fps +can someone suggest me something please? is the reason related to the yolo models or opencv or phthon? how can I make the fps rate higher and faster for object detection with webcam?",The raspberry pi not have the GPU procesors and because of that is very hard for it to do image recognition at a high fps .,0.0,False,2,5966 +2019-02-26 10:41:52.910,"Python3: FileNotFoundError: [Errno 2] No such file or directory: 'train.txt', even with complete path","I'm currently working with Python3 on Jupyter Notebook. I try to load a text file which is in the exact same directory as my python notebook but it still doesn't find it. My line of code is: +text_data = prepare_text('train.txt') +and the error is a typical +FileNotFoundError: [Errno 2] No such file or directory: 'train.txt' +I've already tried to enter the full path to my text file but then I still get the same error. +Does anyone know how to solve this?","I found the answer. Windows put a secont .txt at the end of the file name, so I should have used train.txt.txt instead.",0.2012947653214861,False,1,5967 +2019-02-26 16:48:18.673,Write own stemmer for stemming,"I have a dataset of 27 files, each containing opcodes. I want to use stemming to map all versions of similar opcodes into the same opcode. For example: push, pusha, pushb, etc would all be mapped to push. +My dictionary contains 27 keys and each key has a list of opcodes as a value. Since the values contain opcodes and not normal english words, I cannot use the regular stemmer module. I need to write my own stemmer code. Also I cannot hard-code a custom dictionary that maps different versions of the opcodes to the root opcode because I have a huge dataset. +I think regex expression would be a good idea but I do not know how to use it. Can anyone help me with this or any other idea to write my own stemmer code?","I would recommend looking at the levenshtein distance metric - it measures the distance between two words in terms of character insertions, deletions, and replacements (so push and pusha would be distance 1 apart if you do the ~most normal thing of weighing insertions = deletions = replacements = 1 each). Based on the example you wrote, you could try just setting up categories that are all distance 1 from each other. However, I don't know if all of your equivalent opcodes will be so similar - if they're not leven might not work.",0.0,False,1,5968 +2019-02-26 18:30:41.820,Elementree Fromstring and iterparse in Python 3.x,"I am able to parse from file using this method: +for event, elem in ET.iterparse(file_path, events=(""start"", ""end"")): +But, how can I do the same with fromstring function? Instead of from file, xml content is stored in a variable now. But, I still want to have the events as before.","From the documentation for the iterparse method: + +...Parses an XML section into an element tree incrementally, and + reports what’s going on to the user. source is a filename or file + object containing XML data... + +I've never used the etree python module, but ""or file object"" says to me that this method accepts an open file-like object as well as a file name. It's an easy thing to construct a file-like object around a string to pass as input to a method like this. +Take a look at the StringIO module.",0.0,False,1,5969 +2019-02-26 21:57:40.743,Why should I use tf.data?,"I'm learning tensorflow, and the tf.data API confuses me. It is apparently better when dealing with large datasets, but when using the dataset, it has to be converted back into a tensor. But why not just use a tensor in the first place? Why and when should we use tf.data? +Why isn't it possible to have tf.data return the entire dataset, instead of processing it through a for loop? When just minimizing a function of the dataset (using something like tf.losses.mean_squared_error), I usually input the data through a tensor or a numpy array, and I don't know how to input data through a for loop. How would I do this?","The tf.data module has specific tools which help in building a input pipeline for your ML model. A input pipeline takes in the raw data, processes it and then feeds it to the model. + + +When should I use tf.data module? + +The tf.data module is useful when you have a large dataset in the form of a file such as .csv or .tfrecord. tf.data.Dataset can perform shuffling and batching of samples efficiently. Useful for large datasets as well as small datasets. It could combine train and test datasets. + +How can I create batches and iterate through them for training? + +I think you can efficiently do this with NumPy and np.reshape method. Pandas can read data files for you. Then, you just need a for ... in ... loop to get each batch amd pass it to your model. + +How can I feed NumPy data to a TensorFlow model? + +There are two options to use tf.placeholder() or tf.data.Dataset. + +The tf.data.Dataset is a much easier implementation. I recommend to use it. Also, has some good set of methods. +The tf.placeholder creates a placeholder tensor which feeds the data to a TensorFlow graph. This process would consume more time feeding in the data.",1.2,True,1,5970 +2019-02-27 00:06:57.810,Pipenv: Multiple Environments,"Right now I'm using virtualenv and just switching over to Pipenv. Today in virtualenv I load in different environment variables and settings depending on whether I'm in development, production, or testingby setting DJANGO_SETTINGS_MODULE to myproject.settings.development, myproject.settings.production, and myproject.settings.testing. +I'm aware that I can set an .env file, but how can I have multiple versions of that .env file?","You should create different .env files with different prefixes depending on the environment, such as production.env or testing.env. With pipenv, you can use the PIPENV_DONT_LOAD_ENV=1 environment variable to prevent pipenv shell from automatically exporting the .env file and combine this with export $(cat .env | xargs). +export $(cat production.env | xargs) && PIPENV_DONT_LOAD_ENV=1 pipenv shell would configure your environment variables for production and then start a shell in the virtual environment.",1.2,True,1,5971 +2019-02-27 05:59:35.137,How to architect a GUI application with UART comms which stays responsive to the user,"I'm writing an application in PyQt5 which will be used for calibration and test of a product. The important details: + +The product under test uses an old-school UART/serial communication link at 9600 baud. +...and the test / calibration operation involves communicating with another device which has a UART/serial communication link at 300 baud(!) +In both cases, the communication protocol is ASCII text with messages terminated by a newline \r\n. + +During the test/calibration cycle the GUI needs to communicate with the devices, take readings, and log those readings to various boxes in the screen. The trouble is, with the slow UART communications (and the long time-outs if there is a comms drop-out) how do I keep the GUI responsive? +The Minimally Acceptable solution (already working) is to create a GUI which communicates over the serial port, but the user interface becomes decidedly sluggish and herky-jerky while the GUI is waiting for calls to serial.read() to either complete or time out. +The Desired solution is a GUI which has a nice smooth responsive feel to it, even while it is transmitting and receiving serial data. +The Stretch Goal solution is a GUI which will log every single character of the serial communications to a text display used for debugging, while still providing some nice ""message-level"" abstraction for the actual logic of the application. +My present ""minimally acceptable"" implementation uses a state machine where I run a series of short functions, typically including the serial.write() and serial.read() commands, with pauses to allow the GUI to update. But the state machine makes the GUI logic somewhat tricky to follow; the code would be much easier to understand if the program flow for communicating to the device was written in a simple linear fashion. +I'm really hesitant to sprinkle a bunch of processEvents() calls throughout the code. And even those don't help when waiting for serial.read(). So the correct solution probably involves threading, signals, and slots, but I'm guessing that ""threading"" has the same two Golden Rules as ""optimization"": Rule 1: Don't do it. Rule 2 (experts only): Don't do it yet. +Are there any existing architectures or design patterns to use as a starting point for this type of application?","Okay for the past few days I've been digging, and figured out how to do this. Since there haven't been any responses, and I do think this question could apply to others, I'll go ahead and post my solution. Briefly: + +Yes, the best way to solve this is with with PyQt Threads, and using Signals and Slots to communicate between the threads. +For basic function (the ""Desired"" solution above) just follow the existing basic design pattern for PyQt multithreaded GUI applications: + + +A GUI thread whose only job is to display data and relay user inputs / commands, and, +A worker thread that does everything else (in this case, including the serial comms). + +One stumbling point along the way: I'd have loved to write the worker thread as one linear flow of code, but unfortunately that's not possible because the worker thread needs to get info from the GUI at times. + + +The only way to get data back and forth between the two threads is via Signals and Slots, and the Slots (i.e. the receiving end) must be a callable, so there was no way for me to implement some type of getdata() operation in the middle of a function. Instead, the worker thread had to be constructed as a bunch of individual functions, each one of which gets kicked off after it receives the appropriate Signal from the GUI. + +Getting the serial data monitoring function (the ""Stretch Goal"" above) was actually pretty easy -- just have the low-level serial transmit and receive routines already in my code emit Signals for that data, and the GUI thread receives and logs those Signals. + +All in all it ended up being a pretty straightforward application of existing principles, but I'm writing it down so hopefully the next guy doesn't have to go down so many blind alleys like I did along the way.",0.0,False,1,5972 +2019-02-27 13:33:17.083,how to register users of different kinds using different tables in django?,"I'm new to django, I want to register users using different tables for different users like students, teaching staff, non teaching staff, 3 tables. +How can i do it instead of using default auth_users table for registration","cf Sam's answer for the proper solutions from a technical POV. From a design POV, ""student"", ""teaching staff"" etc are not entities but different roles a user can have. +One curious things with living persons and real-life things in general is that they tend to evolve over time without any respect for our well-defined specifications and classifications - for example it's not uncommon for a student to also have teaching duties at some points, for a teacher to also be studying some other topic, or for a teacher to stop teaching and switch to more administrative tasks. If you design your model with distinct entities instead of one single entitie and distinct roles, it won't properly accomodate those kind of situations (and no, having one account as student and one as teacher is not a proper solution either). +That's why the default user model in Django is based on one single entity (the User model) and features allowing roles definitions (groups and permissions) in such a way that one user can have many roles, whether at the same time or in succession.",0.0,False,2,5973 +2019-02-27 13:33:17.083,how to register users of different kinds using different tables in django?,"I'm new to django, I want to register users using different tables for different users like students, teaching staff, non teaching staff, 3 tables. +How can i do it instead of using default auth_users table for registration","In Django authentication, there is Group model available which have many to many relationship with User model. You can add students, teaching staff and non teaching staff to Group model for separating users by their type.",0.0,False,2,5973 +2019-02-28 01:29:15.947,How do I know if a file has finished copying?,"I've been given a simple file-conversion task: whenever an MP4 file is in a certain directory, I do some magic to it and move it to a different directory. Nice and straightforward, and easy to automate. +However, if a user is copying some huge file into the directory, I worry that my script might catch it mid-copy, and only have half of the file to work with. +Is there a way, using Python 3 on Windows, to check whether a file is done copying (in other words, no process is currently writing to it)? +EDIT: To clarify, I have no idea how the files are getting there: my script just needs to watch a shared network folder and process files that are put there. They might be copied from a local folder I don't have access to, or placed through SCP, or downloaded from the web; all I know is the destination.","you could try first comparing the size of the file initially, or alternatively see if there are new files in the folder, capture the name of the new file and see if its size increases in x time, if you have a script, you could show the code....",0.0,False,1,5974 +2019-02-28 03:04:27.143,Viewing Graph from saved .pbtxt file on Tensorboard,I just have a graph.pbtxt file. I want to view the graph in tensorboard. But I am not aware of how to do that. Do I have to write any python script or can I do it from the terminal itself? Kindly help me to know the steps involved.,"Open tensorboard and use the ""Upload"" button on the left to upload the pbtxt file will directly open the graph in tensorboard.",0.9866142981514304,False,1,5975 +2019-02-28 16:24:27.333,Intersection of interpol1d objects,"I have 2 cumulative distributions that I want to find the intersection of. To get an underlying function, I used the scipy interpol1d function. What I’m trying to figure out now, is how to calculate their intersection. Not sure how I can do it. Tried fsolve, but I can’t find how to restrict the range in which to search for a solution (domain is limited).","Use scipy.optimize.brentq for bracketed root-finding: +brentq(lambda x: interp1d(xx, yy)(x) - interp1d(xxx, yyy)(x), -1, 1)",0.0,False,1,5976 +2019-02-28 18:54:51.120,How to make depth of nii images equal?,"I am having some nii images and each having same height and width but different depth. So I need to make the depth of each image equal, how can I do that? Also I didn't find any Python code, which can help me.","Once you have defined the depth you want for all volumes, let it be D, you can instantiate an image (called volume when D > 1) of dimensions W x H x D, for every volume you have. +Then you can fill every such volume, pixel by pixel, by mapping the pixel position onto the original volume and retrieving the value of the pixel by interpolating the values in neighboring pixels. +For example, a pixel (i_x, i_y, i_z) in the new volume will be mapped in a point (i_x, i_y, i_z') of the old volume. One of the simplest interpolation methods is the linear interpolation: the value of (i_x, i_y, i_z) is a weighted average of the values (i_x, i_y, floor(i_z')) and (i_x, i_y, floor(i_z') + 1).",0.0,False,1,5977 +2019-02-28 21:02:20.790,Tensorflow data pipeline: Slow with caching to disk - how to improve evaluation performance?,"I've built a data pipeline. Pseudo code is as follows: + +dataset -> +dataset = augment(dataset) +dataset = dataset.batch(35).prefetch(1) +dataset = set_from_generator(to_feed_dict(dataset)) # expensive op +dataset = Cache('/tmp', dataset) +dataset = dataset.unbatch() +dataset = dataset.shuffle(64).batch(256).prefetch(1) +to_feed_dict(dataset) + +1 to 5 actions are required to generate the pretrained model outputs. I cache them as they do not change throughout epochs (pretrained model weights are not updated). 5 to 8 actions prepare the dataset for training. +Different batch sizes have to be used, as the pretrained model inputs are of a much bigger dimensionality than the outputs. +The first epoch is slow, as it has to evaluate the pretrained model on every input item to generate templates and save them to the disk. Later epochs are faster, yet they're still quite slow - I suspect the bottleneck is reading the disk cache. +What could be improved in this data pipeline to reduce the issue? +Thank you!","prefetch(1) means that there will be only one element prefetched, I think you may want to have it as big as the batch size or larger. +After first cache you may try to put it second time but without providing a path, so it would cache some in the memory. +Maybe your HDD is just slow? ;) +Another idea is you could just manually write to compressed TFRecord after steps 1-4 and then read it with another dataset. Compressed file has lower I/O but causes higher CPU usage.",0.0,False,1,5978 +2019-03-01 11:32:59.497,Get data from an .asp file,"My girlfriend has been given the task of getting all the data from a webpage. The web page belongs to an adult education centre. To get to the webpage, you must first log in. The url is a .asp file. +She has to put the data in an Excel sheet. The entries are student names, numbers, ID card number, telephone, etc. There are thousands of entries. HR students alone has 70 pages of entries. This all shows up on the webpage as a table. It is possible to copy and paste. +I can handle Python openpyxl reasonably and I have heard of web-scraping, which I believe Python can do. +I don't know what .asp is. +Could you please give me some tips, pointers, about how to get the data with Python? +Can I automate this task? +Is this a case for MySQL? (About which I know nothing.)","This is a really broad question and not really in the style of Stack Overflow. To give you some pointers anyway. In the end .asp files, as far as I know, behave like normal websites. Normal websites are interpreted in the browser like HTML, CSS etc. This can be parsed with Python. There are two approaches to this that I have used in the past that work. One is to use a library like requests to get the HTML of a page and then read it using the BeautifulSoup library. This gets more complex if you need to visit authenticated pages. The other option is to use Selenium for python. This module is more a tool to automate browsing itself. You can use this to automate visiting the website and entering login credentials and then read content on the page. There are probably more options which is why this question is too broad. Good luck with your project though! +EDIT: You do not need MySql for this. Especially not if the required output is an Excel file, which I would generate as a CSV instead because standard Python works better with CSV files than Excel.",0.2012947653214861,False,2,5979 +2019-03-01 11:32:59.497,Get data from an .asp file,"My girlfriend has been given the task of getting all the data from a webpage. The web page belongs to an adult education centre. To get to the webpage, you must first log in. The url is a .asp file. +She has to put the data in an Excel sheet. The entries are student names, numbers, ID card number, telephone, etc. There are thousands of entries. HR students alone has 70 pages of entries. This all shows up on the webpage as a table. It is possible to copy and paste. +I can handle Python openpyxl reasonably and I have heard of web-scraping, which I believe Python can do. +I don't know what .asp is. +Could you please give me some tips, pointers, about how to get the data with Python? +Can I automate this task? +Is this a case for MySQL? (About which I know nothing.)","Try using the tool called Octoparse. +Disclaimer: I've never used it myself, but only came close to using it. So, from my knowledge of its features, I think it would be useful for your need.",0.2012947653214861,False,2,5979 +2019-03-01 22:45:49.617,Pygame/Python/Terminal/Mac related,"I'm a beginner, I have really hit a brick wall, and would greatly appreciate any advice someone more advanced can offer. +I have been having a number of extremely frustrating issues the past few days, which I have been round and round google trying to solve, tried all sorts of things to no avail. +Problem 1) +I can't import pygame in Idle with the error: +ModuleNotFoundError: No module named 'pygame' - even though it is definitely installed, as in terminal, if I ask pip3 to install pygame it says: +Requirement already satisfied: pygame in /usr/local/lib/python3.7/site-packages (1.9.4) +I think there may be a problem with several conflicting versions of python on my computer, as when i type sys.path in Idle (which by the way displays Python 3.7.2 ) the following are listed: +'/Users/myname/Documents', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/myname/Library/Python/3.7/lib/python/site-packages', '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages' +So am I right in thinking pygame is in the python3.7/sitepackages version, and this is why idle won't import it? I don't know I'm just trying to make sense of this. I have absoloutely no clue how to solve this,""re-set the path"" or whatever. I don't even know how to find all of these versions of python as only one appears in my applications folder, the rest are elsewhere? +Problem 2) +Apparently there should be a python 2.7 system version installed on every mac system which is vital to the running of python regardless of the developing environment you use. Yet all of my versions of python seem to be in the library/downloaded versions. Does this mean my system version of python is gone? I have put the computer in recovery mode today and done a reinstall of the macOS mojave system today, so shouldn't any possible lost version of python 2.7 be back on the system now? +Problem 3) +When I go to terminal, frequently every command I type is 'not found'. +I have sometimes found a temporary solution is typing: +export PATH=""/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"" +but the problems always return! +As I say I also did a system reinstall today but that has helped none! +Can anybody please help me with these queries? I am really at the end of my tether and quite lost, forgive my programming ignorance please. Many thanks.","You should actually add the export PATH=""/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"" to your .bash_profile (if you are using bash). Do this by opening your terminal, verifying that it says ""bash"" at the top. If it doesn't, you may have a .zprofile instead. Type ls -al and it will list all the invisible files. If you have .bash_profile listed, use that one. If you have .zprofile, use that. +Type nano .bash_profile to open and edit the profile and add the command to the end of it. This will permanently add the path to your profile after you restart the terminal. +Use ^X to exit nano and type Y to save your changes. Then you can check that it works when you try to run the program from IDLE.",0.0,False,1,5980 +2019-03-03 16:50:01.227,Force screen session to use specific version of python,"I am using a screen on my server. When I ask which python inside the screen I see it is using the default /opt/anaconda2/bin/python version which is on my server, but outside the screen when I ask which python I get ~/anaconda2/bin/python. I want to use the same python inside the screen but I don't know how can I set it. Both path are available in $PATH","You could do either one of the following: + +Use a virtual environment (install virtualenv). You can specify +the version of Python you want to use when creating the virtual +environment with -p /opt/anaconda2/bin/python. +Use an alias: +alias python=/opt/anaconda2/bin/python.",0.3869120172231254,False,1,5981 +2019-03-04 17:51:31.130,How can i remove an object in python?,"i'm trying to create a chess simulator. +consider this scenario: +there is a black rook (instance object of Rook class) in square 2B called rook1. +there is a white rook in square 2C called rook2. +when the player moves rook1 to square 2C , the i should remove rook2 object from memory completely. +how can i do it? +P.S. i'v already tried del rook2 , but i don't know why it doesn't work.","Trying to remove objects from memory is the wrong way to go. Python offers no option to do that manually, and it would be the wrong operation to perform anyway. +You need to alter whatever data structure represents your chess board so that it represents a game state where there is a black rook at c2 and no piece at b2, rather than a game state where there is a black rook at b2 and a white rook at c2. In a reasonable Python beginner-project implementation of a chess board, this probably means assigning to cells in a list of lists. No objects need to be manually removed from memory to do this. +Having rook1 and rook2 variables referring to your rooks is unnecessary and probably counterproductive.",0.999329299739067,False,1,5982 +2019-03-04 22:00:24.150,Text classification beyond the keyword dependency and inferring the actual meaning,"I am trying to develop a text classifier that will classify a piece of text as Private or Public. Take medical or health information as an example domain. A typical classifier that I can think of considers keywords as the main distinguisher, right? What about a scenario like bellow? What if both of the pieces of text contains similar keywords but carry a different meaning. +Following piece of text is revealing someone's private (health) situation (the patient has cancer): +I've been to two clinics and my pcp. I've had an ultrasound only to be told it's a resolving cyst or a hematoma, but it's getting larger and starting to make my leg ache. The PCP said it can't be a cyst because it started out way too big and I swear I have NEVER injured my leg, not even a bump. I am now scared and afraid of cancer. I noticed a slightly uncomfortable sensation only when squatting down about 9 months ago. 3 months ago I went to squat down to put away laundry and it kinda hurt. The pain prompted me to examine my leg and that is when I noticed a lump at the bottom of my calf muscle and flexing only made it more noticeable. Eventually after four clinic visits, an ultrasound and one pcp the result seems to be positive and the mass is getting larger. +[Private] (Correct Classification) +Following piece of text is a comment from a doctor which is definitely not revealing is health situation. It introduces the weaknesses of a typical classifier model: +Don’t be scared and do not assume anything bad as cancer. I have gone through several cases in my clinic and it seems familiar to me. As you mentioned it might be a cyst or a hematoma and it's getting larger, it must need some additional diagnosis such as biopsy. Having an ache in that area or the size of the lump does not really tells anything bad. You should visit specialized clinics few more times and go under some specific tests such as biopsy, CT scan, pcp and ultrasound before that lump become more larger. +[Private] (Which is the Wrong Classification. It should be [Public]) +The second paragraph was classified as private by all of my current classifiers, for obvious reason. Similar keywords, valid word sequences, the presence of subjects seemed to make the classifier very confused. Even, both of the content contains subjects like I, You (Noun, Pronouns) etc. I thought about from Word2Vec to Doc2Vec, from Inferring meaning to semantic embeddings but can't think about a solution approach that best suits this problem. +Any idea, which way I should handle the classification problem? Thanks in advance. +Progress so Far: +The data, I have collected from a public source where patients/victims usually post their own situation and doctors/well-wishers reply to those. I assumed while crawling is that - posts belongs to my private class and comments belongs to public class. All to gether I started with 5K+5K posts/comments and got around 60% with a naive bayes classifier without any major preprocessing. I will try Neural Network soon. But before feeding into any classifier, I just want to know how I can preprocess better to put reasonable weights to either class for better distinction.","(1) Bayes is indeed a weak classifier - I'd try SVM. If you see improvement than further improvement can be achieved using Neural Network (and perhaps Deep Learning) +(2) Feature engineering - use TFiDF , and try other things (many people suggest Word2Vec, although I personally tried and it did not improve). Also you can remove stop words. +One thing to consider, because you give two anecdotes is to measure objectively the level of agreement between human beings on the task. It is sometime overlooked that two people given the same text can disagree on labels (some might say that a specific document is private although it is public). Just a point to notice - because if e.g. the level of agreement is 65%, then it will be very difficult to build an algorithm that is more accurate.",-0.2655860252697744,False,1,5983 +2019-03-05 03:08:47.917,How do you profile a Python script from Windows command line using PyPy and vmprof?,"I have a Python script that I want to profile using vmprof to figure out what parts of the code are slow. Since PyPy is generally faster, I also want to profile the script while it is using the PyPy JIT. If the script is named myscript.py, how do you structure the command on the command line to do this? +I have already installed vmprof using + +pip install vmprof","I would be suprised if it works, but the command is pypy -m vmprof myscript.py . I would expect it to crash saying vmprof is not supported on windows.",0.0,False,1,5984 +2019-03-06 00:43:24.310,How to update python 3.6 to 3.7 using Mac terminal,"OK +I was afraid to use the terminal, so I installed the python-3.7.2-macosx10.9 package downloaded from python.org +Ran the certificate and shell profile scripts, everything seems fine. +Now the ""which python3"" has changed the path from 3.6 to the new 3.7.2 +So everything seems fine, correct? +My question (of 2) is what's going on with the old python3.6 folder still in the applications folder. Can you just delete it safely? Why when you install a new version does it not at least ask you if you want to update or install and keep both versions? +Second question, how would you do this from the terminal? +I see the first step is to sudo to the root. +I've forgotten the rest. +But from the terminal, would this simply add the new version and leave +the older one like the package installer? +It's pretty simple to use the package installer and then delete a folder. +So, thanks in advance. I'm new to python and have not much confidence +using the terminal and all the powerful shell commands. +And yeah I see all the Brew enthusiasts. I DON'T want to use Brew for the moment. +The python snakes nest of pathways is a little confusing, for the moment. +I don't want to get lost with a zillion pathways from Brew because it's +confusing for the moment. +I love Brew, leave me alone.","Each version of the Python installation is independent of each other. So its safe to delete the version you don't want, but be cautious of this because it can lead to broken dependencies :-). +You can run any version by adding the specific version i.e $python3.6 or $python3.7 +The best approach is to use virtual environments for your projects to enhance consistency. see pipenv",0.0,False,1,5985 +2019-03-07 02:42:18.347,How do I figure out what dependencies to install when I copy my Django app from one system to another?,"I'm using Django and Python 3.7. I want to write a script to help me easily migrate my application from my local machien (a Mac High Sierra) to a CentOS Linux instance. I'm using a virtual environment in both places. There are many things that need to be done here, but to keep the question specific, how do I determine on my remote machine (where I'm deploying my project to), what dependencies are lacking? I'm using rsync to copy the files (minus the virtual environment)","On the source system execute pip freeze > requirements.txt, then copy the requiremnts.txt to the target system and then on the target system install all the dependencies with pip install -r requirements.txt. Of course you will need to activate the virtual environments on both systems before execute the pip commands. +If you are using a source code management system like git it is a good idea to keep the requirements.txt up to date in your source code repository.",1.2,True,1,5986 +2019-03-07 10:03:42.277,Does angular server and flask server have both to be running at the same?,"I'm new to both angular and flask framework so plz be patient with me. +I'm trying to build a web app with flask as a backend server and Angular for the frontend (I didn't start it yet), and while gathering infos and looking at tutorials and some documentation (a little bit) I'm wondering: +Does Angular server and flask server need both to be running at the same time or will just flask be enough? Knowing that I want to send data from the server to the frontend to display and collecting data from users and sending it to the backend. +I noticed some guys building the angular app and using the dist files but I don't exactly know how that works. +So can you guys suggest what should I have to do or how to proceed with this? +Thank you ^^","Angular does not need a server. It's a client-side framework so it can be served by any server like Flask. Probably in most tutorials, the backend is served by nodejs, not Flask.",1.2,True,1,5987 +2019-03-08 19:25:09.250,Change color of single word in Tk label widget,"I would like to change the font color of a single word in a Tkinter label widget. +I understand that something similar to what I would like to be done can be achieved with a Text widget.. for example making the word ""YELLOW"" show in yellow: +self.text.tag_config(""tag_yel"", fg=clr_yellow) +self.text.highligh_pattern(""YELLOW"", ""tag_yel"") +But my text is static and all I want is to change the word ""YELLOW"" to show as yellow font and ""RED"" in red font and I cannot seem to figure out how to change text color without changing it all with label.config(fg=clr). +Any help would be appreciated","You cannot do what you want. A label supports only a single foreground color and a single background color. The solution is to use a text or canvas widget., or to use two separate labels.",1.2,True,1,5988 +2019-03-11 12:10:11.213,Running python directly in terminal,"Is it possible to execute short python expressions in one line in terminal, without passing a file? +e.g. (borrowing from how I would write an awk expression) +python 'print(""hello world"")'","For completeness, I found you can also feed a here-string to python. +python <<< 'print(""hello world"")'",0.0,False,2,5989 +2019-03-11 12:10:11.213,Running python directly in terminal,"Is it possible to execute short python expressions in one line in terminal, without passing a file? +e.g. (borrowing from how I would write an awk expression) +python 'print(""hello world"")'","python3 -c ""print('Hello')"" +Use the -c flag as above.",1.2,True,2,5989 +2019-03-11 13:21:12.590,How to save and load my neural network model after training along with weights in python?,"I have trained a single layer neural network model in python (a simple model without keras and tensorflow). +How canI save it after training along with weights in python, and how to load it later?","So you write it down yourself. You need some simple steps: + +In your code for neural network, store weights in a variable. It could be simply done by using self.weights.weights are numpy ndarrays. for example if weights are between layer with 10 neurons to layer with 100 neurons, it is a 10 * 100(or 100* 10) nd array. +Use numpy.save to save the ndarray. +For next use of your network, use numpy.load to load weights +In the first initialization of your network, use weights you've loaded. +Don't forget, if your network is trained, weights should be frozen. It can be done by zeroing learning rate.",0.1352210990936997,False,1,5990 +2019-03-12 12:23:21.577,tf.gradient acting like tfp.math.diag_jacobian,"I try to calculate noise for input data using the gradient of the loss function from the input-data: +my_grad = tf.gradients(loss, input) +loss is an array of size (n x 1) where n is the number of datasets, m is the size of the dataset, input is an array of (n x m) where m is the size of a single dataset. +I need my_grad to be of size (n x m) - so for each dataset the gradient is calulated. But by definition the gradients where i!=j are zero - but tf.gradients allocates huge amount of memory and runs for prettymuch ever... +A version, which calulates the gradients only where i=j would be great - any Idea how to get there?","I suppose I have found a solution: +my_grad = tf.gradients(tf.reduce_sum(loss), input) +ensures, that the cross dependencies i!=j are ignored - that works really nicely and fast..",0.0,False,1,5991 +2019-03-12 14:50:25.703,Lost my python.exe in Pycharm with Anaconda3,"Everything was working perfectly until today, when for some reason my python.exe file disappeared from the Project Interpreter in Pycharm. +It was located in C:\users\my_name\Anaconda3\python.exe, and for some reason I can't find it anywhere! +Yet, all the packages are here (in the site-packages folder), and only the C:\users\my_name\Anaconda3\pythonw.exe is available. +With the latest however, some packages I installed on top of those available in Anaconda3 won't be recognized. +Therefore, how to get back the python.exe file?","My Python.exe was missing today in my existing environment in anaconda, so I clone my environment with anaconda to recreate Python.exe and use it again in Spyder.",0.0,False,3,5992 +2019-03-12 14:50:25.703,Lost my python.exe in Pycharm with Anaconda3,"Everything was working perfectly until today, when for some reason my python.exe file disappeared from the Project Interpreter in Pycharm. +It was located in C:\users\my_name\Anaconda3\python.exe, and for some reason I can't find it anywhere! +Yet, all the packages are here (in the site-packages folder), and only the C:\users\my_name\Anaconda3\pythonw.exe is available. +With the latest however, some packages I installed on top of those available in Anaconda3 won't be recognized. +Therefore, how to get back the python.exe file?","The answer repeats the comment to the question. +I had the same issue once after Anaconda update - python.exe was missing. It was Anaconda 3 installed to Program Files folder by MS Visual Studio (Python 3.6 on Windows10 x64). +To solve the problem I manually copied python.exe file from the most fresh python package available (folder pkgs then folder like python-3.6.8-h9f7ef89_7).",1.2,True,3,5992 +2019-03-12 14:50:25.703,Lost my python.exe in Pycharm with Anaconda3,"Everything was working perfectly until today, when for some reason my python.exe file disappeared from the Project Interpreter in Pycharm. +It was located in C:\users\my_name\Anaconda3\python.exe, and for some reason I can't find it anywhere! +Yet, all the packages are here (in the site-packages folder), and only the C:\users\my_name\Anaconda3\pythonw.exe is available. +With the latest however, some packages I installed on top of those available in Anaconda3 won't be recognized. +Therefore, how to get back the python.exe file?","I just had the same issue and found out that Avast removed it because it thought it was a threat. I found it in Avast -> Protection -> Virus Chest. And from there, you have the option to restore it.",0.3869120172231254,False,3,5992 +2019-03-12 18:13:12.880,trouble with appending scores in python,"the code is supposed to give 3 questions with 2 attempts. if the answer is correct the first try, 3 points. second try gives 1 point. if second try is incorrect, the game will end. +however, the scores are not adding up to create a final score after the 3 rounds. how do i make it so that it does that?",First move import random to the top of the script because you're importing it every time in the loop and the score is calculated just in the last spin of the program since you empty scoreList[] every time,0.6730655149877884,False,1,5993 +2019-03-13 05:05:14.420,Accessing Luigi visualizer on AWS,"I’ve been using the Luigi visualizer for pipelining my python code. +Now I’ve started using an aws instance, and want to access the visualizer from my own machine. +Any ideas on how I could do that?","We had the very same problem today on GCP, and solved with the following steps: + +setting firewall rules for incoming TCP connections on port used by the service (which by default is 8082); +installing apache2 server on the instance with a site.conf configuration that resolve incoming requests on ip-of-instance:8082. + +That's it. Hope this can help.",0.2012947653214861,False,1,5994 +2019-03-13 09:24:24.310,"Async, multithreaded scraping in Python with limited threads","We have to refactor scraping algorithm. To speed it up we came up to conclusion to multi-thread processes (and limit them to max 3). Generally speaking scraping consists of following aspects: + +Scraping (async request, takes approx 2 sec) +Image processing (async per image, approx 500ms per image) +Changing source item in DB (async request, approx 2 sec) + +What I am aiming to do is to create batch of scraping requests and while looping through them, create a stack of consequent async operations: Process images and as soon as images are processed -> change source item. +In other words - scraping goes. but image processing and changing source items must be run in separate limited async threads. +Only think I don't know how to stack the batch and limit threads. +Has anyone came across the same task and what approach have you used?","What you're looking for is consumer-producer pattern. Just create 3 different queues and when you process the item in one of them, queue new work in another. Then you can 3 different threads each of them processing one queue.",1.2,True,1,5995 +2019-03-13 20:16:42.690,Pymongo inserts _id in original array after insert_many .how to avoid insertion of _id?,"Pymongo inserts _id in original array after insert_many .how to avoid insertion of _id ? And why original array is updated with _id? Please explain with example, if anybody knows? Thanks in advance.",Pymongo driver explicitly inserts _id of type ObjectId into the original array and hence original array gets updated before inserting into mongo. This is the expected behaviour of pymongo for insertmany query as per my previous experiences. Hope this answers your question.,1.2,True,1,5996 +2019-03-13 21:29:05.987,how can i prevent the user from closing my cmd window in a python script on windows,is there any way to prevent the user from closing the cmd window of a python script on windows or maybe just disable the (X) close button ?? I have looked for answers already but i couldn't find anything that would help me,"I dont think its possible, what you can do instead is to not display the cmd window (backgroundworker) and make it into a hidden process with system rights so that it cant be shutdown until it finishes.",0.0,False,1,5997 +2019-03-14 00:37:45.023,regex python multiline,"how can i search for patterns in texts that cover multiple lines and have fixed positions relating each other, for example a pattern consisting of 3 letters of x directly below each other and I want to find them at any position in the line, not just at the beginning for example. +Thank you in advance for the answer!","I believe the problem you are asking about is ""Find patterns that appear at the same offset in a series of lines."" +I do not think this describes a regular language, so you would need to draw on Python's extended regex features to have a chance at a regex-based solution. But I do not believe Python supports sufficiently extended features to accomplish this task [1]. +If it is acceptable that they occur at a particular offset (rather than ""any offset, so long as the offset is consistent""), then something like this should work: +/^.{OFFSET}PATTERN.*\n^.{OFFSET}PATTERN.*\n^.{OFFSET}PATTERN/, using the MULTILINE flag so that ^ matches the beginning of a series of lines instead of just the beginning of the entire text. +[1] In particular, you could use a backreference to capture the text preceding the desired pattern on one line, but I do not think you can query the length of the captured content ""inline"". You could search for the same leading text again on the next line, but that does not sound like what you want.",0.0,False,1,5998 +2019-03-14 15:52:38.597,Faster pytorch dataset file,"I have the following problem, I have many files of 3D volumes that I open to extract a bunch of numpy arrays. +I want to get those arrays randomly, i.e. in the worst case I open as many 3D volumes as numpy arrays I want to get, if all those arrays are in separate files. +The IO here isn't great, I open a big file only to get a small numpy array from it. +Any idea how I can store all these arrays so that the IO is better? +I can't pre-read all the arrays and save them all in one file because then that file would be too big to open for RAM. +I looked up LMDB but it all seems to be about Caffe. +Any idea how I can achieve this?","One trivial solution can be pre-processing your dataset and saving multiple smaller crops of the original 3D volumes separately. This way you sacrifice some disk space for more efficient IO. +Note that you can make a trade-off with the crop size here: saving bigger crops than you need for input allows you to still do random crop augmentation on the fly. If you save overlapping crops in the pre-processing step, then you can ensure that still all possible random crops of the original dataset can be produced. +Alternatively you may try using a custom data loader that retains the full volumes for a few batch. Be careful, this might create some correlation between batches. Since many machine learning algorithms relies on i.i.d samples (e.g. Stochastic Gradient Descent), correlated batches can easily cause some serious mess.",0.0,False,1,5999 +2019-03-14 19:33:03.197,How does multiplexing in Django sockets work?,"I am new at this part of web developing and was trying to figure out a way of creating a web app with the basic specifications as the example bellow: + +A user1 opens a page with a textbox (something where he can add text or so), and it will be modified as it decides to do it. + +If the user1 has problems he can invite other user2 to help with the typing. + + +The user2 (when logged to the Channel/Socket) will be able to modify that field and the modifications made will be show to the user1 in real time and vice versa. + + +Or another example is a room on CodeAcademy: + +Imagine that I am learning a new coding language, however, at middle of it I jeopardize it and had to ask for help. + +So I go forward and ask help to another user. This user access the page through a WebSocket (or something related to that). + + +The user helps me changing my code and adding some comments at it in real time, and I also will be able to ask questions through it (real time communication) + + +My questions is: will I be able to developed certain app using Django Channels 2 and multiplexing? or better move to use NodeJS or something related to that? +Obs: I do have more experience working with python/django, so it will more productive for me right know if could find a way working with this combo.","This is definitely possible. They will be lots of possibilities, but I would recommend the following. + +Have a page with code on. The page has some websocket JS code that can connect to a Channels Consumer. +The JS does 2 simple things. When code is updated code on the screen, send a message to the Consumer, with the new text (you can optimize this later). When the socket receives a message, then replace the code on screen with the new code. +In your consumer, add your consumer to a channel group when connecting (the group will contain all of the consumers that are accessing the page) +When a message is received, use group_send to send it to all the other consumers +When your consumer callback function gets called, then send a message to your websocket",0.3869120172231254,False,1,6000 +2019-03-14 20:28:27.727,Operating system does not meet the minimum requirements of the language server,"I installed Python 3.7.2 and VSCode 1.32.1 on Mac OS X 10.10.2. In VSCode I installed the Pyhton extension and got a message saying: +""Operating system does not meet the minimum requirements of the language server. Reverting to alternative, Jedi"". +When clicking the ""More"" option under the message I got information indicating that I need OS X 10.12, at least. +I tried to install an older version of the extension, did some reading here and asked Google, but I'm having a hard time since I don´t really know what vocabulary to use. +My questions are: +Will the extension work despite the error message? +Do I need to solve this, and how do I do that?","The extension will work without the language server, but some thing won't work quite as well (e.g. auto-complete and some refactoring options). Basically if you remove the ""python.jediEnabled"" setting -- or set it to false -- and the extension works fine for you then that's the important thing. :)",1.2,True,1,6001 +2019-03-17 20:51:04.933,What is the preferred way to a add a citation suggestion to python packages?,"How should developers indicate how users should cite the package, other than on the documentation? +R packages return the preferred citation using citation(""pkg""). +I can think of pkg.CITATION, pkg.citation and pkg.__citation__. Are there others? If there is no preferred way (which seems to be the case to me as I did not find anything on python.org), what are the pros and cons of each?","Finally I opted for the dunder option. Only the dunder option (__citation__) makes clear, that this is not a normal variable needed for runtime. +Yes, dunder strings should not be used inflationary because python might use them at a later time. But if python is going to use __citation__, then it will be for a similar purpose. Also, I deem the relative costs higher with the other options.",1.2,True,1,6002 +2019-03-18 14:05:53.610,How to see the full previous command in Pycharm Python console using a shortcut,"I was wondering how I could see the history in the Pycharm Python console using a shortcut. I can see the history using the upper arrow key, but If I want to go further back in history I have to go to each individual line if more lines are ran at the time. Is it possible that each time I press a button the full previous commands that are ran are shown? +I don't want to search in history, I want to go back in history similar using arrow up key but each time I enter arrow up I want to see the previous full code that was ran.","Go to preferences -> Appereance & Behaviour -> Keymap. You can search for ""Browse Console History"" and add a keyboard shortcut with right click -> Add Keyboard shortcut.",0.0,False,1,6003 +2019-03-18 17:28:51.877,Python how to to make set of rules for each class in a game,"in C# we have to get/set to make rules, but I don't know how to do this in Python. +Example: +Orcs can only equip Axes, other weapons are not eligible +Humans can only equip swords, other weapons are eligible. +How can I tell Python that an Orc cannot do something like in the example above? +Thanks for answers in advance, hope this made any sense to you guys.","Python language doesn't have an effective mechanism for restricting access to an instance or method. There is a convention though, to prefix the name of a field/method with an underscore to simulate ""protected"" or ""private"" behavior. +But, all members in a Python class are public by default.",0.0,False,1,6004 +2019-03-18 18:58:53.487,"Regex to get key words, all digits and periods","My input text looks like this: + +Put in 3 extenders but by the 4th floor it is weak on signal these don't piggy back of each other. ST -99. 5G DL 624.26 UP 168.20 4g DL 2 + Up .44 + +I am having difficulty writing a regex that will match any instances of 4G/5G/4g/5g and give me all the corresponding measurements after the instances of these codes, which are numbers with decimals. +The output should be: + +5G 624.26 168.20 4g 2 .44 + +Any thoughts how to achieve this? I am trying to do this analysis in Python.","I would separate it in different capture group like this: +(?i)(?P5?4?G)\sDL\s(?P[^\s]*)\sUP\s(?P[^\s]*) +(?i) makes the whole regex case insensitive +(?P5?4?G) is the first group matching on either 4g, 5g, 4G or 5G. +(?P[^\s]*) is the second and third group matching on everything that is not a space. +Then in Python you can do: +match = re.match('(?i)(?P5?4?G)\sDL\s(?P[^\s]*)\sUP\s(?P[^\s]*)', input) +And access each group like so: +match.group('g1') etc.",0.1352210990936997,False,1,6005 +2019-03-19 03:35:02.983,"In Zapier, how do I get the inputs to my Python ""Run Code"" action to be passed in as lists and not joined strings?","In Zapier, I have a ""Run Python"" action triggered by a ""Twitter"" event. One of the fields passed to me by the Twitter event is called ""Entities URLs Display URL"". It's the list of anchor texts of all of the links in the tweet being processed. +Zapier is passing this value into my Python code as a single comma-separated string. I know I can use .split(',') to get a list, but this results in ambiguity if the original strings contained commas. +Is there some way to get Zapier to pass this sequence of strings into my code as a sequence of strings rather than as a single joined-together string?","David here, from the Zapier Platform team. +At this time, all inputs to a code step are coerced into strings due to the way data is passed between zap steps. This is a great request though and I'll make a note of it internally.",0.6730655149877884,False,1,6006 +2019-03-19 07:09:31.563,"Where is the tesseract executable file located on MacOS, and how to define it in Python?","I have made a code using pytesseract and whenever I run it, I get this error: +TesseractNotFoundError: tesseract is not installed or it's not in your path +I have installed tesseract using HomeBrew and also pip installed it.","If installed with Homebrew, it will be located in /usr/local/bin/tesseract by default. To verify this, run which tesseract in the terminal as Dmitrrii Z. mentioned. +If it's there, you can set it up in your python environment by adding the following line to your python script, after importing the library: +pytesseract.pytesseract.tesseract_cmd = r'/usr/local/bin/tesseract'",0.6730655149877884,False,1,6007 +2019-03-19 09:10:22.167,Call function from file that has already imported the current file,"If I have the files frame.py and bindings.py both with classes Frame and Bindings respectively inside of them, I import the bindings.py file into frame.py by using from bindings import Bindings but how do I go about importing the frame.py file into my bindings.py file. If I use import frame or from frame import Frame I get the error ImportError: cannot import name 'Bindings' from 'bindings'. Is there any way around this without restructuring my code?",Instead of using from bindings import Bindings try import bindings.,0.0,False,1,6008 +2019-03-20 10:03:02.943,How to only enter a date that is a weekday in Python,"I'm creating a web applcation in Python and I only want the user to be able to enter a weekday that is older than today's date. I've had a look at isoweekday() for example but don't know how to integrate it into a flask form. The form currently looks like this: +appointment_date = DateField('Appointment Date', format='%Y-%m-%d', validators=[DataRequired()]) +Thanks","If you just want a weekday, you should put a select or a textbox, not a date picker. +If you put a select, you can disable the days before today so you don't even need a validation",0.0,False,1,6009 +2019-03-20 23:43:33.130,Speed up access to python programs from Golang's exec packaqe,"I need suggestions on how to speed up access to python programs when called from Golang. I really need fast access time (very low latency). +Approach 1: +func main() { +... +... + cmd = exec.Command(""python"", ""test.py"") + o, err = cmd.CombinedOutput() +... +} +If my test.py file is a basic print ""HelloWorld"" program, the execution time is over 50ms. I assume most of the time is for loading the shell and python in memory. +Approach 2: +The above approach can be speeded up substantially by having python start a HTTP server and then gaving the Go code POST a HTTP request and get the response from the HTTP server (python). Speeds up response times to less than 5ms. +I guess the main reason for this is probably because the python interpretor is already loaded and warm in memory. +Are there other approaches I can use similar to approach 2 (shared memory, etc.) which could speed up the response from my python code?. Our application requires extremely low latency and the 50 ms I am currently seeing from using Golang's exec package is not going to cut it. +thanks,","Approach 1: Simple HTTP server and client +Approach 2: Local socket or pipe +Approach 3: Shared memory +Approach 4: GRPC server and client +In fact, I prefer the GRPC method by stream way, it will hold the connection (because of HTTP/2), it's easy, fast and secure. And it's easy moving python node to another machine.",0.0,False,1,6010 +2019-03-21 20:01:04.153,Python: Iterate through every pixel in an image for image recognition,"I'm a newbie in image processing and python in general. For an image recognition project, I want to compare every pixel with one another. For that, I need to create a program that iterates through every pixel, takes it's value (for example ""[28, 78, 72]"") and creates some kind of values through comparing it to every other pixel. I did manage to access one single number in an array element /pixel (output: 28) through a bunch of for loops, but I just couldn't figure out how to access every number in every pixel, in every row. Does anyone know a good algorithm to solve my problem? I use OpenCV for reading in the image by the way.","Comparing every pixel with a ""pattern"" can be done with convolution. You should take a look at Haar cascade algorithm.",0.0,False,1,6011 +2019-03-21 20:38:04.357,numpy.savetxt() rounding values,"I'm using numpy.savetxt() to save an array, but its rounding my values to the first decimal point, which is a problem. anyone have any clue how to change this?","You can set the precision through changing fmt parameter. For example np.savetxt('tmp.txt',a, fmt='%1.3f') would leave you with an output with the precision of first three decimal points",0.3869120172231254,False,1,6012 +2019-03-22 03:06:43.583,Training SVM in Python with pictures,"I have basic knowledge of SVM, but now I am working with images. I have images in 5 folders, each folder, for example, has images for letters a, b, c, d, e. The folder 'a' has images of handwriting letters for 'a, folder 'b' has images of handwriting letters for 'b' and so on. +Now how can I use the images as my training data in SVM in Python.","as far i understood you want to train your svm to classify these images into the classes named a,b,c,d . For that you can use any of the good image processing techniques to extract features (such as HOG which is nicely implemented in opencv) from your image and then use these features , and the label as the input to your SVM training (the corresponding label for those would be the name of the folders i.e a,b,c,d) you can train your SVM using the features only and during the inference time , you can simply calculate the HOG feature of the image and feed it to your SVM and it will give you the desired output.",0.0,False,1,6013 +2019-03-22 12:32:50.940,How to execute script from container within another container?,"I have a contanarized flask app with external db, that logs users on other site using selenium. Everything work perfectly in localhost. I want to deploy this app using containers and found selenium container with google chrome within could make the job. And my question is: how to execute scripts/methods from flask container in selenium container? I tried to find some helpful info, but I didn't find anything. +Should I make an API call from selenium container to flask container? Is it the way or maybe something different?","As far as i understood, you are trying to take your local implementation, which runs on your pc and put it into two different docker containers. Then you want to make a call from the selenium container to your container containing the flask script which connects to your database. +In this case, you can think of your containers like two different computers. You can tell docker do create an internal network between these two containers and send the request via API call, like you suggested. But you are not limited to this approach, you can use any technique, that works for two computers to exchange commands.",1.2,True,1,6014 +2019-03-22 21:15:34.407,Visual Studio doesn't work with Anaconda environment,"I downloaded VS2019 preview to try how it works with Python. +I use Anaconda, and VS2019 sees the Anaconda virtual environment, terminal opens and works but when I try to launch 'import numpy', for example, I receive this: + +An internal error has occurred in the Interactive window. Please + restart Visual Studio. Intel MKL FATAL ERROR: Cannot load + mkl_intel_thread.dll. The interactive Python process has exited. + +Does anyone know how to fix it?","I had same issue, this worked for me: +Try to add conda-env-root/Library/bin to the path in the run environment.",0.0,False,1,6015 +2019-03-24 17:23:41.657,Automatically filled field in model,"I have some model where there are date field and CharField with choices New or Done, and I want to show some message for this model objects in my API views if 2 conditions are met, date is past and status is NEW, but I really don't know how I should resolve this. +I was thinking that maybe there is option to make some field in model that have choices and set suitable choice if conditions are fulfilled but I didn't find any information if something like this is possible so maybe someone have idea how resolve this?","You need override the method save of your model. An overrided method must check the condition and show message +You may set the signal receiver on the post_save signal that does the same like (1).",0.0,False,1,6016 +2019-03-25 03:15:40.920,how to drop multiple (~5000) columns in the pandas dataframe?,"I have a dataframe with 5632 columns, and I only want to keep 500 of them. I have the columns names (that I wanna keep) in a dataframe as well, with the names as the row index. Is there any way to do this?","Let us assume your DataFrame is named as df and you have a list cols of column indices you want to retain. Then you should use: +df1 = df.iloc[:, cols] +This statement will drop all the columns other than the ones whose indices have been specified in cols. Use df1 as your new DataFrame.",0.0,False,1,6017 +2019-03-26 17:26:01.377,How to configure PuLP to call GLPK solver,"I am using the PuLP library in Python to solve an MILP problem. I have run my problem successfully with the default solver (CBC). Now I would like to use PuLP with another solver (GLPK). How do I set up PuLP with GLPK? +I have done some research online and found information on how to use GLPK (e.g. with lp_prob.solve(pulp.GLPK_CMD())) but haven't found information on how to actually set up PuLP with GLPK (or any other solver for that matter), so that it finds my GLPK installation. I have already installed GLPK seperately (but I didn't add it to my PATH environment variable). +I ran the command pulp.pulpTestAll() +and got: +Solver unavailable +I know that I should be getting a ""passed"" instead of an ""unavailable"" to be able to use it.","I had same problem, but is not related with glpk installation, is with solution file create, the message is confusim. My problem was I use numeric name for my variables, as '0238' ou '1342', I add a 'x' before it, then they looked like 'x0238'.",0.2012947653214861,False,2,6018 +2019-03-26 17:26:01.377,How to configure PuLP to call GLPK solver,"I am using the PuLP library in Python to solve an MILP problem. I have run my problem successfully with the default solver (CBC). Now I would like to use PuLP with another solver (GLPK). How do I set up PuLP with GLPK? +I have done some research online and found information on how to use GLPK (e.g. with lp_prob.solve(pulp.GLPK_CMD())) but haven't found information on how to actually set up PuLP with GLPK (or any other solver for that matter), so that it finds my GLPK installation. I have already installed GLPK seperately (but I didn't add it to my PATH environment variable). +I ran the command pulp.pulpTestAll() +and got: +Solver unavailable +I know that I should be getting a ""passed"" instead of an ""unavailable"" to be able to use it.","After reading in more detail the code and testing out some things, I finally found out how to use GLPK with PuLP, without changing anything in the PuLP package itself. +Your need to pass the path as an argument to GLPK_CMD in solve as follows (replace with your glpsol path): +lp_prob.solve(GLPK_CMD(path = 'C:\\Users\\username\\glpk-4.65\\w64\\glpsol.exe') +You can also pass options that way, e.g. +lp_prob.solve(GLPK_CMD(path = 'C:\\Users\\username\\glpk-4.65\\w64\\glpsol.exe', options = [""--mipgap"", ""0.01"",""--tmlim"", ""1000""])",1.2,True,2,6018 +2019-03-26 23:03:52.333,Tower of colored cubes,"Consider a set of n cubes with colored facets (each one with a specific color +out of 4 possible ones - red, blue, green and yellow). Form the highest possible tower of k cubes ( k ≤ n ) properly rotated (12 positions of a cube), so the lateral faces of the tower will have the same color, using and evolutionary algorithm. +What I did so far: +I thought that the following representation would be suitable: an Individual could be an array of n integers, each number having a value between 1 and 12, indicating the current position of the cube (an input file contains n lines, each line shows information about the color of each face of the cube). +Then, the Population consists of multiple Individuals. +The Crossover method should create a new child(Individual), containing information from its parents (approximately half from each parent). +Now, my biggest issue is related to the Mutate and Fitness methods. +In Mutate method, if the probability of mutation (say 0.01), I should change the position of a random cube with other random position (for example, the third cube can have its position(rotation) changed from 5 to 12). +In Fitness method, I thought that I could compare, two by two, the cubes from an Individual, to see if they have common faces. If they have a common face, a ""count"" variable will be incremented with the number of common faces and if all the 4 lateral faces will be the same for these 2 cubes, the count will increase with another number of points. After comparing all the adjacent cubes, the count variable is returned. Our goal is to obtain as many adjacent cubes having the same lateral faces as we can, i.e. to maximize the Fitness method. +My question is the following: +How can be a rotation implemented? I mean, if a cube changes its position(rotation) from 3, to 10, how do we know the new arrangement of the faces? Or, if I perform a mutation on a cube, what is the process of rotating this cube if a random rotation number is selected? +I think that I should create a vector of 6 elements (the colors of each face) for each cube, but when the rotation value of a cube is modified, I don't know in what manner the elements of its vector of faces should be rearranged. +Shuffling them is not correct, because by doing this, two opposite faces could become adjacent, meaning that the vector doesn't represent that particular cube anymore (obviously, two opposite faces cannot be adjacent).","First, I'm not sure how you get 12 rotations; I get 24: 4 orientations with each of the 6 faces on the bottom. Use a standard D6 (6-sided die) and see how many different layouts you get. +Apparently, the first thing you need to build is a something (a class?) that accurately represents a cube in any of the available orientations. I suggest that you use a simple structure that can return the four faces in order -- say, front-right-back-left -- given a cube and the rotation number. +I think you can effectively represent a cube as three pairs of opposing sides. Once you've represented that opposition, the remaining organization is arbitrary numbering: any valid choice is isomorphic to any other. Each rotation will produce an interleaved sequence of two opposing pairs. For instance, a standard D6 has opposing pairs [(1, 6), (2, 5), (3, 4)]. The first 8 rotations would put 1 and 6 on the hidden faces (top and bottom), giving you the sequence 2354 in each of its 4 rotations and their reverses. +That class is one large subsystem of your problem; the other, the genetic algorithm, you seem to have well in hand. Stack all of your cubes randomly; ""fitness"" is a count of the most prevalent 4-show (sequence of 4 sides) in the stack. At the start, this will generally be 1, as nothing will match. +From there, you seem to have an appropriate handle on mutation. You might give a higher chance of mutating a non-matching cube, or perhaps see if some cube is a half-match: two opposite faces match the ""best fit"" 4-show, so you merely rotate it along that axis, preserving those two faces, and swapping the other pair for the top-bottom pair (note: two directions to do that). +Does that get you moving?",0.0,False,1,6019 +2019-03-27 20:20:56.763,Airflow: How to download file from Linux to Windows via smbclient,"I have a DAG that imports data from a source to a server. From there, I am looking to download that file from the server to the Windows network. I would like to keep this part in Airflow for automation purposes. Does anyone know how to do this in Airflow? I am not sure whether to use the os package, the shutil package, or maybe there is a different approach.","I think you're saying you're looking for a way to get files from a cloud server to a windows shared drive or onto a computer in the windows network, these are some options I've seen used: + +Use a service like google drive, dropbox, box, or s3 to simulate a synced folder on the cloud machine and a machine in the windows network. +Call a bash command to SCP the files to the windows server or a worker in the network. This could work in the opposite direction too. +Add the files to a git repository and have a worker in the windows network sync the repository to a shared location. This option is only good in very specific cases. It has the benefit that you can track changes and restore old states (if the data is in CSV or another text format), but it's not great for large files or binary files. +Use rsync to transfer the files to a worker in the windows network which has the shared location mounted and move the files to the synced dir with python or bash. +Mount the network drive to the server and use python or bash to move the files there. + +All of these should be possible with Airflow by either using python (shutil) or a bash script to transfer the files to the right directory for some other process to pick up or by calling a bash sub-process to perform the direct transfer by SCP or commit the data via git. You will have to find out what's possible with your firewall and network settings. Some of these would require coordinating tasks on the windows side (the git option for example would require some kind of cron job or task scheduler to pull the repository to keep the files up to date).",0.0,False,1,6020 +2019-03-29 18:04:09.080,Python GTK+ 3: Is it possible to make background window invisible?,"basically I have this window with a bunch of buttons but I want the background of the window to be invisible/transparent so the buttons are essentially floating. However, GTK seems to be pretty limited with CSS and I haven't found a way to do it yet. I've tried making the main window opacity 0 but that doesn't seem to work. Is this even possible and if so how can I do it? Thanks. +Edit: Also, I'm using X11 forwarding.",For transparency Xorg requires a composite manager running on the X11 server. The compmgr program from Xorg is a minimal composite manager.,0.0,False,1,6021 +2019-03-30 18:02:10.470,Matplotlib with Pydroid 3 on Android: how to see graph?,"I'm currently using an Android device (of Samsung), Pydroid 3. +I tried to see any graphs, but it doesn't works. +When I run the code, it just shows me a black-blank screen temporarily and then goes back to the source code editing window. +(means that i can't see even terminal screen, which always showed me [Program Finished]) +Well, even the basic sample code which Pydroid gives me doesn't show me the graph :( +I've seen many tutorials which successfully showed graphs, but well, mine can't do that things. +Unfortunately, cannot grab any errors. +Using same code which worked at Windows, so don't think the code has problem. +Of course, matplotlib is installed, numpy is also installed. +If there's any possible problems, please let me know.","I also had this problem a while back, and managed to fix it by using plt.show() +at the end of your code. With matplotlib.pyplot as plt.",0.1016881243684853,False,3,6022 +2019-03-30 18:02:10.470,Matplotlib with Pydroid 3 on Android: how to see graph?,"I'm currently using an Android device (of Samsung), Pydroid 3. +I tried to see any graphs, but it doesn't works. +When I run the code, it just shows me a black-blank screen temporarily and then goes back to the source code editing window. +(means that i can't see even terminal screen, which always showed me [Program Finished]) +Well, even the basic sample code which Pydroid gives me doesn't show me the graph :( +I've seen many tutorials which successfully showed graphs, but well, mine can't do that things. +Unfortunately, cannot grab any errors. +Using same code which worked at Windows, so don't think the code has problem. +Of course, matplotlib is installed, numpy is also installed. +If there's any possible problems, please let me know.","After reinstalling it worked. +The problem was that I forced Pydroid to update matplotlib via Terminal, not the official PIP tab. +The version of matplotlib was too high for pydroid",1.2,True,3,6022 +2019-03-30 18:02:10.470,Matplotlib with Pydroid 3 on Android: how to see graph?,"I'm currently using an Android device (of Samsung), Pydroid 3. +I tried to see any graphs, but it doesn't works. +When I run the code, it just shows me a black-blank screen temporarily and then goes back to the source code editing window. +(means that i can't see even terminal screen, which always showed me [Program Finished]) +Well, even the basic sample code which Pydroid gives me doesn't show me the graph :( +I've seen many tutorials which successfully showed graphs, but well, mine can't do that things. +Unfortunately, cannot grab any errors. +Using same code which worked at Windows, so don't think the code has problem. +Of course, matplotlib is installed, numpy is also installed. +If there's any possible problems, please let me know.","You just need to add a line +plt.show() +Then it will work. You can also save the file before showing +plt.savefig(""*imageName*.png"")",0.0,False,3,6022 +2019-03-31 02:36:13.693,"Accidentally used homebrew to change my default python to 3.7, how do I change it back to 2.7?","I was trying to install python 3 because I wanted to work on a project using python 3. Instructions I'd found were not working, so I boldly ran brew install python. Wrong move. Now when I run python -V I get ""Python 3.7.3"", and when I try to enter a virtualenv I get -bash: /Users/elliot/Library/Python/2.7/bin/virtualenv: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory +My ~/.bash_profile reads +export PATH=""/Users/elliot/Library/Python/2.7/bin:/usr/local/opt/python/libexec/bin:/Library/PostgreSQL/10/bin:$PATH"" +but ls /usr/local/Cellar/python/ gets me 3.7.3 so it seems like brew doesn't even know about my old 2.7 version anymore. +I think what I want is to reset my system python to 2.7, and then add python 3 as a separate python running on my system. I've been googling, but haven't found any advice on how to specifically use brew to do this. +Edit: I'd also be happy with keeping Python 3.7, if I knew how to make virtualenv work again. I remember hearing that upgrading your system python breaks everything, but I'd be super happy to know if that's outdated knowledge and I'm just being a luddite hanging on to 2.7.","So, I got through it by completely uninstalling Python, which I'd been reluctant to do, and then reinstalled Python 2. I had to update my path and open a new shell to get it to see the new python 2 installation, and things fell into place. I'm now using pyenv for my Python 3 project, and it's a dream.",0.0,False,1,6023 +2019-03-31 06:41:35.623,How does one transfer python code written in a windows laptop to a samsung android phone?,"I created numerous python scripts on my pc laptop, and I want to run those scripts on my android phone. How can I do that? How can I move python scripts from my windows pc laptop, and use those python scripts on my samsung adroid phone? +I have downloaded qpython from the google playstore, but I still don't know how to get my pc python programs onto my phone. I heard some people talk about ""ftp"" but I don't even know what that means. +Thanks","Send them to yourself via email, then download the scripts onto your phone and run them through qpython. +However you have to realize not all the modules on python work on qpython so your scripts may not work the same when you transfer them.",0.0,False,2,6024 +2019-03-31 06:41:35.623,How does one transfer python code written in a windows laptop to a samsung android phone?,"I created numerous python scripts on my pc laptop, and I want to run those scripts on my android phone. How can I do that? How can I move python scripts from my windows pc laptop, and use those python scripts on my samsung adroid phone? +I have downloaded qpython from the google playstore, but I still don't know how to get my pc python programs onto my phone. I heard some people talk about ""ftp"" but I don't even know what that means. +Thanks","you can use TeamViewer to control your android phone from your PC. And copy and paste the code easily. +or +You can transfer your scripts on your phone memory in the qpython folder and open it using qpython for android.",0.0,False,2,6024 +2019-04-01 16:47:12.417,how to find text before and after given words and output into different text files?,"I have a text file like this: + +... + NAME : name-1 + ... + NAME : name-2 + ... + ... + ... + NAME : name-n + ... + +I want output text files like this: + +name_1.txt : NAME : name-1 ... + name_2.txt : NAME : name-2 ... + ... + name_n.txt : NAME : name-n ... + +I have the basic knowledge of grep, sed, awk, shell scripting, python.","With GNU sed: +sed ""s/\(.*\)\(name-.*\)/echo '\1 \2' > \2.txt/;s/-/_/2e"" input-file + +Turn line NAME : name-2 into echo ""NAME : name-2"" > name-2.txt +Then replace the second - with _ yielding echo ""NAME : name-2"" > name_2.txt +e have the shell run the command constructed in the pattern buffer. + +This outputs blank lines to stdout, but creates a file for each matching line. +This depends on the file having nothing but lines matching this format... but you can expand the gist here to skip other lines with n.",0.0,False,1,6025 +2019-04-02 09:36:07.253,"Unable to parse the rows in ResultSet returned by connection.execute(), Python and SQLAlchemy","I have a task to compare data of two tables in two different oracle databases. We have access of views in both of db. Using SQLAlchemy ,am able to fetch rows from views but unable to parse it. +In one db the type of ID column is : Raw +In db where column type is ""Raw"", below is the row am getting from resultset . +(b'\x0b\x975z\x9d\xdaF\x0e\x96>[Ig\xe0/', 1, datetime.datetime(2011, 6, 7, 12, 11, 1), None, datetime.datetime(2011, 6, 7, 12, 11, 1), b'\xf2X\x8b\x86\x03\x00K|\x99(\xbc\x81n\xc6\xd3', None, 'I', 'Inactive') +ID Column data: b'\x0b\x975z\x9d\xdaF\x0e\x96>[_Ig\xe0/' +Actual data in ID column in database: F2588B8603004B7C9928BC816EC65FD3 +This data is not complete hexadecimal format as it has some speical symbols like >|[_ etc. I want to know that how can I parse the data in ID column and get it as a string.",bytes.hex() solved the problem,1.2,True,1,6026 +2019-04-02 12:30:37.360,How to install Python packages from python3-apt in PyCharm on Windows?,"I'm on Windows and want to use the Python package apt_pkg in PyCharm. +On Linux I get the package by doing sudo apt-get install python3-apt but how to install apt_pkg on Windows? +There is no such package on PyPI.",There is no way to run apt-get in Windows; the package format and the supporting infrastructure is very explicitly Debian-specific.,0.2012947653214861,False,1,6027 +2019-04-03 14:59:12.000,“Close and Halt” feature does not functioning in jupyter notebook launched under Canopy on macOs High Sierra,"When I done with my work, I try to close my jupyter notebook via 'Close and Halt' under the file menu. However it somehow do not functioning. +I am running the notebook from Canopy, version: 2.1.9.3717, under macOs High Sierra.","If you are running Jupyter notebook from Canopy, then the Jupyter notebook interface is not controlling the kernel; rather, Canopy's built-in ipython Qtconsole is. You can restart the kernel from the Canopy run menu.",0.3869120172231254,False,1,6028 +2019-04-03 17:51:59.123,Running an external Python script on a Django site,"I have a Python script which communicates with a Financial site through an API. I also have a Django site, i would like to create a basic form on my site where i input something and, according to that input, my Python script should perform some operations. +How can i do this? I'm not asking for any code, i just would like to understand how to accomplish this. How can i ""run"" a python script on a Django project? Should i make my Django project communicate with the script through a post request? Or is there a simpler way?","Since you don't want code, and you didn't get detailed on everything required required, here's my suggestion: + +Make sure your admin.py file has editable fields for the model you're using. +Make an admin action, +Take the selected row with the values you entered, and run that action with the data you entered. + +I would be more descriptive, but I'd need more details to do so.",0.3869120172231254,False,2,6029 +2019-04-03 17:51:59.123,Running an external Python script on a Django site,"I have a Python script which communicates with a Financial site through an API. I also have a Django site, i would like to create a basic form on my site where i input something and, according to that input, my Python script should perform some operations. +How can i do this? I'm not asking for any code, i just would like to understand how to accomplish this. How can i ""run"" a python script on a Django project? Should i make my Django project communicate with the script through a post request? Or is there a simpler way?","I agree with @Daniel Roseman +If you are looking for your program to be faster, maybe multi-threading would be useful.",0.0,False,2,6029 +2019-04-04 02:39:46.887,Tracking any change in an table on SQL Server With Python,"How are you today? +I'm a newbie in Python. I'm working with SQL server 2014 and Python 3.7. So, my issue is: When any change occurs in a table on DB, I want to receive a message (or event, or something like that) on my server (Web API - if you like this name). +I don't know how to do that with Python. +I have an practice (an exp. maybe). I worked with C# and SQL Server, and in this case, I used ""SQL Dependency"" method in C# to solve that. It's really good! +Have something like that in Python? Many thank for any idea, please! +Thank you so much.","I do not know many things about SQL. But I guess there are tools for SQL to detect those changes. And then you could create an everlasting loop thread using multithreading package to capture that change. (Remember to use time.sleep() to block your thread so that It wouldn't occupy the CPU for too long.) Once you capture the change, you could call the function that you want to use. (Actually, you could design a simple event engine to do that). I am a newbie in Computer Science and I hope my answer is correct and helpful. :)",0.0,False,1,6030 +2019-04-04 07:59:55.183,virtual real time limit (178/120s) reached,"I am using ubuntu 16 version and running Odoo erp system 12.0 version. +On my application log file i see information says ""virtual real time limit (178/120s) reached"". +What exactly it means & what damage it can cause to my application? +Also how i can increase the virtual real time limit?","Open your config file and just add below parameter : +--limit-time-real=100000",0.9866142981514304,False,1,6031 +2019-04-04 15:23:10.660,How to handle multiple major versions of dependency,"I'm wondering how to handle multiple major versions of a dependency library. +I have an open source library, Foo, at an early release stage. The library is a wrapper around another open source library, Bar. Bar has just launched a new major version. Foo currently only supports the previous version. As I'm guessing that a lot of people will be very slow to convert from the previous major version of Bar to the new major version, I'm reluctant to switch to the new version myself. +How is this best handled? As I see it I have these options + +Switch to the new major version, potentially denying people on the old version. +Keep going with the old version, potentially denying people on the new version. +Have two different branches, updating both branches for all new features. Not sure how this works with PyPi. Wouldn't I have to release at different version numbers each time? +Separate the repository into two parts. Don't really want to do this. + +The ideal solution for me would be to have the same code base, where I could have some sort of C/C++ macro-like thing where if the version is new, use new_bar_function, else use old_bar_function. When installing the library from PyPi, the already installed version of the major version dictates which version is used. If no version is installed, install the newest. +Would much appreciate some pointers.","Have two different branches, updating both branches for all new features. Not sure how this works with PyPI. Wouldn't I have to release at different version numbers each time? + +Yes, you could have a 1.x release (that supports the old version) and a 2.x release (that supports the new version) and release both simultaneously. This is a common pattern for packages that want to introduce a breaking change, but still want to continue maintaining the previous release as well.",0.2012947653214861,False,1,6032 +2019-04-05 16:28:56.133,How do apply Q-learning to an OpenAI-gym environment where multiple actions are taken at each time step?,"I have successfully used Q-learning to solve some classic reinforcement learning environments from OpenAI Gym (i.e. Taxi, CartPole). These environments allow for a single action to be taken at each time step. However I cannot find a way to solve problems where multiple actions are taken simultaneously at each time step. For example in the Roboschool Reacher environment, 2 torque values - one for each axis - must be specify at each time step. The problem is that the Q matrix is built from (state, action) pairs. However, if more than one action are taken simultaneously, it is not straightforward to build the Q matrix. +The book ""Deep Reinforcement Learning Hands-On"" by Maxim Lapan mentions this but does not give a clear answer, see quotation below. + +Of course, we're not limited to a single action to perform, and the environment could have multiple actions, such as pushing multiple buttons simultaneously or steering the wheel and pressing two pedals (brake and accelerator). To support such cases, Gym defines a special container class that allows the nesting of several action spaces into one unified action. + +Does anybody know how to deal with multiple actions in Q learning? +PS: I'm not talking about the issue ""continuous vs discrete action space"", which can be tackled with DDPG.","You can take one of two approaches - depend on the problem: + +Think of the set of actions you need to pass to the environment as independent and make the network output actions values for each one (make softmax separately) - so if you need to pass two actions, the network will have two heads, one for each axis. +Think of them as dependent and look on the Cartesian product of the sets of actions, and then make the network to output value for each product - so if you have two actions that you need to pass and 5 options for each, the size of output layer will be 2*5=10, and you just use softmax on that.",0.6730655149877884,False,1,6033 +2019-04-06 19:50:46.103,How to install python3.6 in parallel with python 2.7 in Ubuntu 18,Setting up to start python for data analytics and want to install python 3.6 in Ubuntu 18.0 . Shall i run both version in parallel or overwrite 2.7 and how ? I am getting ambiguous methods when searched up.,Try pyenv and/or pipenv . Both are excellent tools to maintain local python installations.,0.0,False,1,6034 +2019-04-07 08:00:53.180,how to display the month in from view ? (Odoo11),"please, how do I display the month in the form? example: +07/04/2019 i want to change it in 07 april, 2019 +Thank you in advance","Try with following steps: + +Go to Translations > Languages +Open record with your current language. +Edit date format with %d %A, %Y",0.3869120172231254,False,1,6035 +2019-04-07 14:08:01.350,How to fix print((double parentheses)) after 2to3 conversion?,"When migrating my project to Python 3 (2to3-3.7 -w -f print *), I observed that a lot of (but not all) print statements became print((...)), so these statements now print tuples instead of performing the expected behavior. I gather that if I'd used -p, I'd be in a better place right now because from __future__ import print_function is at the top of every affected module. +I'm thinking about trying to use sed to fix this, but before I break my teeth on that, I thought I'd see if anyone else has dealt with this before. Is there a 2to3 feature to clean this up? +I do use version control (git) and have commits immediately before and after (as well as the .bak files 2to3 creates), but I'm not sure how to isolate the changes I've made from the print situations.",If your code already has print() functions you can use the -x print argument to 2to3 to skip the conversion.,0.6133572603953825,False,1,6036 +2019-04-08 06:39:59.923,"Windowed writes in python, e.g. to NetCDF","In python how can I write subsets of an array to disk, without holding the entire array in memory? +The xarray input/output docs note that xarray does not support incremental writes, only incremental reads except by streaming through dask.array. (Also that modifying a dataset only affects the in-memory copy, not the connected file.) The dask docs suggest it might be necessary to save the entire array after each manipulation?","This can be done using netCDF4 (the python library of low level NetCDF bindings). Simply assign to a slice of a dataset variable, and optionally call the dataset .sync() method afterward to ensure no delay before those changes are flushed to the file. +Note this approach also provides the opportunity to progressively grow a dimension of the array (by calling createDimension with size None, making it the first dimension of a variable, and iteratively assigning to incrementally larger indices along that dimension of the variable). +Although random-access window (i.e. subset) writes appear to require the lower level package, more systematic subset writes (eventually covering the entire array) can be done incrementally with xarray (by specifying a chunk size parameter to trigger use of the dask.array backend), and provided that your algorithm is refactored so that the main loop occurs in the dask/xarray store-to-file call. This means you will not have explicit control over the sequence in which chunks are generated and written.",0.0,False,1,6037 +2019-04-08 14:03:38.120,Is there any way to hide or encrypt your python code for edge devices? Any way to prevent reverse engineering of python code?,"I am trying to make a smart IOT device (capable of performing smart Computer Vision operations, on the edge device itself). A Deep Learning algorithm (written in python) is implemented on Raspberry Pi. Now, while shipping this product (software + hardware) to my customer, I want that no one should log in to the raspberry pi and get access to my code. The flow should be something like, whenever someone logs into pi, there should be some kind of key that needs to be input to get access to code. But in that case how OS will get access to code and run it (without key). Then I may have to store the key on local. But still there is a chance to get access to key and get access to the code. I have applied a patent for my work and want to protect it. +I am thinking to encrypt my code (written in python) and just ship the executable version. I tried pyinstaller for it, but somehow there is a script available on the internet that can reverse engineer it. +Now I am little afraid as it can leak all my effort of 6 months at one go. Please suggest a better way of doing this. +Thanks in Advance.","Keeping the code on your server and using internet access is the only way to keep the code private (maybe). Any type of distributed program can be taken apart eventually. You can't (possibly shouldn't) try to keep people from getting inside devices they own and are in their physical possession. If you have your property under patent it shouldn't really matter if people are able to see the code as only you will be legally able to profit from it. +As a general piece of advice, code is really difficult to control access to. Trying to encrypt software or apply software keys to it or something like that is at best a futile attempt and at worst can often cause issues with software performance and usability. The best solution is often to link a piece of software with some kind of custom hardware device which is necessary and only you sell. That might not be possible here since you're using generic hardware but food for thought.",-0.3869120172231254,False,1,6038 +2019-04-08 15:02:18.437,How to classify unlabelled data?,I am new to Machine Learning. I am trying to build a classifier that classifies the text as having a url or not having a url. The data is not labelled. I just have textual data. I don't know how to proceed with it. Any help or examples is appreciated.,"Since it's text, you can use bag of words technique to create vectors. + +You can use cosine similarity to cluster the common type text. +Then use classifier, which would depend on number of clusters. +This way you have a labeled training set. + +If you have two cluster, binary classifier like logistic regression would work. +If you have multiple classes, you need to train model based on multinomial logistic regression +or train multiple logistic models using One vs Rest technique. + +Lastly, you can test your model using k-fold cross validation.",0.2012947653214861,False,1,6039 +2019-04-08 16:54:25.427,Django - how to visualize signals and save overrides?,"As a project grows, so do dependencies and event chains, especially in overridden save() methods and post_save and pre_save signals. +Example: +An overridden A.save creates two related objects to A - B and C. When C is saved, the post_save signal is invoked that does something else, etc... +How can these event chins be made more clear? Is there a way to visualize (generate automatically) such chains/flows? I'm not looking for ERD nor a Class diagram. I need to be sure that doing one thing one place won't affect something on the other side of the project, so simple visualization would be the best. +EDIT +To be clear, I know that it would be almost impossible to check dynamically generated signals. I just want to check all (not dynamically generated) post_save, pre_save, and overridden save methods and visualize them so I can see immediately what is happening and where when I save something.","(Too long to fit into a comment, lacking code to be a complete answer) +I can't mock up a ton of code right now, but another interesting solution, inspired by Mario Orlandi's comment above, would be some sort of script that scans the whole project and searches for any overridden save methods and pre and post save signals, tracking the class/object that creates them. It could be as simple as a series of regex expressions that look for class definitions followed by any overridden save methods inside. +Once you have scanned everything, you could use this collection of references to create a dependency tree (or set of trees) based on the class name and then topologically sort each one. Any connected components would illustrate the dependencies, and you could visualize or search these trees to see the dependencies in a very easy, natural way. I am relatively naive in django, but it seems you could statically track dependencies this way, unless it is common for these methods to be overridden in multiple places at different times.",0.4540544406412981,False,1,6040 +2019-04-09 07:36:02.467,Capturing time between HTML form submit action and printing response,"I have a Python Flask application with a HTML form which accept few inputs from user, uses those in an python program which returns the processed values back to flask application return statement. +I wanted to capture the time took for whole processing and rendering output data on browser but not sure how to do that. At present I have captured the take by python program to process the input values but it doesn't account for complete time between ""submit"" action and rendering output data.",Use ajax request to submit form. Fetch the time on clicking the button and after getting the response and then calculate the difference.,0.0,False,1,6041 +2019-04-09 09:15:48.837,"How to extract images from PDF or Word, together with the text around images?","I found there are some library for extracting images from PDF or word, like docx2txt and pdfimages. But how can I get the content around the images (like there may be a title below the image)? Or get a page number of each image? +Some other tools like PyPDF2 and minecart can extract image page by page. However, I cannot run those code successfully. +Is there a good way to get some information of the images? (from the image got from docx2txt or pdfimages, or another way to extract image with info)",docx2python pulls the images into a folder and leaves -----image1.png---- markers in the extracted text. This might get you close to where you'd like to go.,0.0,False,1,6042 +2019-04-09 18:46:58.267,What is this audio datatype and how do I convert it to wav/l16?,"I am recording audio in a web browser and sending it to a flask backend. From there, I want to transcribe the audio using Watson Speech to Text. I cannot figure out what data format I'm receiving the audio and how to convert it to a format that works for watson. +I believe watson expects a bytestring like b'\x0c\xff\x0c\xffd. The data I receive from the browser looks like [ -4 -27 -34 -9 1 -8 -1 2 10 -28], which I can't directly convert to bytes because of the negative values (using bytes() gives me that error). +I'm really at a loss for what kind of conversion I need to be making here. Watson doesn't return any errors for any kind of data I throw at it just doesn't respond.","Those values should be fine, but you have to define how you want them stored before getting the bytes representation of them. +You'd simply want to convert those values to signed 2-byte/16-bit integers, then get the bytes representation of those.",1.2,True,1,6043 +2019-04-09 19:37:11.227,how do I implement ssim for loss function in keras?,"I need SSIM as a loss function in my network, but my network has 2 outputs. I need to use SSIM for first output and cross-entropy for the next. The loss function is a combination of them. However, I need to have a higher SSIM and lower cross-entropy, so I think the combination of them isn't true. Another problem is that I could not find an implementation of SSIM in keras. +Tensorflow has tf.image.ssim, but it accepts the image and I do not think I can use it in loss function, right? Could you please tell me what should I do? I am a beginner in keras and deep learning and I do not know how can I make SSIM as a custom loss function in keras.","other choice would be +ssim_loss = 1 - tf.reduce_mean(tf.image.ssim(target, output, max_val=self.max_val)) +then +combine_loss = mae (or mse) + ssim_loss +In this way, you are minimizing both of them.",0.0,False,1,6044 +2019-04-11 11:57:15.603,KMeans: Extracting the parameters/rules that fill up the clusters,"I have created a 4-cluster k-means customer segmentation in scikit learn (Python). The idea is that every month, the business gets an overview of the shifts in size of our customers in each cluster. +My question is how to make these clusters 'durable'. If I rerun my script with updated data, the 'boundaries' of the clusters may slightly shift, but I want to keep the old clusters (even though they fit the data slightly worse). +My guess is that there should be a way to extract the paramaters that decides which case goes to their respective cluster, but I haven't found the solution yet. +I would appreciate any help","Got the answer in a different topic: +Just record the cluster means. Then when new data comes in, compare it to each mean and put it in the one with the closest mean.",0.3869120172231254,False,1,6045 +2019-04-11 13:25:10.313,how to count number of days via cron job in odoo 10?,"I am setting up a script for counting number of days with passing each day in odoo. +How i can count day passing each day till end of the month. +For example : i have set two dates to find days between them.I need function which compare number of days with each passing day. When meet remaining day is 0 then will call a cron job.","Write a scheduled action that runs python code daily. The first thing that this code should do is to check the number of days you talk about and if it is 0, it should trigger whatever action it is needed.",0.0,False,1,6046 +2019-04-12 04:46:43.223,How to add reply(child comments) to comments on feed in getstream.io python,I am using getstream.io to create feeds. The user can follow feeds and add reaction like and comments. If a user adds a comment on feed and another wants to reply on the comment then how I can achieve this and also retrieve all reply on the comment.,you can add the child reaction by using reaction_id,0.0,False,1,6047 +2019-04-12 12:06:29.347,how to find the similarity between two documents,"I have tried using the similarity function of spacy to get the best matching sentence in a document. However it fails for bullet points because it considers each bullet as the a sentence and the bullets are incomplete sentences (eg sentence 1 ""password should be min 8 characters long , sentence 2 in form of a bullet "" 8 characters""). It does not know it is referring to password and so my similarity comes very low.","Bullets are considered but the thing is it doesn't understand who 8 characters is referring to so I thought of finding the heading of the paragraph and replacing the bullets with it +I found the headings using python docs but it doesn't read bullets while reading the document ,is there a way I can read it using python docs ? +Is there any way I can find the headings of a paragraph in spacy? +Is there a better approach for it",0.0,False,2,6048 +2019-04-12 12:06:29.347,how to find the similarity between two documents,"I have tried using the similarity function of spacy to get the best matching sentence in a document. However it fails for bullet points because it considers each bullet as the a sentence and the bullets are incomplete sentences (eg sentence 1 ""password should be min 8 characters long , sentence 2 in form of a bullet "" 8 characters""). It does not know it is referring to password and so my similarity comes very low.","Sounds to me like you need to do more text processing before attempting to use similarity. If you want bullet points to be considered part of a sentence, you need to modify your spacy pipeline to understand to do so.",0.0,False,2,6048 +2019-04-12 13:48:58.717,Trying to Import Infoblox Module in Python,"I am trying to write some code in python to retrieve some data from Infoblox. To do this i need to Import the Infoblox Module. +Can anyone tell me how to do this ?","Before you can import infoblox you need to install it: + +open a command prompt (press windows button, then type cmd) +if you are working in a virtual environment access it with activate yourenvname (otherwise skip this step) +execute pip install infoblox to install infoblox, then you should be fine +to test it from the command prompt, execute python, and then try executing import infoblox + +The same process works for basically every package.",0.0,False,1,6049 +2019-04-12 21:52:02.810,Why do I keep getting this error when trying to create a virtual environment with Python 3 on MacOS?,"So I'm following a book that's teaching me how to make a Learning Log using Python and the Django web framework. I was asked to go to a terminal and create a directory called ""learning_log"" and change the working directory to ""learning_log"" (did that with no problems). However, when I try to create the virtual environment, I get an error (seen at the bottom of this post). Why am I getting this error and how can I fix this to move forward in the book? +I already tried installing a virtualenv with pip and pip3 (as the book prescribed). I was then instructed to enter the command: +learning_log$ virtualenv ll_env +And I get: +bash: virtualenv: command not found +Since I'm using Python3.6, I tried: +learning_log$ virtualenv ll_env --python=python3 +And I still get: +bash: virtualenv: command not found +Brandons-MacBook-Pro:learning_log brandondusch$ python -m venv ll_env +Error: Command '['/Users/brandondusch/learning_log/ll_env/bin/python', '-Im', 'ensurepip', '--upgrade', '- +-default-pip']' returned non-zero exit status 1.","For Ubuntu: +The simple is if virtualenv --version returns something like virtualenv: command not found and which virtualenv prints nothing on the console, then virtualenv is not installed on your system. Please try to install using pip3 install virtualenv or sudo apt-get install virtualenv but this one might install a bit older one. +EDIT +For Mac: +For Mac, you need to install that using sudo pip install virtualenv after you have installed Python3 on your Mac.",0.0,False,2,6050 +2019-04-12 21:52:02.810,Why do I keep getting this error when trying to create a virtual environment with Python 3 on MacOS?,"So I'm following a book that's teaching me how to make a Learning Log using Python and the Django web framework. I was asked to go to a terminal and create a directory called ""learning_log"" and change the working directory to ""learning_log"" (did that with no problems). However, when I try to create the virtual environment, I get an error (seen at the bottom of this post). Why am I getting this error and how can I fix this to move forward in the book? +I already tried installing a virtualenv with pip and pip3 (as the book prescribed). I was then instructed to enter the command: +learning_log$ virtualenv ll_env +And I get: +bash: virtualenv: command not found +Since I'm using Python3.6, I tried: +learning_log$ virtualenv ll_env --python=python3 +And I still get: +bash: virtualenv: command not found +Brandons-MacBook-Pro:learning_log brandondusch$ python -m venv ll_env +Error: Command '['/Users/brandondusch/learning_log/ll_env/bin/python', '-Im', 'ensurepip', '--upgrade', '- +-default-pip']' returned non-zero exit status 1.","I had the same error. I restarted my computer and tried it again, but the error was still there. Then I tried python3 -m venv ll_env and it moved forward.",0.0,False,2,6050 +2019-04-13 11:57:31.263,How do I calculate the similarity of a word or couple of words compared to a document using a doc2vec model?,"In gensim I have a trained doc2vec model, if I have a document and either a single word or two-three words, what would be the best way to calculate the similarity of the words to the document? +Do I just do the standard cosine similarity between them as if they were 2 documents? Or is there a better approach for comparing small strings to documents? +On first thought I could get the cosine similarity from each word in the 1-3 word string and every word in the document taking the averages, but I dont know how effective this would be.","There's a number of possible approaches, and what's best will likely depend on the kind/quality of your training data and ultimate goals. +With any Doc2Vec model, you can infer a vector for a new text that contains known words – even a single-word text – via the infer_vector() method. However, like Doc2Vec in general, this tends to work better with documents of at least dozens, and preferably hundreds, of words. (Tiny 1-3 word documents seem especially likely to get somewhat peculiar/extreme inferred-vectors, especially if the model/training-data was underpowered to begin with.) +Beware that unknown words are ignored by infer_vector(), so if you feed it a 3-word documents for which two words are unknown, it's really just inferring based on the one known word. And if you feed it only unknown words, it will return a random, mild initialization vector that's undergone no inference tuning. (All inference/training always starts with such a random vector, and if there are no known words, you just get that back.) +Still, this may be worth trying, and you can directly compare via cosine-similarity the inferred vectors from tiny and giant documents alike. +Many Doc2Vec modes train both doc-vectors and compatible word-vectors. The default PV-DM mode (dm=1) does this, or PV-DBOW (dm=0) if you add the optional interleaved word-vector training (dbow_words=1). (If you use dm=0, dbow_words=0, you'll get fast training, and often quite-good doc-vectors, but the word-vectors won't have been trained at all - so you wouldn't want to look up such a model's word-vectors directly for any purposes.) +With such a Doc2Vec model that includes valid word-vectors, you could also analyze your short 1-3 word docs via their individual words' vectors. You might check each word individually against a full document's vector, or use the average of the short document's words against a full document's vector. +Again, which is best will likely depend on other particulars of your need. For example, if the short doc is a query, and you're listing multiple results, it may be the case that query result variety – via showing some hits that are really close to single words in the query, even when not close to the full query – is as valuable to users as documents close to the full query. +Another measure worth looking at is ""Word Mover's Distance"", which works just with the word-vectors for a text's words, as if they were ""piles of meaning"" for longer texts. It's a bit like the word-against-every-word approach you entertained – but working to match words with their nearest analogues in a comparison text. It can be quite expensive to calculate (especially on longer texts) – but can sometimes give impressive results in correlating alternate texts that use varied words to similar effect.",1.2,True,1,6051 +2019-04-14 15:12:05.933,operations order in Python,"I have just now started learning python from Learn Python 3 The Hard Way by Zed Shaw. In exercise 3 of the book, there was a problem to get the value of 100 - 25 * 3 % 4. The solution to this problem is already mentioned in the archives, in which the order preference is given to * and %(from left to right). +I made a problem on my own to get the value of 100 - 25 % 3 + 4. The answer in the output is 103. +I just wrote: print (""the value of"", 100 - 25 % 3 + 4), which gave the output value 103. +If the % is given the preference 25 % 3 will give 3/4. Then how the answer is coming 103. Do I need to mention any float command or something? +I would like to know how can I use these operations. Is there any pre-defined rule to solve these kinds of problems?",The % operator is used to find the remainder of a quotient. So 25 % 3 = 1 not 3/4.,0.0,False,2,6052 +2019-04-14 15:12:05.933,operations order in Python,"I have just now started learning python from Learn Python 3 The Hard Way by Zed Shaw. In exercise 3 of the book, there was a problem to get the value of 100 - 25 * 3 % 4. The solution to this problem is already mentioned in the archives, in which the order preference is given to * and %(from left to right). +I made a problem on my own to get the value of 100 - 25 % 3 + 4. The answer in the output is 103. +I just wrote: print (""the value of"", 100 - 25 % 3 + 4), which gave the output value 103. +If the % is given the preference 25 % 3 will give 3/4. Then how the answer is coming 103. Do I need to mention any float command or something? +I would like to know how can I use these operations. Is there any pre-defined rule to solve these kinds of problems?","Actually, the % operator gives you the REMAINDER of the operation. +Therefore, 25 % 3 returns 1, because 25 / 3 = 8 and the remainder of this operation is 1. +This way, your operation 100 - 25 % 3 + 4 is the same as 100 - 1 + 4 = 103",1.2,True,2,6052 +2019-04-14 20:15:45.423,Comparing feature extractors (or comparing aligned images),"I'd like to compare ORB, SIFT, BRISK, AKAZE, etc. to find which works best for my specific image set. I'm interested in the final alignment of images. +Is there a standard way to do it? +I'm considering this solution: take each algorithm, extract the features, compute the homography and transform the image. +Now I need to check which transformed image is closer to the target template. +Maybe I can repeat the process with the target template and the transformed image and look for the homography matrix closest to the identity but I'm not sure how to compute this closeness exactly. And I'm not sure which algorithm should I use for this check, I suppose a fixed one. +Or I could do some pixel level comparison between the images using a perceptual difference hash (dHash). But I suspect the the following hamming distance may not be very good for images that will be nearly identical. +I could blur them and do a simple subtraction but sounds quite weak. +Thanks for any suggestions. +EDIT: I have thousands of images to test. These are real world pictures. Images are of documents of different kinds, some with a lot of graphics, others mostly geometrical. I have about 30 different templates. I suspect different templates works best with different algorithms (I know in advance the template so I could pick the best one). +Right now I use cv2.matchTemplate to find some reference patches in the transformed images and I compare their locations to the reference ones. It works but I'd like to improve over this.","From your question, it seems like the task is not to compare the feature extractors themselves, but rather to find which type of feature extractor leads to the best alignment. +For this, you need two things: + +a way to perform the alignment using the features from different extractors +a way to check the accuracy of the alignment + +The algorithm you suggested is a good approach for doing the alignment. To check if accuracy, you need to know what is a good alignment. +You may start with an alignment you already know. And the easiest way to know the alignment between two images is if you made the inverse operation yourself. For example, starting with one image, you rotate it some amount, you translate/crop/scale or combine all this operations. Knowing how you obtained the image, you can obtain your ideal alignment (the one that undoes your operations). +Then, having the ideal alignment and the alignment generated by your algorithm, you can use one metric to evaluate its accuracy, depending on your definition of ""good alignment"".",1.2,True,1,6053 +2019-04-15 15:05:35.363,How to get access to django database from other python program?,"I have django project in which I can display records from raspberry pi device. I had mysql database and i have send records from raspberry there. I can display it via my api, but I want to work on this records.I want to change this to django database but I don't know how I can get access to django database which is on VPS server from raspberry pi device.","ALERT: THIS CAN LEAD TO SECURITY ISSUES +A Django database is no different from any other database. In this case a MySQL. +The VPS server where the MySQL is must have a public IP, the MySQL must be listening on that IP (if the VPS has a public IP but MySQL is not listening/bind on that IP, it won't work) and the port of the MySQL open (default is 3306), then you can connect to that database from any program with the required configurations params (host, port, user, password,...). +I'm not a sysadmin expert, but having a MySQL on a public IP is a security hole. So the best approach IMO is to expose the operations you want to do via API with Django.",1.2,True,1,6054 +2019-04-16 11:37:49.557,"What happened after entered "" flask run"" on a terminal under the project directory?","What happened after entered ""flask run"" on a terminal under the project directory? +How the python interpreter gets the file of flask.__main__.py and starts running project's code? +I know how Flask locates app. What I want to figure out is how command line instruction ""flask run"" get the flask/__main__.py bootup","flask is a Python script. Since you stated you are not a beginner, you should simply open the file (/usr/bin/flask) in your favorite text editor and start from there. There is no magic under the hood.",1.2,True,1,6055 +2019-04-17 08:02:38.757,what's the difference between airflow's 'parallelism' and 'dag_concurrency',"I can't understand the difference between dag_concurrency and parallelism. documentation and some of the related posts here somehow contradicts my findings. +The understanding I had before was that the parallelism parameter allows you to set the MAX number of global(across all DAGs) TaskRuns possible in airflow and dag_concurrency to mean the MAX number of TaskRuns possible for a single Dag. +So I set the parallelism to 8 and dag_concurrency to 4 and ran a single Dag. And I found out that it was running 8 TIs at a time but I was expecting it to run 4 at a time. + +How is that possible? +Also, if it helps, I have set the pool size to 10 or so for these tasks. But that shouldn't have mattered as ""config"" parameters are given higher priorities than the pool's, Right?","The other answer is only partially correct: +dag_concurrency does not explicitly control tasks per worker. dag_concurrency is the number of tasks running simultaneously per dag_run. So if your DAG has a place where 10 tasks could be running simultaneously but you want to limit the traffic to the workers you would set dag_concurrency lower. +The queues and pools setting also have an effect on the number of tasks per worker. +These setting are very important as you start to build large libraries of simultaneously running DAGs. +parallelism is the maximum number of tasks across all the workers and DAGs.",0.9866142981514304,False,1,6056 +2019-04-17 15:40:35.510,"how do i fix ""No module named 'win32api'"" on python2.7","I am trying to import win32api in python 2.7.9. i did the ""pip install pypiwin32"" and made sure all the files were intalled correctly (i have the win32api.pyd under ${PYTHON_HOME}\Lib\site-packages\win32). i also tried coping the files from C:\Python27\Lib\site-packages\pywin32_system32 to C:\Python27\Lib\site-packages\win32. I also tried restarting my pc after each of these steps but nothing seems to work! i still get the error 'No module named 'win32api''","Well, turns out the answer is upgrading my python to 3.6. +python 2.7 seems to old to work with outside imports (I'm just guessing here, because its not the first time I'm having an import problem) +hope it helps :)",1.2,True,1,6057 +2019-04-17 15:55:52.440,paste code to Jupyter notebook without symbols,"I tried to paste few lines code from online sources with the symbol like "">>>"". My question is how to paste without these symbols? +(Line by line works but it will be very annoying if pasting a big project.) +Cheers","Go to Edit > Find and Replace, in which find for >>> and replace with empty. Enjoy :)",0.0,False,1,6058 +2019-04-17 19:02:36.187,How can python iterate over a set if no order is defined?,"So I notice that we say in python that sets have no order or arrangement, although of course you can sort the list generated from a set. +So I was wondering how the iteration over a set is defined in python. Does it just follow the sorted list ordering, or is there some other footgun that might crop up at some point? +Thanks.","A temporary order is used to iterate over the set, but you can't reliably predict it (practically speaking, as it depends on the insertion and deletion history of the set). If you need a specific order, use a list.",1.2,True,1,6059 +2019-04-18 06:31:12.170,"How to triangulate a point in 3D space, given coordinate points in 2 image and extrinsic values of the camera","I'm trying to write a function that when given two cameras, their rotation, translation matrices, focal point, and the coordinates of a point for each camera, will be able to triangulate the point into 3D space. Basically, given all the extrinsic/intrinsic values needed +I'm familiar with the general idea: to somehow create two rays and find the closest point that satisfies the least squares problem, however, I don't know exactly how to translate the given information to a series of equations to the coordinate point in 3D.","Assume you have two cameras -- camera 1 and camera 2. +For each camera j = 1, 2 you are given: + +The distance hj between it's center Oj, (is ""focal point"" the right term? Basically the point Oj from which the camera is looking at its screen) and the camera's screen. The camera's coordinate system is centered at Oj, the Oj--->x and Oj--->y axes are parallel to the screen, while the Oj--->z axis is perpendicular to the screen. +The 3 x 3 rotation matrix Uj and the 3 x 1 translation vector Tj which transforms the Cartesian 3D coordinates with respect to the system of camera j (see point 1) to the world-coordinates, i.e. the coordinates with respect to a third coordinate system from which all points in the 3D world are described. +On the screen of camera j, which is the plane parallel to the plane Oj-x-y and at a distance hj from the origin Oj, you have the 2D coordinates (let's say the x,y coordinates only) of point pj, where the two points p1 and p2 are in fact the projected images of the same point P, somewhere in 3D, onto the screens of camera 1 and 2 respectively. The projection is obtained by drawing the 3D line between point Oj and point P and defining point pj as the unique intersection point of this line with with the screen of camera j. The equation of the screen in camera j's 3D coordinate system is z = hj , so the coordinates of point pj with respect to the 3D coordinate system of camera j look like pj = (xj, yj, hj) and so the 2D screen coordinates are simply pj = (xj, yj) . + +Input: You are given the 2D points p1 = (x1, y1), p2 = (x2, y2) , the twp cameras' focal distances h1, h2 , two 3 x 3 rotation matrices U1 and U2, two translation 3 x 1 vector columns T1 and T2 . +Output: The coordinates P = (x0, y0, z0) of point P in the world coordinate system. +One somewhat simple way to do this, avoiding homogeneous coordinates and projection matrices (which is fine too and more or less equivalent), is the following algorithm: + +Form Q1 = [x1; y1; h1] and Q2 = [x2; y2; h2] , where they are interpreted as 3 x 1 vector columns; +Transform P1 = U1*Q1 + T1 and P2 = U1*Q2 + T1 , where * is matrix multiplication, here it is a 3 x 3 matrix multiplied by a 3 x 1 column, givin a 3 x 1 column; +Form the lines X = T1 + t1*(P1 - T1) and X = T2 + t2*(P2 - T2) ; +The two lines from the preceding step 3 either intersect at a common point, which is the point P or they are skew lines, i.e. they do not intersect but are not parallel (not coplanar). +If the lines are skew lines, find the unique point X1 on the first line and the uniqe point X2 on the second line such that the vector X2 - X1 is perpendicular to both lines, i.e. X2 - X1 is perpendicular to both vectors P1 - T1 and P2 - T2. These two point X1 and X2 are the closest points on the two lines. Then point P = (X1 + X2)/2 can be taken as the midpoint of the segment X1 X2. + +In general, the two lines should pass very close to each other, so the two points X1 and X2 should be very close to each other.",0.0,False,1,6060 +2019-04-18 14:54:16.823,Understanding execution_date in Airflow,"I am running an airflow DAG and wanted to understand how the execution date gets set. This is the code I am running: +{{ execution_date.replace(day=1).strftime(""%Y-%m-%d"") }} +This always returns the first day of the month. This is the functionality that I want, but I just want to find a way to understand what is happening.",execution_date returns a datatime object. You are using the replace method of that object to replace the “day” with the first. Then outputting that to a string with the format method.,0.0,False,2,6061 +2019-04-18 14:54:16.823,Understanding execution_date in Airflow,"I am running an airflow DAG and wanted to understand how the execution date gets set. This is the code I am running: +{{ execution_date.replace(day=1).strftime(""%Y-%m-%d"") }} +This always returns the first day of the month. This is the functionality that I want, but I just want to find a way to understand what is happening.","The reason this always returns the first of the month is that you are using a Replace to ensure the day is forced to be the 1st of the month. Simply remove "".replace(day=1)"".",1.2,True,2,6061 +2019-04-19 10:22:36.757,"How to convert file .py to .exe, having Python from Anaconda Navigator? (in which command prompt should I write installation codes?)","I created a Python script (format .py) that works. +I would like to convert this file to .exe, to use it in a computer without having Python installed. +How can I do? +I have Python from Anaconda3. +What can I do? +Thank you! +I followed some instruction found here on Stackoverflow. +.I modify the Path in the 'Environment variables' in the windows settings, edited to the Anaconda folder. +.I managed to install pip in conda prompt (I guess). +Still, nothing is working. I don't know how to proceed and in general how to do things properly.","I personaly use pyinstaller, its available from pip. +But it will not really compile, it will just bundle. +The difference is compiling means translating to real machine code while bundling is creating a big exe file with all your libs and your python interpreter. +Even if pyinstaller create bigger file and is slower than cython (at execution), I prefer it because it work all the time without work (except lunching it).",1.2,True,1,6062 +2019-04-19 16:25:54.117,How can i install opencv in python3.7 on ubuntu?,"I have a Nvidia Jetson tx2 with the orbitty shield on it. +I got it from a friend who worked on it last year. It came with ubuntu 16.04. I updated everything on it and i installed the latest python3.7 and pip. +I tried checking the version of opencv to see what i have but when i do import cv2 it gives me : +Traceback (most recent call last): + File """", line 1, in +ModuleNotFoundError: No module named 'cv2' +Somehow besides python3.7 i have python2.7 and python3.5 installed. If i try to import cv2 on python2.7 and 3.5 it works, but in 3.7 it doesn't. +Can u tell me how can i install opencv in python3.7 and the latest version?",Does python-3.7 -m pip install opencv-python work? You may have to change the python-3.7 to whatever path/alias you use to open your own python 3.7.,0.0,False,1,6063 +2019-04-20 21:40:23.537,Negative Feature Importance Value in CatBoost LossFunctionChange,"I am using CatBoost for ranking task. I am using QueryRMSE as my loss function. I notice for some features, the feature importance values are negative and I don't know how to interpret them. +It says in the documentation, the i-th feature importance is calculated as the difference between loss(model with i-th feature excluded) - loss(model). +So a negative feature importance value means that feature makes my loss go up? +What does that suggest then?",Negative feature importance value means that feature makes the loss go up. This means that your model is not getting good use of this feature. This might mean that your model is underfit (not enough iteration and it has not used the feature enough) or that the feature is not good and you can try removing it to improve final quality.,1.2,True,1,6064 +2019-04-23 04:00:09.300,cv2 - multi-user image display,"Using python and OpenCV, is it possible to display the same image on multiple users? +I am using cv2.imshow but it only displays the image for the user that runs the code. +Thanks",I was able to display the images on another user/host by setting the DISPLAY environment variable of the X server to match the desired user's DISPLAY.,0.0,False,1,6065 +2019-04-23 06:19:55.700,Move turtle slightly closer to random coordinate on each update,"I'm doing a homework and I want to know how can I move turtle to a random location a small step each time. Like can I use turtle.goto() in a slow motion? +Someone said I should use turtle.setheading() and turtle.forward() but I'm confused on how to use setheading() when the destination is random. +I'm hoping the turtle could move half radius (which is 3.5) each time I update the program to that random spot.","Do you mean that you want to move a small step, stop, and repeat? If so, you can ‘import time’ and add ‘time.sleep(0.1)’ after each ‘forward’",0.0,False,1,6066 +2019-04-23 15:17:02.483,Python append single bit to bytearray,"I have a bytearray containing some bytes, it currently look like this (Converted to ASCII): + +['0b1100001', '0b1100010', '0b1100011', '0b10000000'] + +I need to add a number of 0 bits to this, is that possible or would I have to add full bytes? If so, how do I do that?","Where do you need the bits added to? Each element of your list or an additional element that contains all 0's? +The former: +myList[0] = myList[0] * 2 # ASL +The later +myList.append(0b000000)",0.1352210990936997,False,1,6067 +2019-04-23 19:50:59.320,How to access _pycache_ directory,"I want to remove a folder, but I can’t get in pycache to delete the pyc and pyo$ files. I have done it before, but I don’t know how I did it.","If you want to remove your python file artifacts, such as the .pyc and .pyo cache files, maybe you could try the following: + +Move into your project's root directory +cd +Remove python file artifacts +find . -name '*.pyc' -exec rm -f {} + +find . -name '*.pyo' -exec rm -f {} + + +Hopefully that helps!",0.0,False,1,6068 +2019-04-26 07:18:59.020,numerical entity extraction from unstructured texts using python,"I want to extract numerical entities like temperature and duration mentioned in unstructured formats of texts using neural models like CRF using python. I would like to know how to proceed for numerical extraction as most of the examples available on the internet are for specific words or strings extraction. +Input: 'For 5 minutes there, I felt like baking in an oven at 350 degrees F' +Output: temperature: 350 + duration: 5 minutes","So far my research shows that you can treat numbers as words. +This raises an issue : learning 5 will be ok, but 19684 will be to rare to be learned. +One proposal is to convert into words. ""nineteen thousands six hundred eighty four"" and embedding each word. The inconvenient is that you are now learning a (minimum) 6 dimensional vector (one dimension per word) +Based on your usage, you can also embed 0 to 3000 with distinct ids, and say 3001 to 10000 will map id 3001 in your dictionary, and then add one id in your dictionary for each 10x.",0.0,False,1,6069 +2019-04-26 14:50:51.197,Python Azure webjob passing parameters,"I have a Python WebJob living in Azure and I'm trying to pass parameters to it. +I've found documentation saying that I should be able to post the URL and add:?arguments={'arg1', 'arg2'} after it. +However, when I do that and then try to print(sys.argv) in my code, it's only printing the name of the Python file and none of the arguments I pass to it. +How do I get the arguments to pass to my Python code? I am also using a run.cmd in my Azure directory to trigger my Python code if that makes a difference. +UPDATE: So I tested it in another script without the run.cmd and that certainly is the problem. If I just do ?arguments=22 66 it works. So how do I pass parameters when I'm using a run.cmd file?","I figured it out: in the run.cmd file, you need to put ""%*"" after your script name and it will detect any arguments you passed in the URL.",1.2,True,1,6070 +2019-04-27 17:03:24.327,What happens after shutting down the PC via subprocess?,"I try to turn my pc off and restart it on LAN. +When getting one of the commands (turnoff or restart), I execute one of the followings: +subprocess.call([""shutdown"", ""-f"", ""-s"", ""-y""]) # Turn off +subprocess.call([""shutdown"", ""-f"", ""-r"", ""-t"", ""-c"", ""-y""]) # Restart +I'd like to inform the other side if the process was successfully initiated, and if the PC is in the desired state. +I know that it is possible to implement a function which will check if the PC is alive (which is a pretty good idea) several seconds after executing the commands, but how one can know how many seconds are needed? And what if the PC will be shut down a moment after sending a message stating that it is still alive? +I'm curious to know- what really happens after those commands are executed? Will the script keep running until the task manager will kill it? Will it stop running right after the command?","Programs like shutdown merely send a message to init (or whatever modern replacement) and exit immediately; it’s up to it what happens next. Typical Unix behavior is to first shut down things like SSH servers (which probably doesn’t kill your connection to the machine), then send SIGTERM to all processes, wait a few seconds (5 is typical) for signal handlers to run, and then send SIGKILL to any survivors. Finally, filesystems are unmounted and the hardware halt or reboot happens. +While there’s no guarantee that the first phase takes long enough for you to report successful shutdown execution, it generally will; if it’s a concern, you can catch the SIGTERM to buy yourself those few extra seconds to get the message out.",1.2,True,1,6071 +2019-04-27 20:18:09.337,How can I create a vCard qrcode with pyqrcode?,"I am trying to generate a vCard QR code with the pyqrcode library but I cannot figure out the way to do it. +I have read their documentation 5 times and it doesn't say anything about vCard, only about URL and on the internet, I could found only about wifi. Does anybody know how can I do it? +I want to make a vCard QR code and afterward to display it on django web page.","Let's say : +We've two libraries: + +pyqrcode : QR reader / writer +vobject : vCard serializer / deserializer + +Flow: +a. Generate a QR img from ""some"" web site : +web site send JSON info => get info from JSON and serialize using vobject to obtain a vcard string => pyqrcode.create(vcard string) +b. Show human redeable info from QR img : +pyqrcode read an QR img ( created from a. ) => deserialize using vobject to obtain a JSON => show info parsing JSON in the web site. +OR... after deserialize using vobject you can write a .vcard file",1.2,True,1,6072 +2019-04-28 15:35:56.843,Cloud SQL/NiFi: Connect to cloud sql database with python and NiFi,"So, I am doing a etl process in which I use Apache NiFi as an etl tool along with a postgresql database from google cloud sql to read csv file from GCS. As a part of the process, I need to write a query to transform data read from csv file and insert to the table in the cloud sql database. So, based on NIFi, I need to write a python to execute a sql queries automatically on a daily basis. But the question here is that how can I write a python to connect with the cloud sql database? What config that should be done? I have read something about cloud sql proxy but can I just use an cloud sql instance's internal ip address and put it in some config file and creating some dbconnector out of it? +Thank you +Edit: I can connect to cloud sql database from my vm using psql -h [CLOUD_SQL_PRIVATE_IP_ADDR] -U postgres but I need to run python script for the etl process and there's a part of the process that need to execute sql. What I am trying to ask is that how can I write a python file that use for executing the sql +e.g. In python, query = 'select * from table ....' and then run +postgres.run_sql(query) which will execute the query. So how can I create this kind of executor?","I don't understand why you need to write any code in Python? I've done a similar process where I used GetFile (locally) to read a CSV file, parse and transform it, and then used ExecuteSQLRecord to insert the rows into a SQL server (running on a cloud provider). The DBCPConnectionPool needs to reference your cloud provider as per their connection instructions. This means the URL likely reference something.google.com and you may need to open firewall rules using your cloud provider administration.",0.0,False,1,6073 +2019-04-29 12:55:44.847,"Keras / NN - Handling NaN, missing input","These days i'm trying to teach myself machine learning and i'm going though some issues with my dataset. +Some of my rows (i work with csv files that i create with some js script, i feel more confident doing that in js) are empty wich is normal as i'm trying to build some guessing model but the issue is that it results in having nan values on my training set. +My NN was not training so i added a piece of code to remove them from my set but now i have some issues where my model can't work with input from different size.. +So my question is: how do i handle missing data ? (i basically have 2 rows and can only have the value from 1 and can't merge them as it will not give good results) +i can remove it from my set, wich would reduce the accuracy of my model in the end. +PS: if needed i'll post some code when i come back home.","You need to have the same input size during training and inference. If you have a few missing values (a few %), you can always choose to replace the missing values by a 0 or by the average of the column. If you have more missing values (more than 50%) you are probably better off ignoring the column completely. Note that this theoretical, the best way to make it work is to try different strategies on your data.",1.2,True,1,6074 +2019-04-30 15:36:33.210,Doc2Vec - Finding document similarity in test data,"I am trying to train a doc2vec model using training data, then finding the similarity of every document in the test data for a specific document in the test data using the trained doc2vec model. However, I am unable to determine how to do this. +I currently using model.docvecs.most_similar(...). However, this function only finds the similarity of every document in the training data for a specific document in the test data. +I have tried manually comparing the inferred vector of a specific document in the test data with the inferred vectors of every other document in the test data using model.docvecs.n_similarity(inferred_vector.tolist(), testvectors[i].tolist()) but this returns KeyError: ""tag '-0.3502606451511383' not seen in training corpus/invalid"" as there are vectors not in the dictionary.","The act of training-up a Doc2Vec model leaves it with a record of the doc-vectors learned from the training data, and yes, most_similar() just looks among those vectors. +Generally, doing any operations on new documents that weren't part of training will require the use of infer_vector(). Note that such inference: + +ignores any unknown words in the new document +may benefit from parameter tuning, especially for short documents +is currently done just one document at time in a single thread – so, acquiring inferred-vectors for a large batch of N-thousand docs can actually be slower than training a fresh model on the same N-thousand docs +isn't necessarily deterministic, unless you take extra steps, because the underlying algorithms use random initialization and randomized selection processes during training/inference +just gives you the vector, without loading it into any convenient storage-object for performing further most_similar()-like comparisons + +On the other hand, such inference from a ""frozen"" model can be parallelized across processes or machines. +The n_similarity() method you mention isn't really appropriate for your needs: it's expecting lists of lookup-keys ('tags') for existing doc-vectors, not raw vectors like you're supplying. +The similarity_unseen_docs() method you mention in your answer is somewhat appropriate, but just takes a pair of docs, re-calculating their vectors each time – somewhat wasteful if a single new document's doc-vector needs to be compared against many other new documents' doc-vectors. +You may just want to train an all-new model, with both your ""training documents"" and your ""test documents"". Then all the ""test documents"" get their doc-vectors calculated, and stored inside the model, as part of the bulk training. This is an appropriate choice for many possible applications, and indeed could learn interesting relationships based on words that only appear in the ""test docs"" in a totally unsupervised way. And there's not yet any part of your question that gives reasons why it couldn't be considered here. +Alternatively, you'd want to infer_vector() all the new ""test docs"", and put them into a structure like the various KeyedVectors utility classes in gensim - remembering all the vectors in one array, remembering the mapping from doc-key to vector-index, and providing an efficient bulk most_similar() over the set of vectors.",1.2,True,2,6075 +2019-04-30 15:36:33.210,Doc2Vec - Finding document similarity in test data,"I am trying to train a doc2vec model using training data, then finding the similarity of every document in the test data for a specific document in the test data using the trained doc2vec model. However, I am unable to determine how to do this. +I currently using model.docvecs.most_similar(...). However, this function only finds the similarity of every document in the training data for a specific document in the test data. +I have tried manually comparing the inferred vector of a specific document in the test data with the inferred vectors of every other document in the test data using model.docvecs.n_similarity(inferred_vector.tolist(), testvectors[i].tolist()) but this returns KeyError: ""tag '-0.3502606451511383' not seen in training corpus/invalid"" as there are vectors not in the dictionary.","It turns out there is a function called similarity_unseen_docs(...) which can be used to find the similarity of 2 documents in the test data. +However, I will leave the question unsolved for now as it is not very optimal since I would need manually compare the specific document with every other document in the test data. Also, it compares the words in the documents instead of the vectors which could affect accuracy.",0.0,False,2,6075 +2019-04-30 22:47:27.537,How to run a python program using sourcelair?,"I'm trying to run a python program in the online IDE SourceLair. I've written a line of code that simply prints hello, but I am embarrassed to say I can't figure out how to RUN the program. +I have the console, web server, and terminal available on the IDE already pulled up. I just don't know how to start the program. I've tried it on Mac OSX and Chrome OS, and neither work. +I don't know if anyone has experience with this IDE, but I can hope. Thanks!!","Can I ask you why you are using SourceLair? +Well I just figured it out in about 2 mins....its the same as using any other editor for python. +All you have to do is to run it in the terminal. python (nameoffile).py",0.2012947653214861,False,1,6076 +2019-05-01 22:51:50.737,How to implement Proximal Policy Optimization (PPO) Algorithm for classical control problems?,"I am trying to implement clipped PPO algorithm for classical control task like keeping room temperature, charge of battery, etc. within certain limits. So far I've seen the implementations in game environments only. My question is the game environments and classical control problems are different when it comes to the implementation of the clipped PPO algorithm? If they are, help and tips on how to implement the algorithm for my case are appreciated.","I'm answering your question from a general RL point of view, I don't think the particular algorithm (PPO) makes any difference in this question. +I think there is no fundamental differences, both can be seen as discrete control problems. In a game you observe the state, then choose an action and act according to it, and receive reward an the observation of the subsequent state. +Now if you take a simple control problem, instead of a game you probably have a simulation (or just a very simple dynamic model) that describes the behavior of your problem. For example the equations of motion for an inverted pendulum (another classical control problem). In some case you might directly interact with the real system, not a model of it, but this is rare as it can be really slow, and the typical sample complexities of RL algorithms make learning on a real (physical) system less practical. +Essentially you interact with the model of your problem just the same way as you do with a game: you observe a state, take an action and act, and observe the next state. The only difference is that while in games reward is usually pre-defined (some score or goal state), probably you need to define the reward function for your problem. But again, in many cases you also need to define rewards for games, so this is not a major difference either.",1.2,True,1,6077 +2019-05-03 22:13:05.803,Visualizing a frozen graph_def.pb,"I am wondering how to go about visualization of my frozen graph def. I need it to figure out my tensorflow networks input and output nodes. I have already tried several methods to no avail, like the summarize graph tool. Does anyone have an answer for some things that I can try? I am open to clarifying questions, thanks in advance.",You can try to use TensorBoard. It is on the Tensorflow website...,0.0,False,1,6078 +2019-05-04 18:47:48.437,Python: how to create database and a GUI together?,"I am new to Python and to train myself, I would like to use Python build a database that would store information about wine - bottle, date, rating etc. The idea is that: + +I could use to database to add a new wine entries +I could use the database to browse wines I have previously entered +I could run some small analyses + +The design of my Python I am thinking of is: + +Design database with Python package sqlite3 +Make a GUI built on top of the database with the package Tkinter, so that I can both enter new data and query the database if I want. + +My question is: would your recommend this design and these packages? Is it possible to build a GUI on top of a database? I know StackOverflow is more for specific questions rather than ""project design"" questions so I would appreciate if anyone could point me to forums that discuss project design ideas. +Thanks.","If it's just for you, sure there is no problem with that stack. +If I were doing it, I would skip Tkinter, and build something using Flask (or Django.) Doing a web page as a GUI yields faster results, is less fiddly, and more applicable to the job market.",0.0,False,1,6079 +2019-05-05 00:30:24.233,Pandas read_csv method can't get 'œ' character properly while using encoding ISO 8859-15,"I have some trubble reading with pandas a csv file which include the special character 'œ'. +I've done some reseach and it appears that this character has been added to the ISO 8859-15 encoding standard. +I've tried to specify this encoding standard to the pandas read_csv methods but it doesn't properly get this special character (I got instead a '☐') in the result dataframe : +df= pd.read_csv(my_csv_path, "";"", header=None, encoding=""ISO-8859-15"") +Does someone know how could I get the right 'œ' character (or eaven better the string 'oe') instead of this ? +Thank's a lot :)",Anyone have a clue ? I've manage the problem by manually rewrite this special character before reading my csv with pandas but that doesn't answer my question :(,0.0,False,1,6080 +2019-05-06 11:57:11.053,Using OpenCV with PyPy,"I am trying to run a python script using OpenCV with PyPy, but all the documentation that I found didn't work. +The installation of PyPy went well, but when I try to run the script it says that it can't find OpenCV modules like 'cv2' for example, despite having cloned opencv for pypy directly from a github repository. +I would need to know how to do it exactly.","pip install opencv-python worked well for me on python 2.7, I can import and use cv2.",0.2012947653214861,False,1,6081 +2019-05-07 06:21:51.733,Getting ARERR 149 A user name must be supplied in the control record,"I have a SOAP url , while running the url through browser I am getting a wsdl response.But when I am trying to call a method in the response using the required parameter list, and it is showing ""ARERR [149] A user name must be supplied in the control record"".I tried using PHP as well as python but I am getting the same error. +I searched this error and got the information like this : ""The name field of the ARControlStruct parameter is empty. Supply the name of an AR System user in this field."".But nowhere I saw how to supply the user name parameter.","I got the solution for this problem.Following are the steps I followed to solve the issue (I have used ""zeep"" a 3rd party module to solve this): + +Run the following command to understand WSDL: + +python -mzeep wsdl_url + +Search for string ""Service:"". Below that we can see our operation name +For my operation I found following entry: + +MyOperation(parameters..., _soapheaders={parameters: ns0:AuthenticationInfo}) +which clearly communicates that, I have to pass parameters and an auth param using kwargs ""_soapheaders"" +With that I came to know that I have to pass my authentication element as _soapheaders argument to MyOperation function. + +Created Auth Element: + +auth_ele = client.get_element('ns0:AuthenticationInfo') +auth = auth_ele(userName='me', password='mypwd') + +Passed the auth to my Operation: + +cleint.service.MyOperation('parameters..', _soapheaders=[auth])",0.0,False,1,6082 +2019-05-07 20:45:21.080,How to implement Breadth-First-Search non-recursively for a directed graph on python,"I'm trying to implement a BFS function that will print a list of nodes of a directed graph as visited using Breadth-First-Search traversal. The function has to be implemented non-recursively and it has to traverse through all the nodes in a graph, so if there are multiple trees it will print in the following way: +Tree 1: a, b +Tree 2: d, e, h +Tree 3: ..... +My main difficulty is understanding how to make the BFS function traverse through all the nodes if the graph has several trees, without reprinting previously visited nodes.","BFS is usually done with a queue. When you process a node, you push its children onto the queue. After processing the node, you process the next one in the queue. +This is by nature non-recursive.",0.0,False,1,6083 +2019-05-08 08:51:35.840,"How to kill tensorboard with Tensorflow2 (jupyter, Win)","sorry for the noob question, but how do I kill the Tensorflow PID? +It says: +Reusing TensorBoard on port 6006 (pid 5128), started 4 days, 18:03:12 ago. (Use '!kill 5128' to kill it.) +But I can not find any PID 5128 in the windows taks manager. Using '!kill 5128' within jupyter the error returns that comand kill cannot be found. Using it in the Windows cmd or conda cmd does not work either. +Thanks for your help.","If you clear the contents of AppData/Local/Temp/.tensorboard-info, and delete your logs, you should be able to have a fresh start",0.9999665971563038,False,1,6084 +2019-05-08 11:29:27.797,how to extract line from a word2vec file?,"I have created a word2vec file and I want to extract only the line at position [0] +this is the word2vec file +`36 16 +Activity 0.013954502 0.009596351 -0.0002082094 -0.029975398 -0.0244055 -0.001624907 0.01995442 0.0050479663 -0.011549354 -0.020344704 -0.0113901375 -0.010574887 0.02007604 -0.008582828 0.030914625 -0.009170294 +DATABASED%GWC%5 0.022193532 0.011890317 -0.018219836 0.02621059 0.0029900416 0.01779779 -0.026217759 0.0070709535 -0.021979155 0.02609082 0.009237218 -0.0065825963 -0.019650755 0.024096865 -0.022521153 0.014374277 +DATABASED%GWC%7 0.021235622 -0.00062567473 -0.0045315344 0.028400827 0.016763352 0.02893731 -0.013499333 -0.0037113864 -0.016281538 0.004078895 0.015604254 -0.029257657 0.026601797 0.013721668 0.016954066 -0.026421601`","glove_model[""Activity""] should get you its vector representation from the loaded model. This is because glove_model is an object of type KeyedVectors and you can use key value to index into it.",1.2,True,1,6085 +2019-05-08 17:12:26.120,Handling many-to-many relationship from existing database using Django ORM,"I'm starting to work with Django, already done some models, but always done that with 'code-first' approach, so Django handled the table creations etc. Right now I'm integrating an already existing database with ORM and I encountered some problems. +Database has a lot of many-to-many relationships so there are quite a few tables linking two other tables. I ran inspectdb command to let Django prepare some models for me. I revised them, it did rather good job guessing the fields and relations, but the thing is, I think I don't need those link tables in my models, because Django handles many-to-many relationships with ManyToManyField fields, but I want Django to use that link tables under the hood. +So my question is: Should I delete the models for link tables and add ManyToManyFields to corresponding models, or should I somehow use this models? +I don't want to somehow mess-up database structure, it's quite heavy populated. +I'm using Postgres 9.5, Django 2.2.",In many cases it doesn't matter. If you would like to keep the code minimal then m2m fields are a good way to go. If you don't control the database structure it might be worth keeping the inspectdb schema in case you have to do it again after schema changes that you don't control. If the m2m link tables can grow properties of their own then you need to keep them as models.,0.0,False,1,6086 +2019-05-08 20:10:18.047,"Is there a way to use the ""read_csv"" method to read the csv files in order they are listed in a directory?","I am plotting plots on one figure using matplotlib from csv files however, I want the plots in order. I want to somehow use the read_csv method to read the csv files from a directory in the order they are listed in so that they are outputted in the same fashion. +I want the plots listed under each other the same way the csv files are listed in the directory.","you could use os.listdir() to get all the files in the folder and then sort them out in a certain way, for example by name(it would be enough using the python built in sorted() ). Instead if you want more fancy ordering you could retrieve both the name and last modified date and store them in a dictionary, order the keys and retrieve the values. So as @Fausto Morales said it all only depends on which order you would like them to be sorted.",1.2,True,1,6087 +2019-05-09 09:52:44.457,How to make a python script run forever online?,"I Have a python script that monitors a website, and I want it to send me a notification when some particular change happens to the website. +My question is how can I make that Python script runs for ever in some place else (Not my machine, because I want it to send me a notification even when my machine is off)? +I have thought about RDP, but I wanted to have your opinions also. +(PS: FREE Service if it's possible, otherwise the lowest cost) +Thank you!","I would suggest you to setup AWS EC2 instance with whatever OS you want. +For beginner, you can get 750 hours of usage for free where you can run your script on.",0.3869120172231254,False,1,6088 +2019-05-12 11:06:47.317,How to write binary file with bit length not a multiple of 8 in Python?,"I'm working on a tool generates dummy binary files for a project. We have a spec that describes the real binary files, which are created from a stream of values with various bit lengths. I use input and spec files to create a list of values, and the bitstring library's BitArray class to convert the values and join them together. +The problem is that the values' lengths don't always add up to full bytes, and I need the file to contain the bits as-is. Normally I could use BitArray.tofile(), but that method automatically pads the file with zeroes at the end. +Is there another way how to write the bits to a file?","You need to give padding to the, say 7-bit value so it matches a whole number of bytes: +1010101 (7 bits) --> 01010101 +1111 (4 bits) --> 00001111 +The padding of the most significant digits does not affect the data taken from the file.",0.0,False,1,6089 +2019-05-14 11:09:07.967,Send variable between PCs over the internet using python,"I have two computers with internet connection. They both have public IPs and they are NATed. What I want is to send a variable from PC A to PC B and close the connection. +I have thought of two approaches for this: +1) Using sockets. PC B will have listen to a connection from PC A. Then, when the variable will be sent, the connection will be closed. The problem is that, the sockets will not communicate, because I have to forward the traffic from my public IP to PC B. +2) An out of the box idea, is to have the variable broadcasted online somewhere. I mean making a public IP hold the variable in HTML and then the PC would GET the IP from and get the variable. The problem is, how do I make that variable accessible over the internet? +Any ideas would be much appreciated.","Figured a solution out. I make a dummy server using flask and I hosted it at pythonanywhere.com for free. The variables are posted to the server from PC A and then, PC B uses the GET method to get them locally.",1.2,True,1,6090 +2019-05-15 19:48:44.263,Pulling duration stats API in Airflow,"In airflow, the ""Gantt"" chart offers quite a good view on performance of the ran tasks. It offers stats like start/end time, duration and etc. +Do you guys know a way to programmatically pull these stats via the Airflow API? I would like to use these stats and generate periodic reports on the performance of my tasks and how it changes over time. +My airflow version is: 1.9 +Python: 3.6.3 +Running on top of docker +Thanks! +Kelvin +Airflow online documentation","One easy approach could be to set up a SQL alchemy connection, airflow stores/sends all the data in there once the configuration is completed(dag info/stat/fail, task info/stats/ etc.). +Edit airflow.cfg and add: +sql_alchemy_conn = mysql://------/table_name",1.2,True,1,6091 +2019-05-15 23:51:31.380,How to use a Pyenv virtualenv from within Eclipse?,"I am using Eclipse on Linux to develop C applications, and the build system I have makes use of make and python. I have a custom virtualenv installed and managed by pyenv, and it works fine from the command line if I pre-select the virtualenv with, say pyenv shell myvenv. +However I want Eclipse to make use of this virtualenv when building (via ""existing makefile"") from within Eclipse. Currently it runs my Makefile but uses the system python in /usr/bin/python, which is missing all of the packages needed by the build system. +It isn't clear to me how to configure Eclipse to use a custom Python interpreter such as the one in my virtualenv. I have heard talk of setting PYTHONPATH however this seems to be for finding site-packages rather than the interpreter itself. My virtualenv is based on python 3.7 and my system python is 2.7, so setting this alone probably isn't going to work. +I am not using PyDev (this is a C project, not a Python project) so there's no explicit support for Python in Eclipse. I'd prefer not to install PyDev if I can help it. +I've noticed that pyenv adds its plugins, shims and bin directories to PATH when activated. I could explicitly add these to PATH in Eclipse, so that Eclipse uses pyenv to find an interpreter. However I'd prefer to point directly at a specific virtualenv rather than use the pyenv machinery to find the current virtualenv.",Typing CMD+SHIFT+. will show you dotfiles & directories that begin with dot in any Mac finder dialog box...,-0.1352210990936997,False,3,6092 +2019-05-15 23:51:31.380,How to use a Pyenv virtualenv from within Eclipse?,"I am using Eclipse on Linux to develop C applications, and the build system I have makes use of make and python. I have a custom virtualenv installed and managed by pyenv, and it works fine from the command line if I pre-select the virtualenv with, say pyenv shell myvenv. +However I want Eclipse to make use of this virtualenv when building (via ""existing makefile"") from within Eclipse. Currently it runs my Makefile but uses the system python in /usr/bin/python, which is missing all of the packages needed by the build system. +It isn't clear to me how to configure Eclipse to use a custom Python interpreter such as the one in my virtualenv. I have heard talk of setting PYTHONPATH however this seems to be for finding site-packages rather than the interpreter itself. My virtualenv is based on python 3.7 and my system python is 2.7, so setting this alone probably isn't going to work. +I am not using PyDev (this is a C project, not a Python project) so there's no explicit support for Python in Eclipse. I'd prefer not to install PyDev if I can help it. +I've noticed that pyenv adds its plugins, shims and bin directories to PATH when activated. I could explicitly add these to PATH in Eclipse, so that Eclipse uses pyenv to find an interpreter. However I'd prefer to point directly at a specific virtualenv rather than use the pyenv machinery to find the current virtualenv.","I had the same trouble and after some digging, there are two solutions; project-wide and workspace-wide. I prefer the project-wide as it will be saved in the git repository and the next person doesn't have to pull their hair. +For the project-wide add /Users/${USER}/.pyenv/shims: to the start of the ""Project properties > C/C++ Build > Environment > PATH"". +I couldn't figure out the other method fully (mostly because I'm happy with the other one) but it should be with possible to modify ""Eclipse preferences > C/C++ > Build > Environment"". You should change the radio button and add PATH variable.",0.0,False,3,6092 +2019-05-15 23:51:31.380,How to use a Pyenv virtualenv from within Eclipse?,"I am using Eclipse on Linux to develop C applications, and the build system I have makes use of make and python. I have a custom virtualenv installed and managed by pyenv, and it works fine from the command line if I pre-select the virtualenv with, say pyenv shell myvenv. +However I want Eclipse to make use of this virtualenv when building (via ""existing makefile"") from within Eclipse. Currently it runs my Makefile but uses the system python in /usr/bin/python, which is missing all of the packages needed by the build system. +It isn't clear to me how to configure Eclipse to use a custom Python interpreter such as the one in my virtualenv. I have heard talk of setting PYTHONPATH however this seems to be for finding site-packages rather than the interpreter itself. My virtualenv is based on python 3.7 and my system python is 2.7, so setting this alone probably isn't going to work. +I am not using PyDev (this is a C project, not a Python project) so there's no explicit support for Python in Eclipse. I'd prefer not to install PyDev if I can help it. +I've noticed that pyenv adds its plugins, shims and bin directories to PATH when activated. I could explicitly add these to PATH in Eclipse, so that Eclipse uses pyenv to find an interpreter. However I'd prefer to point directly at a specific virtualenv rather than use the pyenv machinery to find the current virtualenv.","For me, following steps worked ( mac os 10.12, eclipse photon version, with pydev plugin) + +Project -> properties +Pydev-Interpreter/Grammar +Click here to configure an interpreter not listed (under interpret combobox) +open interpreter preference page +Browse for python/pypy exe -> my virtualenvdirectory/bin/python +Then the chosen python interpreter path should show ( for me still, it was not pointing to my virtual env, but I typed my path explicitly here and it worked) + +In the bottom libraries section, you should be able to see the site-packages from your virtual env +Extra tip - In my mac os the virtual env was starting with .pyenv, since it's a hidden directory, I was not able to select this directory and I did not know how to view the hidden directory in eclipse file explorer. Therefore I created an softlink ( without any . in the name) to the hidden directory (.pyenv) and then I was able to select the softlink",-0.1352210990936997,False,3,6092 +2019-05-16 10:29:25.553,the clustering of mixed data using python,"I am trying to cluster a data set containing mixed data(nominal and ordinal) using k_prototype clustering based on Huang, Z.: Clustering large data sets with mixed numeric and categorical values. +my question is how to find the optimal number of clusters?","There is not one optimal number of clusters. But dozens. Every heuristic will suggest a different ""optimal"" number for another poorly defined notion of what is ""optimal"" that likely has no relevancy for the problem that you are trying to solve in the first place. +Rather than being overly concerned with ""optimality"", rather explore and experiment more. Study what you are actually trying to achieve, and how to get this into mathematical form to be able to compute what is solving your problem, and what is solving someone else's...",0.0,False,1,6093 +2019-05-17 07:14:43.650,"How to predict different data via neural network, which is trained on the data with 36x60 size?","I was training a neural network with images of an eye that are shaped 36x60. So I can only predict the result using a 36x60 image? But in my application I have a video stream, this stream is divided into frames, for each frame 68 points of landmarks are predicted. In the eye range, I can select the eye point, and using the 'boundingrect' function from OpenCV, it is very easy to get a cropped image. But this image has no form 36x60. What is the correct way to get 36x60 data that can be used for forecasting? Or how to use a neural network for data of another form?","Neural networks (insofar as I've encountered) have a fixed input shape, freedom permitted only to batch size. This (probably) goes for every amazing neural network you've ever seen. Don't be too afraid of reshaping your image with off-the-shelf sampling to the network's expected input size. Robust computer-vision networks are generally trained on augmented data; randomly scaled, skewed, and otherwise transformed in order to---among other things---broaden the network's ability to handle this unavoidable scaling situation. +There are caveats, of course. An input for prediction should be as similar to the dataset it was trained on as possible, which is to say that a model should be applied to the data for which it was designed. For example, consider an object detection network made for satellite applications. If that same network is then applied to drone imagery, the relative size of objects may be substantially larger than the objects for which the network (specifically its anchor-box sizes) was designed. +Tl;dr: Assuming you're using the right network for the job, don't be afraid to scale your images/frames to fit the network's inputs.",1.2,True,1,6094 +2019-05-17 13:19:41.943,How to configure alerts for employee contract expiration in odoo 11?,"i'm using odoo 11 and i want to know how can I configure odoo in a way that the HR manager and the employee received alert before the expiration of contract. +Is it possible to do it ? Any idea for help please ?","This type of scenario is only archived by developing custom addon. +In custom addon you have to specify cron file which will automatically fire some action at regular basis, and which will send email notification to HR Manager that some of employee's contract are going to be expired.",0.0,False,1,6095 +2019-05-17 14:56:30.123,User word2vec model output in larger kmeans project,"I am attempting a rather large unsupervised learning project and am not sure how to properly utilize word2vec. We're trying to cluster groups of customers based on some stats about them and what actions they take on our website. Someone recommended I use word2vec and treat each action a user takes as a word in a ""sentence"". The reason this step is necessary is because a single customer can create multiple rows in the database (roughly same stats, but new row for each action on the website in chronological order). In order to perform kmeans on this data we need to get that down to one row per customer ID. Hence the previous idea to collapse down the actions as words in a sentence ""describing the user's actions"" +My question is I've come across countless tutorials and resources online that show you how to use word2vec (combined with kmeans) to cluster words on their own, but none of them show how to use the word2vec output as part of a larger kmeans model. I need to be able to use the word2vec model along side other values about the customer. How should I go about this? I'm using python for the clustering if you want to be specific with coding examples, but I could also just be missing something super obvious and high level. It seems the word2vec outputs vectors, but kmeans needs straight numbers to work, no? Any guidance is appreciated.","There are two common approaches. + +Taking the average of all words. That is easy, but the resulting vectors tend to be, well, average. They are not similar to the keywords of the document, but rather similar to the most average and least informative words... My experiences with this approach are pretty disappointing, despite this being the most mentioned approach. +par2vec/doc2vec. You add a ""word"" for each user to all it's contexts, in addition to the neighbor words, during training. This way you get a ""predictive"" vector for each paragraph/document/user the same way you get a word in the first word2vec. These are supposedly more informative but require much more effort to train - you can't download a pretrained model because they are computed during training.",0.0,False,1,6096 +2019-05-17 18:10:01.270,"Conversion from pixel to general Metric(mm, in)","I am using openCV to process an image and use houghcircles to detect the circles in the image under test, and also calculating the distance between their centers using euclidean distance. +Since this would be in pixels, I need the absolute distances in mm or inches, can anyone let me know how this can be done +Thanks in advance.","The image formation process implies taking a 2D projection of the real, 3D world, through a lens. In this process, a lot of information is lost (e.g. the third dimension), and the transformation is dependent on lens properties (e.g. focal distance). +The transformation between the distance in pixels and the physical distance depends on the depth (distance between the camera and the object) and the lens. The complex, but more general way, is to estimate the depth (there are specialized algorithms which can do this under certain conditions, but require multiple cameras/perspectives) or use a depth camera which can measure the depth. Once the depth is known, after taking into account the effects of the lens projection, an estimation can be made. +You do not give much information about your setup, but the transformation can be measured experimentally. You simply take a picture of an object of known dimensions and you determine the physical dimension of one pixel (e.g. if the object is 10x10 cm and in the picture it has 100x100px, then 10px is 1mm). This is strongly dependent on the distance to the camera from the object. +An approach a bit more automated is to use a certain pattern (e.g. checkerboard) of known dimensions. It can be automatically detected in the image and the same transformation can be performed.",0.0,False,1,6097 +2019-05-19 00:17:45.020,How to run Airflow dag with more than 100 thousand tasks?,"I have an airflow DAG that has over 100,000 tasks. +I am able to run only up to 1000 tasks. Beyond that the scheduler hangs, the webserver cannot render tasks and is extremely slow on the UI. +I have tried increasing, min_file_process_interval and processor_poll_interval config params. +I have set num_duration to 3600 so that scheduler restarts every hour. +Any limits I'm hitting on the webserver or scheduler? In general, how to deal with a large number of tasks in Airflow? Any config settings, etc would be very helpful. +Also, should I be using SubDagOperator at this scale or not? please advice. +Thanks,","I was able to run more than 165,000 airflow tasks! +But there's a catch. Not all the tasks were scheduled and rendered in a single Airflow Dag. +The problems I faced when I tried to schedule more and more tasks are that of scheduler and webserver. +The memory and cpu consumption on scheduler and webserver dramatically increased as more and more tasks were being scheduled (it is obvious and makes sense). It went to a point where the node couldn't handle it anymore (scheduler was using over 80GB memory for 16,000+ tasks) +I split the single dag into 2 dags. One is a leader/master. The second one being the worker dag. +I have an airflow variable that says how many tasks to process at once (for example, num_tasks=10,000). Since I have over 165,000 tasks, the worker dag will process 10k tasks at a time in 17 batches. +The leader dag, all it does is trigger the same worker dag over and over with different sets of 10k tasks and monitor the worker dag run status. The first trigger operator triggers the worker dag for the first set of 10k tasks and keeps waiting until the worker dag completes. Once it's complete, it triggers the same worker dag with the next batch of 10k tasks and so on. +This way, the worker dag keeps being reused and never have to schedule more than X num_tasks +The bottom line is, figure out the max_number of tasks your Airflow setup can handle. And then launch the dags in leader/worker fashion for max_tasks over and over again until all the tasks are done. +Hope this was helpful.",1.2,True,1,6098 +2019-05-19 02:12:09.703,Let high priority python thread to enter the critical section while low priority thread is execution in the critical section,I have set of threads which can execute a synchronized method in python. Currently when a thread comes to critical section it enters to the critical section if no thread is executing the critical section. Otherwise wait and enter the critical section after lock is released. (it works as synchronization supposed to work). But I have a high priority thread which should enter the critical section whether a low priority thread is in the critical section or not. Is this possible? If so how can I implement this?,"As another answer described very well, this is not possible, there is no way to do it. +What you can and often should do is prevent another lower priority thread from entering this critical section first, before high priority thread. +I.e. if a critical section is being held by some thread, this thread needs to exit it first. But by that time there might be multiple threads waiting for this critical section, some low and some high priority. You may want to ensure higher priority thread gets the critical section first in such situation.",0.3869120172231254,False,1,6099 +2019-05-19 21:14:23.120,Replace os.system with os.popen for security purposes,"Is it possible to use os.popen() to achieve a result similar to os.system? I know that os.popen() is more secure, but I want to know how to be able to actually run the commands through this function. When using os.system(), things can get very insecure and I want to be able to have a secure way of accessing terminal commands.","Anything that uses the shell to execute commands is insecure for obvious reasons (you don't want someone running rm -rf / in your shell :). Both os.system and os.popen use the shell. +For security, use the subprocess module with shell = False +Either way, both of those functions have been deprecated since Python 2.6",1.2,True,1,6100 +2019-05-20 11:26:16.497,"""SSL: CERTIFICATE_VERIFY_FAILED"" error in my telegram bot","My Telegram bot code was working fine for weeks and I didn't changed anything today suddenly I got [SSL: CERTIFICATE_VERIFY_FAILED] error and my bot code no longer working in my PC. +I use Ubuntu 18.04 and I'm usng telepot library. +What is wrong and how to fix it? +Edit: I'm using getMe method and I don't know where is the certificate and how to renew it and I didn't import requests in my bot code. I'm using telepot API by importing telepot in my code.","Probably your certificate expired, that is why it worked fine earlier. Just renew it and all should be good. If you're using requests under the hood you can just pass verify=False to the post or get method but that is unwise. +The renew procedure depends on from where do you get your certificate. If your using letsencrypt for example with certbot. Issuing sudo certbot renew command from shell will suffice.",0.3869120172231254,False,1,6101 +2019-05-20 16:35:33.720,Use C# DLL in Python,"I have a driver which is written in C#, .NET 4.7.0 and build as DLL. I don't have sources from this driver. I want to use this driver in python application. +I wrapped some functionality from driver into method of another C# project. Then I built it into DLL. I used RGiesecke.DllExport to make one method available in python. When i call this method from python using ctypes, I get WinError -532462766 Windows Error 0xe0434352. +If I exclude driver code and keep only wrapper code in exported method everything runs fine. +Could you please give me some advice how to make this working or help me find better sollution? Moving from python to IronPython is no option here. +Thank you.","PROBLEM CAUSE: +Python didn't run wrapper from directory where it was stored together with driver. That caused problem with loading driver.",1.2,True,1,6102 +2019-05-20 17:25:47.853,How to make multiple y axes zoomable individually,"I have a bokeh plot with multiple y axes. I want to be able to zoom in one y axis while having the other one's displayed range stay the same. Is this possible in bokeh, and if it is, how can I accomplish that?","Bokeh does not support this, twin axes are always linked to maintain their original relative scale.",1.2,True,1,6103 +2019-05-21 07:05:10.423,Unsupported major.minor version when running a java program from shell script which is executed by a python program,"I have a shell script that runs some java program on a remote server. +But this shell script is to be executed by a python script which is on my local machine. +Here's the flow : Python script executes the shell script (with paramiko), the shell script then executes a java class. +I am getting an error : 'The java class could not be loaded. java.lang.UnsupportedClassVersionError: (Unsupported major.minor version 50.0)' whenever I run python code. +Limitations: I cannot make any changes to the shell script. +I believe this is java version issue. But I don't know how to explicitly have a python program to run in a specific java environment. +Please suggest how I can get rid of this error. +The java version of unix machine (where shell script executes) : 1.6.0 +Java version of my local machine (where python script executes): 1.7.0","The shell script can stay the same, update java on the remote system to java 1.7 or later. Then it should work. +Another possibility could be to compile the java application for java 1.6 instead. The java compiler (javac) has the arguments -source and -target and adding -source 1.6 -target 1.6 when compiling the application should solve this issue, too (but limits the application to use java 1.6 features). +Also be aware: If you use a build system like gradle or maven, then you have a different way to set source and target version.",0.3869120172231254,False,1,6104 +2019-05-21 07:54:56.323,"Accidentally deleted /usr/bin/python instead of /usr/local/bin/python on OS X/macOS, how to restore?","I had so many Python installations that it was getting frustrating, so I decided to do a full reinstall. I removed the /Library/Frameworks/Python.Frameworks/ folder, and meant to remove the /usr/local/bin/python folder too, but I accidentally removed the /usr/bin/python instead. I don't see any difference, everything seems to be working fine for now, but I've read multiple articles online saying that I should never touch /usr/bin/python as OS X uses it and things will break. +I tried Time Machine but there are no viable recovery options. How can I manually ""restore"" what was deleted? Do I even need to, since everything seems to be working fine for now? I haven't restarted the Mac yet, in fear that things might break. +I believe the exact command I ran was rm -rf /usr/bin/python*, and I don't have anything python related in my /usr/bin/ folder. +I'm running on macOS Mojave 10.14.5","Items can't be recovered when you perform rm -rf. However, you can try the following: +cp /usr/local/bin/python* /usr/bin +This would copy user local python to usr bin and most probably will bail you out. +Don't worry, nothing will happen to your OS. It should work fine :)",0.2012947653214861,False,1,6105 +2019-05-21 09:29:34.240,How to build a resnet with Keras that trains and predicts the subclass from the main class?,"I would like go implement a hierarchical resnet architecture. However, I could not find any solution for this. For example, my data structure is like: + +class A + + +Subclass 1 +Subclass 2 +.... + +class B + + +subclass 6 +........ + + +So i would like to train and predict the main class and then the subclass of the chosen/predicted mainclass. Can someone provide a simple example how to do this with generators?","The easiest way to do so would be to train multiple classifiers and build a hierarchical system by yourself. +One classifier detecting class A, B etc. After that make a new prediction for subclasses. +If you want only one single classifier: +What about just killing the first hierarchy of parent classes? Should be also quite easy. If you really want a model, where the hierarchy is learned take a look at Hierarchical Multi-Label Classification Networks.",0.0,False,1,6106 +2019-05-22 21:18:51.313,AzureDataFactory Incremental Load using Python,"How do I create azure datafactory for incremental load using python? +Where should I mention file load option(Incremental Load:LastModifiedOn) while creating activity or pipeline?? +We can do that using UI by selecting File Load Option. But how to do the same pragmatically using python? +Does python api for datafactory support this or not?","My investigations suggest that the Python SDK has not yet implemented this feature. I used the SDK to connect to my existing instance and fetched two example datasets. I did not find anything that looked like the 'last modified date'. I tried dataset.serialize() , dataset.__dict__ , dataset.properties.__dict__ . I also tried .__slots__ . +Trying serialize() is significant because there ought to be parity between the JSON generated in the GUI and the JSON generated by the Python. The lack of parity suggests the SDK version lags behind the GUI version. +UPDATE: The SDK's are being updated.",0.0,False,1,6107 +2019-05-22 22:30:47.140,Can I connect my IBM Cloudant Database as the callback URL for my Twilio IBM STT add-on service?,"I have a Watson voice assistant instance connected using SIP trunk to a Twilio API. I want to enable to the IBM Speech-To-Text add-on from the Twilio Marketplace which will allow me to obtain full transcriptions of phone calls made to the Watson Assistant bot. I want to store these transcriptions in a Cloudant Database I have created in IBM Cloud. Can I use the endpoint of my Cloudant Database as the callback URL for my Twilio add-on so that when the add-on is activated, the transcription will be added as a document in my Cloudant Database? +It seems that I should be able to somehow call a trancsription service through IBM Cloud's STT service in IBM Cloud, but since my assistant is connected through Twilio, this add-on seems like an easier option. I am new to IBM Cloud and chat-bot development so any information is greatly appreciated.","Twilio developer evangelist here. +First up, I don't believe that you can enable add-ons for voice services that are served through Twilio SIP trunking. +Unless I am mistaken and you are making a call through a SIP trunk to a Twilio number that is responding with TwiML. In this case, then you can add the STT add-on. I'm not sure it would be the best idea to set the webhook URL to your Cloudant DB URL as the webhook is not going to deliver the data in the format that Cloudant expects. +Instead I would build out an application that can provide an endpoint to receive the webhook, transform the data into something Cloudant will understand and then send it on to the DB. +Does that help at all?",0.0,False,1,6108 +2019-05-23 04:26:35.540,How corrupt checksum over TCP/IP,"I am connecting my slave via TCP/IP, everything looks fine by using the Wireshark software I can validate that the CRC checksum always valid “good”, but I am wondering how I can corrupt the CRC checksum so I can see like checksum “Invalid”. Any suggestion how can I get this done maybe python code or any other way if possible. +Thank you all +Tariq","I think you use a library that computes CRC. You can form Modbus packet without it, if you want simulate bad CRC condition",0.2012947653214861,False,1,6109 +2019-05-23 20:27:53.837,How to identify Plaid transactions if transaction ID's change,I noticed that the same transaction had a different transaction ID the second time I pulled it. Why is this the case? Is it because pending transactions have different transaction IDs than those same transactions once posted? Does anyone have recommendations for how I can identify unique transactions if the trx IDs are in fact changing?,"Turns out that the transaction ID often does change. When a transaction is posted (stops pending), the original transaction ID becomes the pending transaction ID, and a new transaction ID is assigned.",1.2,True,1,6110 +2019-05-24 20:15:57.300,How to implement neural network pruning?,"I trained a model in keras and I'm thinking of pruning my fully connected network. I'm little bit lost on how to prune the layers. +Author of 'Learning both Weights and Connections for Efficient +Neural Networks', say that they add a mask to threshold weights of a layer. I can try to do the same and fine tune the trained model. But, how does it reduce model size and # of computations?","If you add a mask, then only a subset of your weights will contribute to the computation, hence your model will be pruned. For instance, autoregressive models use a mask to mask out the weights that refer to future data so that the output at time step t only depends on time steps 0, 1, ..., t-1. +In your case, since you have a simple fully connected layer, it is better to use dropout. It randomly turns off some neurons at each iteration step so it reduces the computation complexity. However, the main reason dropout was invented is to tackle overfitting: by having some neurons turned off randomly, you reduce neurons' co-dependencies, i.e. you avoid that some neurons rely on others. Moreover, at each iteration, your model will be different (different number of active neurons and different connections between them), hence your final model can be interpreted as an ensamble (collection) of several diifferent models, each specialized (we hope) in the understanding of a specific subset of the input space.",0.6730655149877884,False,1,6111 +2019-05-25 15:12:30.457,Controlling Kodi from Browser,"I am currently building a media website using node js. I would like to be able to control Kodi, which is installed of the server computer, remotely from the website browser.How would I go about doing this? My first idea was + +to simply see if I could somehow pipe the entire Kodi GUI into the +browser such that the full program stays on the server +and just the GUI is piped to the browser, sending commands back to +the server; + +however, I could find little documentation on how to do that. +Second, I thought of making a script (eg Python) that would be able to control Kodi and just interface node js with the Python script, but again, +I could find little documentation on that. + Any help would be much appreciated. +Thank You!",Can't you just go to settings -> services -> control and then the 'remote control via http' settings? I use this to login to my local ip e.g. 192.168.1.150:8080 (you can set the port on this page) from my browser and I can do anything from there,0.0,False,1,6112 +2019-05-25 20:48:52.037,How to i split a String by first and last character in python,"I have a list of strings +my_list = ['1Jordan1', '2Michael2', '3Jesse3']. +If I should delete the first and last character, how would I do it in python??",You would use slicing. I would use [1:-1].,0.0,False,1,6113 +2019-05-26 02:09:50.387,Comparing results of neural net on two subsets of features,"I am running a LSTM model on a multivariate time series data set with 24 features. I have ran feature extraction using a few different methods (variance testing, random forest extraction, and Extra Tree Classifier). Different methods have resulted in a slightly different subset of features. I now want to test my LSTM model on all subsets to see which gives the best results. +My problem is that the test/train RMSE scores for my 3 models are all very similar, and every time I run my model I get slightly different answers. This question is coming from a person who is naive and still learning the intricacies of neural nets, so please help me understand: in a case like this, how do you go about determining which model is best? Can you do seeding for neural nets? Or some type of averaging over a certain amount of trials?","Since you have mentioned that using the different feature extraction methods, you are only getting slightly different feature sets, so the results are also similar. Also since your LSTM model is then also getting almost similar RMSE values, the models are able to generalize well and learn similarly and extract important information from all the datasets. +The best model depends on your future data, the computation time and load of different methods and how well they will last in production. Setting a seed is not really a good idea in neural nets. The basic idea is that your model should be able to reach the optimal weights no matter how they start. If your models are always getting similar results, in most cases, it is a good thing.",1.2,True,1,6114 +2019-05-27 23:00:17.260,Setting legend entries manually,"I am using openpyxl to create charts. For some reason, I do not want to insert row names when adding data. So, I want to edit the legend entries manually. I am wondering if anyone know how to do this. +More specifically +class openpyxl.chart.legend.Legend(legendPos='r', legendEntry=(), + layout=None, overlay=None, spPr=None, txPr=None, extLst=None). I want to edit the legendEntry field",You cannot do that. You need to set the rows when creating the plots. That will create the titles for your charts,1.2,True,1,6115 +2019-05-28 00:51:27.173,Time series prediction: need help using series with different periods of days,"There's this event that my organization runs, and we have the ticket sales historic data from 2016, 2017, 2018. This data contains the quantity of tickets selled by day, considering all the sales period. +To the 2019 edition of this event, I was asked to make a prediction of the quantity of tickets selled by day, considering all the sales period, sort of to guide us through this period, meaning we would have the information if we are above or below the expected sales average. +The problem is that the historic data has a different size of sales period in days: +In 2016, the total sales period was 46 days. +In 2017, 77 days. +In 2018, 113 days. +In 2019 we are planning 85 days. So how do I ajust those historical data, in a logic/statistical way, so I could use them as inputs to a statistical predictive model (such as ARIMA model)? +Also, I'm planning to do this on Python, so if you have any suggestions about that, I would love to hear them too! +Thank you!","Based on what I understand after reading your question, I would approach this problem in the following way. + +For each day, find how far out the event is from that day. The max +value for this number is 46 in 2016, 77 in 2017 etc. Scale this value +by the max day. +Use the above variable, along with day of the month, day of the week +etc as extraneous variable +Additionally, use lag information from ticket sales. You can try one +day lag, one week lag etc. +You would be able to generate all this data from the sale start until +end. +Use the generated variables as predictor for each day and use ticket +sales as target variable and generate a machine learning model +instead of forecasting. +Use the machine learning model along with generated variables to predict future sales.",0.0,False,1,6116 +2019-05-28 05:42:52.493,Why can't I push from PyCharm,"I'm a new GitHub user, and this question may be a trivial newbie problem. So I apologize in advance. +I'm using PyCharm for a Python project. I've set up a Git repository for the project and uploaded the files manually through the Git website. I also linked the repository to my PyCharm project. +When I modify a file, PyCharm allows me to ""commit"" it, but when I try to ""push"" it, I get a PyCharm pop-up error message saying ""Push rejected."" No further information is provided. How do I figure out what went wrong -- and how to fix it? +Thanks.","If you manually uploaded files to the Github by dropping them, it now likely has a different history than your local files. +One way you could get around this is to store all of your changes in a different folder, do a git pull in pycharm, abandoning your changes so you are up to date with origin/master, then commit the files and push as you have been doing.",0.3869120172231254,False,1,6117 +2019-06-01 11:32:58.337,How to choose a split variables for continous features for decision tree,I am currently implementing decision tree algorithm. If I have a continous featured data how do i decide a splitting point. I came across few resources which say to choose mid points between every two points but considering I have 8000 rows of data this would be very time consuming. The output/feature label is having category data. Is any approach where I can perform this operation quicker,"Decision tree works calculating entropy and information gain to determine the most important feature. Indeed, 8000 row is not too much for decision tree. But generally, Random forest is similar to decision tree. It is working as ensemble. You can review and try it.Moreover, maybe being slowly is related to another thing.",0.0,False,1,6118 +2019-06-02 09:05:49.710,What is a scalable way of creating cron jobs on Amazon Web Services?,"This is my first question so I appologize if it's not the best quality. +I have a use case: User creates a monitoring task which sends an http request to a website every X hours. User can have thousands of these tasks and can add/modify and delete them. When a user creates a task, django signals create a Celery periodic task which then is running periodically. +I'm searching for a more scalable solution using AWS. I've read about using Lambda + Cloudwatch Events. +My question is: how do I approach this to let my users create tens of thousands of these tasks in the cheapest / most scalable way? +Thank you for reading my question! +Peter","There is no straight forward solution to your problem .You have to proceed step by step with some plumbing along the way . +Event management +1- Create a lambda function that creates a cloudwatch schedule. +2 - Create a lambda function that deletes a cloudwatch schedule. +3 - Persist any event created using dynamodb +4 - Create 2 API gateway that will invoke the 2 lambda above. +5 - Create anohter lambda function (used by cloudwatch) that will invoke the API gateway below. +6 - Create API gateway that will invoke the website via http request. +When the user creates an event from the app, there will be a chaining calls as follow : +4 -> 1,3 -> 5-> 6 +Now there are two other parameters to take into consideration : +Lambda concurrency: you can't run simultaneously more than 1000 lambda in same region. +Cloudwatch: You can not create more than 100 rules per region . Rule is where you define the schedule.",0.0,False,1,6119 +2019-06-03 00:39:25.213,Run python script from another computer without installing packages/setting up environment?,"I have a Jupyter notebook script that will be used to teach others how to use python. +Instead of asking each participant to install the required packages, I would like to provide a folder with the environment ready from the start. +How can I do this? +What is the easiest way to teach python without running into technical problems with packages/environments etc.?","You would need to use a program such as py2exe, pyinstaller, or cx_freeze to package each the file, the modules, and a lightweight interpreter. The result will be an executable which does not require the user to have any modules or even python installed to access it; however, because of the built-in interpreter, it can get quite large (which is why Python is not commonly used to make executables).",0.2012947653214861,False,2,6120 +2019-06-03 00:39:25.213,Run python script from another computer without installing packages/setting up environment?,"I have a Jupyter notebook script that will be used to teach others how to use python. +Instead of asking each participant to install the required packages, I would like to provide a folder with the environment ready from the start. +How can I do this? +What is the easiest way to teach python without running into technical problems with packages/environments etc.?","The easiest way I have found to package python files is to use pyinstaller which packages your python file into an executable file. +If it's a single file I usually run pyinstaller main.py --onefile +Another option is to have a requirements file +This reduces installing all packages to one command pip install -r requirements.txt",0.2012947653214861,False,2,6120 +2019-06-04 10:52:09.683,how to use python-gitlab to upload file with newline?,"I'm trying to use python-gitlab projects.files.create to upload a string content to gitlab. +The string contains '\n' which I'd like it to be the real newline char in the gitlab file, but it'd just write '\n' as a string to the file, so after uploading, the file just contains one line. +I'm not sure how and at what point should I fix this, I'd like the file content to be as if I print the string using print() in python. +Thanks for your help. +EDIT--- +Sorry, I'm using python 3.7 and the string is actually a csv content, so it's basically like: +',col1,col2\n1,data1,data2\n' +So when I upload it the gitlab file I want it to be: +,col1,col2 +1,data1,data2","I figured out by saving the string to a file and read it again, this way the \n in the string will be translated to the actual newline char. +I'm not sure if there's other of doing this but just for someone that encounters a similar situation.",0.0,False,1,6121 +2019-06-04 17:28:52.047,How do you install Django 2x on pip when python 2x is your default version of python but you use python 3x on Bash,"I need to install Django 2.2.2 on my MacBook pro (latest generation), and I am a user of python 3x. However, my default version of python is python 2x and I cannot pip install Django version 2x when I am using python 2x. Could anyone explain how to change the default version of python on MacBook I have looked at many other questions on this site and none have worked. All help is appreciated thank you :)",You can simply use pip3 instead of pip to install Python 3 packages.,1.2,True,1,6122 +2019-06-05 17:11:10.447,Example of using hylang with python multiprocessing,"I am looking for an example of using python multiprocessing (i.e. a process-pool/threadpool, job queue etc.) with hylang.","Note that a straightforward translation runs into a problem on macOS (which is not officially supported, but mostly works anyway): Hy sets sys.executable to the Hy interpreter, and multiprocessing relies on that value to start up new processes. You can work around that particular problem by calling (multiprocessing.set_executable hy.sys_executable), but then it will fail to parse the file containing the Hy code itself, which it does again for some reason in the child process. So there doesn't seem to be a good solution for using multiprocessing with Hy running natively on a Mac. +Which is why we have Docker, I suppose.",0.0,False,1,6123 +2019-06-05 23:27:18.603,How to use python with qr scanner devices?,I want to create a program that can read and store the data from a qr scanning device but i don't know how to get the input from the barcode scanner as an image or save it in a variable to read it after with openCV,"Typically a barcode scanner automatically outputs to the screen, just like a keyboard (except really quickly), and there is an end of line character at the end (like and enter). +Using a python script all you need to do is start the script, connect a scanner, scan something, and get the input (STDIN) of the script. If you built a script that was just always receiving input and storing or processing them, you could do whatever you please with the data. +A QR code is read in the same way that a barcode scanner works, immediately outputting the encoded data as text. Just collect this using the STDIN of a python script and you're good to go!",0.0,False,1,6124 +2019-06-06 06:24:25.907,What are the available estimators which we can use as estimator in onevsrest classifier?,"I want to know briefly about all the available estimators like logisticregression or multinomial regression or SVMs which can be used for classification problems. +These are the three I know. Are there any others like these? and relatively how long they run or how accurate can they get than these?","The following can be used for classification problems: + +Logistic Regression +SVM +RandomForest Classifier +Neural Networks",0.2012947653214861,False,1,6125 +2019-06-06 07:55:29.040,How to use data obtained from a form in Django form?,"I'm trying to create a form in Django using Django form. +I need two types of forms. + +A form that collect data from user, do some calculations and show the results to user without saving the data to database. I want to show the result to user once he/she press button (calculate) next to it not in different page. +A form that collect data from user, look for it in a column in google sheet, and if it's unique, add it to the column otherwise inform the user a warning that the data is not unique. + +Thanks","You could use AJAX and javascript to achieve this, but I suggest doing this only via javascript. This means you will have to rewrite the math in JS and output it directly in the element. +Please let me know if you need any help :) +Jasper",0.0,False,2,6126 +2019-06-06 07:55:29.040,How to use data obtained from a form in Django form?,"I'm trying to create a form in Django using Django form. +I need two types of forms. + +A form that collect data from user, do some calculations and show the results to user without saving the data to database. I want to show the result to user once he/she press button (calculate) next to it not in different page. +A form that collect data from user, look for it in a column in google sheet, and if it's unique, add it to the column otherwise inform the user a warning that the data is not unique. + +Thanks","Start by writing it in a way that the user submits the form (like any normal django form), you process it in your view, do the calculation, and return the same page with the calculated values (render the template). That way you know everything is working as expected, using just Django/python. +Then once that works, refactor to make your form submit the data using AJAX and your view to just return the calculation results in JSON. Your AJAX success handler can then insert the results in the current page. +The reason I suggest you do this in 2 steps is that you're a beginner with javascript, so if you directly try to build this with AJAX, and you're not getting the results you expect, it's difficult to understand where things go wrong.",0.0,False,2,6126 +2019-06-06 09:28:12.653,Cassandra write throttling with multiple clients,"I have two clients (separate docker containers) both writing to a Cassandra cluster. +The first is writing real-time data, which is ingested at a rate that the cluster can handle, albeit with little spare capacity. This is regarded as high-priority data and we don't want to drop any. The ingestion rate varies quite a lot from minute to minute. Sometimes data backs up in the queue from which the client reads and at other times the client has cleared the queue and is (briefly) waiting for more data. +The second is a bulk data dump from an online store. We want to write it to Cassandra as fast as possible at a rate that soaks up whatever spare capacity there is after the real-time data is written, but without causing the cluster to start issuing timeouts. +Using the DataStax Python driver and keeping the two clients separate (i.e. they shouldn't have to know about or interact with each other), how can I throttle writes from the second client such that it maximises write throughput subject to the constraint of not impacting the write throughput of the first client?","The solution I came up with was to make both data producers write to the same queue. +To meet the requirement that the low-priority bulk data doesn't interfere with the high-priority live data, I made the producer of the low-priority data check the queue length and then add a record to the queue only if the queue length is below a suitable threshold (in my case 5 messages). +The result is that no live data message can have more than 5 bulk data messages in front of it in the queue. If messages start backing up on the queue then the bulk data producer stops queuing more data until the queue length falls below the threshold. +I also split the bulk data into many small messages so that they are relatively quick to process by the consumer. +There are three disadvantages of this approach: + +There is no visibility of how many queued messages are low priority and how many are high priority. However we know that there can't be more than 5 low priority messages. +The producer of low-priority messages has to poll the queue to get the current length, which generates a small extra load on the queue server. +The threshold isn't applied strictly because there is a race between the two producers from checking the queue length to queuing a message. It's not serious because the low-priority producer queues only a single message when it loses the race and next time it will know the queue is too long and wait.",1.2,True,1,6127 +2019-06-07 13:05:17.733,Pardot Visit query API - generic query not available,"I am trying to extract/sync data through Pardot API v4 into a local DB. Most APIs were fine, just used the query method with created_after search criteria. But the Visit API does not seem to support neither a generic query of all visit data, nor a created_after search criteria to retrieve new items. +As far as I can see I can only query Visits in the context of a Visitor or a Prospect. +Any ideas why, and how could I implement synchronisation? (sorry, no access to Pardot DB...) +I have been using pypardot4 python wrapper for convenience but would be happy to use the API natively if it makes any difference.","I managed to get a response from Pardot support, and they have confirmed that such response filtering is not available on the Visits API. I asked for a feature request, but hardly any chance to get enough up-votes to be considered :(",1.2,True,1,6128 +2019-06-08 19:04:33.077,How can I stop networkx to change the source and the target node?,"I make a Graph (not Digraph) from a data frame (Huge network) with networkx. +I used this code to creat my graph: +nx.from_pandas_edgelist(R,source='A',target='B',create_using=nx.Graph()) +However, in the output when I check the edge list, my source node and the target node has been changed based on the sort and I don't know how to keep it as the way it was in the dataframe (Need the source and target node stay as the way it was in dataframe).","If you mean the order has changed, check out nx.OrderedGraph",0.0,False,1,6129 +2019-06-08 19:37:59.810,How to fail a Control M job when running a python function,"I have a Control-M job that calls a python script. The python script contains a function that returns True or False. +Is it possible to make the job to fail when the function returns False? +I have to use a shell scrip for this? If yes how should i create it? +Thank you","Return a non-zero value -- i.e. call sys.exit(1) when function returns False, and sys.exit(0) otherwise.",1.2,True,1,6130 +2019-06-11 02:31:46.400,How to load NTU rgbd dataset?,"We are working on early action prediction but we are unable to understand the dataset itself NTU rgbd dataset is 1.3 tb.my laptop Hard disk is 931 GB + .first problem : how to deal with such a big dataset? +Second problem : how to understand dataset? +Third problem: how to load dataset ? +Thanks for the help","The overall size of the dataset is 1.3 TB and this size will decrease after processing the data and converting it into numpy arrays or something else. +But I do not think you will work on the entire dataset, what is the part you want to work on it in the dataset?",0.0,False,1,6131 +2019-06-11 08:49:12.827,How do I install Pytorch offline?,"I need to install Pytorch on a computer with no internet connection. +I've tried finding information about this online but can't find a single piece of documentation. +Do you know how I can do this? Is it even possible?","An easy way with pip: + +Create an empty folder +pip download torch using the connected computer. You'll get the pytorch package and all its dependencies. +Copy the folder to the offline computer. You must be using the same python setup on both computers (this goes for virtual environments as well) +pip install * on the offline computer, in the copied folder. This installs all the packages in the correct order. You can then use pytorch. + +Note that this works for (almost) any kind of python package.",0.9999954793514042,False,1,6132 +2019-06-11 16:14:57.993,Graphing multiple csv lists into one graph in python,"I have 5 csv files that I am trying to put into one graph in python. In the first column of each csv file, all of the numbers are the same, and I want to treat these as the x values for each csv file in the graph. However, there are two more columns in each csv file (to make 3 columns total), but I just want to graph the second column as the 'y-values' for each csv file on the same graph, and ideally get 5 different lines, one for each file. Does anyone have any ideas on how I could do this? +I have already uploaded my files to the variable file_list",Read the first file and create a list of lists in which each list filled by two columns of this file. Then read the other files one by one and append y column of them to the correspond index of this list.,0.0,False,1,6133 +2019-06-11 16:32:40.920,Password authentication failed when trying to run django application on server,"I have downloaded postgresql as well as django and python but when I try running the command ""python manage.py runserver"" it gives me an error saying ""Fatal: password authentication failed for user"" . I am trying to run it locally but am unable to figure out how to get past this issue. +I was able to connect to the server in pgAdmin but am still getting password authentication error message","You need to change the password used to connect to your local Database, and this can be done, modifying your setting.py file in ""DATABASES"" object",0.0,False,1,6134 +2019-06-12 14:54:28.927,How to get a voxel array from a list of 3D points that make up a line in a voxalized volume?,"I have a list of points that represent a needle/catheter in a 3D volume. This volume is voxalized. I want to get all the voxels that the line that connects the point intersects. The line needs to go through all the points. +Ideally, since the round needle/catheter has a width I would like to be able to get the voxels that intersect the actual three dimensional object that is the needle/catheter. (I imagine this is much harder so if I could get an answer to the first problem I would be very happy!) +I am using the latest version of Anaconda (Python 3.7). I have seen some similar problems, but the code is always in C++ and none of it seems to be what I'm looking for. I am fairly certain that I need to use raycasting or a 3D Bresenham algorithm, but I don't know how. +I would appreciate your help!","I ended up solving this problem myself. For anyone who is wondering how, I'll explain it briefly. +First, since all the catheters point in the general direction of the z-axis, I got the thickness of the slices along that axis. Both input points land on a slice. I then got the coordinates of every intersection between the line between the two input points and the z-slices. Next, since I know the radius of the catheter and I can calculate the angle between the two points, I was able to draw ellipse paths on each slice around the points I had previously found (when you cut a cone at and angle, the cross-section is an ellipse). Then I got the coordinates of all the voxels on every slice along the z-axis and checked which voxels where within my ellipse paths. Those voxels are the ones that describe the volume of the catheter. If you would like to see my code please let me know.",0.0,False,1,6135 +2019-06-12 21:34:00.557,Hash a set of three indexes in a key for dictionary?,"I have a matrix of data with three indexes: i, j and k +I want to enter some of the data in this matrix into a dictionary, and be able to find them afterwards in the dictionary. +The data itself can not be the key for the dict. +I would like the i,j,k set of indexes to be the key. +I think I need to ""hash"" (some sort of hash) in one number from which I can get back the i,j,k. I need the result key to be ordered so that: + +key1 for 1,2,3 is greater than +key2 for 2,1,3 is greater than +key3 for 2,3,1 + +Do you know any algorithms to get the keys from this set of indexes? Or is there a better structure in python to do what I want to do? +I can't know before I store the data how much I will get, so I think I cannot just append the data with its indexes.","Only immutable elements can be used as dictionary keys + +This mean you can't use a list (mutable data type) but you can use a tuple as the key of your dictionary: dict_name[(i, j, k)] = data",1.2,True,1,6136 +2019-06-12 23:20:49.637,Chatterbot sqlite store in repl.it,"I'm wondering how sqlite3 works when working in something like repl.it? I've been working on learning chatterbot on my own computer through Jupiter notebook. I'm a pretty amateur coder, and I have never worked with databases or SQL. When working from my own computer, I pretty much get the concept that when setting up a new bot with chatterbot, it creates a sqlite3 file, and then saves conversations to it to improve the chatbot. However, if I create a chatbot the same way only through repl.it and give lots of people the link, is the sqlite3 file saved online somewhere? Is it big enough to save lots of conversations from many people to really improve the bot well?","I am not familiar with repl.it, but for all the answers you have asked the answer is yes. For example, I have made a simple web page that uses the chatterbot library. Then I used my own computer as a server using ngrok and gather training data from users.",0.0,False,1,6137 +2019-06-14 03:35:14.117,Command prompt does not recognize changes in PATH. How do I fix this?,"I am attempting to download modules in Python through pip. No matter how many times I edit the PATH to show the pip.exe, it shows the same error: +'pip' is not recognized as an internal or external command, +operable program or batch file. +I have changed the PATH many different times and ways to make pip usable, but these changes go unnoticed by the command prompt terminal. +How should I fix this?",Are you using PyCharm? if yes change the environment to your desired directory and desired interpreter if you do have multiple interpreter available,0.0,False,1,6138 +2019-06-14 21:20:00.560,Using python on android tablet,"Learning python workflow on android tablet +I have been using Qpython3 but find it unsatisfactory +Can anybody tell me how best to learn the python workflow using an android tablet... that is what IDE works best with android and any links to pertinent information. Thank you.","Try pydroid3 instead of Qpython.it have almost all scientific Python libraries like Numpy,scikit-learn,matplotlib,pandas etc.All you have to do is to download the scripting library.You can save your file with extension ' .py ' and then upload it to drive and then to colab +Hope this will help.......",0.2012947653214861,False,1,6139 +2019-06-16 01:10:00.687,Wing IDE The debug server encountered an error in probing locals,"I am running Wing IDE 5 with Python 2.4. Everything was fine until I tried to debug and set a breakpoint. Arriving at the breakpoint I get an error message: +""The debug server encountered an error in probing locals or globals..."" +And the Stack Data display looks like: + locals + globals +I am not, to my knowledge, using a server client relationship or anything special, I am simply debugging a single threaded program running directly under the IDE. Anybody seen this or know how to fix it? +Wing IDE 5.0.9-1","That's a pretty old version of Wing and likely a bug that's been fixed since then, so trying a newer version of Wing may solve it. +However, if you are stuck with Python 2.4 then that's the latest that supports it (except that unofficially Wing 6 may work with Python 2.4 on Windows). +A work-around would be to inspect data from the Debug Probe and/or Watch tools (both available in the Tools menu). +Also, Clear Stored Value Errors in the Debug menu may allow Wing to load the data in a later run if the problem doesn't reoccur.",1.2,True,1,6140 +2019-06-18 12:13:26.103,How to change a OneToOneField into ForeignKey in django model with data in both table?,"I am having a model Employee with a OneToOneField relationship with Django USER model. Now for some reason, I want to change it to the ManyToOne(ForeignKey) relationship with the User model. +Both these tables have data filled. Without losing the data how can I change it? +Can I simply change the relationship and migrate?","makemigrations in this case would only correspond to an sql of Alter field you can see the result of makemigrations, the same sql will be executed when you migrate the model so the data would not be affected",0.0,False,1,6141 +2019-06-18 14:09:10.777,Does escaping work differently in Python shell? (Compared to code in file),"In a Python 3.7 shell I get some unexpected results when escaping strings, see examples below. Got the same results in the Python 2.7 shell. +A quick read in the Python docs seems to say that escaping can be done in strings, but doesn't seem to say it can't be used in the shell. (Or I have missed it). +Can someone explain why escaping doesn't seem to work as expected. +Example one: +input: +>>> ""I am 6'2\"" tall"" +output: +'I am 6\'2"" tall' +while >>> print(""I am 6'2\"" tall"") +returns (what I expected): +I am 6'2"" tall +(I also wonder how the backslash, in the unexpected result, ends up behind the 6?) +Another example: +input: +>>> ""\tI'm tabbed in."" +output: +""\tI'm tabbed in."" +When inside print() the tab is replaced with a proper tab. (Can't show it, because stackoverflow seems the remove the tab/spaces in front of the line I use inside a code block).","The interactive shell will give you a representation of the return value of your last command. It gives you that value using the repr() method, which tries to give a valid source code representation of the value; i.e. something you could copy and paste into code as is. +print on the other hand prints the contents of the string to the console, without regards whether it would be valid source code or not.",0.3869120172231254,False,1,6142 +2019-06-18 15:01:36.913,Writing to a file in C while reading from it in python,"I am working with an Altera DE1-SoC board where I am reading data from a sensor using a C program. The data is being read continually, in a while loop and written to a text file. I want to read this data using a python program and display the data. +The problem is that I am not sure how to avoid collision during the read/write from the file as these need to happen simultaneously. I was thinking of creating a mutex, but I am not sure how to implement it so the two different program languages can work with it. +Is there a simple way to do this? Thanks.","You could load a C library into Python using cdll.LoadLibrary and call a function to get the status of the C mutex. Then in Python if the C mutex is locking then don't read, and if it is unlocked then it can read.",0.1352210990936997,False,2,6143 +2019-06-18 15:01:36.913,Writing to a file in C while reading from it in python,"I am working with an Altera DE1-SoC board where I am reading data from a sensor using a C program. The data is being read continually, in a while loop and written to a text file. I want to read this data using a python program and display the data. +The problem is that I am not sure how to avoid collision during the read/write from the file as these need to happen simultaneously. I was thinking of creating a mutex, but I am not sure how to implement it so the two different program languages can work with it. +Is there a simple way to do this? Thanks.","Operating system will take care of this as long as you can open that file twice (one for read and one for write). Just remember to flush from C code to make sure your data are actually written to disk, instead of being kept in cache in memory.",0.1352210990936997,False,2,6143 +2019-06-20 06:34:56.463,Building a window application from the bunch of python files,"I have written some bunch of python files and i want to make a window application from that. +The structure looks like this: +Say, a.py,b.py,c.py are there. a.by is the file which i want application to open and it is basically a GUI which has import commands for ""b.py"" and ""c.py"". +I know this might be a very basic problem,but i have just started to packaging and deployment using python.Please tell me how to do that , or if is there any way to do it by py2exe and pyinstaller? +I have tried to do it by py2exe and pyinstaller from the info available on internet , but that seems to create the app which is running only ""a.py"" .It is not able to then use ""b"" and ""c "" as well.","I am not sure on how you do this with py2exe. I have used py2app before which is very similar, but it is for Mac applications. For Mac there is a way to view the contents of the application. In here you can add the files you want into the resources folder (where you would put your 'b.py' and 'c.py'). +I hope there is something like this in Windows and hope it helps.",0.0,False,1,6144 +2019-06-20 13:04:42.747,How to display number of epochs in tensorflow object detection api with Faster Rcnn?,"I am using Tensorflow Object detection api. What I understood reading the faster_rcnn_inception_v2_pets.config file is that num_steps mean the total number of steps and not the epochs. But then what is the point of specifying batch_size?? Lets say I have 500 images in my training data and I set batch size = 5 and num_steps = 20k. Does that mean number of epochs are equal to 200 ?? +When I run model_main.py it shows only the global_steps loss. So if these global steps are not the epochs then how should I change the code to display train loss and val loss after each step and also after each epoch.","So you are right with your assumption, that you have 200 epochs. +I had a similar problem with the not showing of loss. +my solution was to go to the model_main.py file and then insert +tf.logging.set_verbosity(tf.logging.INFO) +after the import stuff. +then it shows you the loss after each 100 steps. +you could change the set_verbosity if you want to have it after every epoch ;)",0.3869120172231254,False,1,6145 +2019-06-20 13:36:08.230,"how can i search for facebook users ,using facebook API(V3.3) in python 3","I want to be able to search for any user using facebook API v3.3 in python 3. +I have written a function that can only return my details and that's fine, but now I want to search for any user and I am not succeeding so far, it seems as if in V3.3 I can only search for places and not users + +The following function search and return a place, how can I modify it so that I can able to search for any Facebook users? + +def search_friend(): + graph = facebook.GraphAPI(token) + find_user = graph.search(q='Durban north beach',type='place') + print(json.dumps(find_user, indent=4))","You can not search for users any more, that part of the search functionality has been removed a while ago. +Plus you would not be able to get any user info in the first place, unless the user in question logged in to your app first, and granted it permission to access at least their basic profile info.",0.3869120172231254,False,1,6146 +2019-06-21 07:53:06.587,Record Audio from Peppers Tablet Microphone,"I would like to use the microphone of peppers tablet to implement speech recognition. +I already do speech recognition with the microphones in the head. +But the audio I get from the head microphones is noisy due to the fans in the head and peppers joints movement. +Does anybody know how to capture the audio from peppers tablet? +I am using Pepper 2.5. and would like to solve this with python. +Thanks!","With NAOqi 2.5 on Pepper it is not possible to access the tablet's microphone. +You can either upgrade to 2.9.x and use the Android API for this, or stay in 2.5 and use Python to get the sound from Pepper's microphones.",0.0,False,1,6147 +2019-06-21 10:48:44.013,How to create .mdb file?,"I am new with zarr, HDF5 and LMDB. I have converted data from HDF5 to Zarr but i got many files with extension .n (n from 0 to 31). I want to have just one file with .zarr extension. I tried to use LMDB (zarr.LMDBStore function) but i don't understand how to create .mdb file ? Do you have an idea how to do that ? +Thank you !","@kish When trying your solution i got this error: +from comtypes.gen import Access +ImportError: cannot import name 'Access'",0.0,False,1,6148 +2019-06-21 15:20:04.737,How to remove regularisation from pre-trained model?,"I've got a partially trained model in Keras, and before training it any further I'd like to change the parameters for the dropout, l2 regularizer, gaussian noise etc. I have the model saved as a .h5 file, but when I load it, I don't know how to remove these regularizing layers or change their parameters. Any clue as to how I can do this?",Create a model with your required hyper-parameters and load the parameters to the model using load_weight().,0.0,False,1,6149 +2019-06-21 17:20:48.640,How to display contact without company in odoo?,"how to display contact without company in odoo 11 , exemple : if mister X in Company Y, in odoo, display this mister and company : Y, X. But i want only X. thanks",That name comes via name_get method written inside res.partner.py You need to extend that method in your custom module and remove company name as a prefix from the contact name.,0.3869120172231254,False,1,6150 +2019-06-22 20:23:45.847,Python3 script exit with any traceback?,"I have one Python3 script that exits without any traceback from time to time. +Some said in another question that it was caused by calling sys.exit, but I am not pretty sure whether this is the case. +So how can I make Python3 script always exit with traceback, of course except when it is killed with signal 9?","It turns out that the script crashed when calling some function from underlying so, and crashed without any trackback. .",1.2,True,1,6151 +2019-06-24 14:06:10.280,"Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, invalid path","I get this error: + +Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, invalid path: /home/yosra/Desktop/CERT.RSA + +When I run: $ virtualenv venv +So I put a random CERT.RSA on the Desktop which worked and I created my virtual environment, but then when I run: pip install -r requirements.txt +I got this one: + +Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /KristianOellegaard/django-hvad/archive/2.0.0-beta.tar.gz (Caused by SSLError(SSLError(0, 'unknown error (_ssl.c:3715)'),)) + +I feel that these 2 errors are linked to each other, but I want to know how can I fix the first one?","I received this error while running the command as ""pip install flask"" in Pycharm. +If you look at the error, you will see that the error points out to ""packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle -- Invalid path"". +I solved this by removing the environment variable ""REQUESTS_CA_BUNDLE"" OR you can just change the name of the environment variable ""REQUESTS_CA_BUNDLE"" to some other name. +Restart your Pycharm and this should be solved. +Thank you !",0.0814518047658113,False,2,6152 +2019-06-24 14:06:10.280,"Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, invalid path","I get this error: + +Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, invalid path: /home/yosra/Desktop/CERT.RSA + +When I run: $ virtualenv venv +So I put a random CERT.RSA on the Desktop which worked and I created my virtual environment, but then when I run: pip install -r requirements.txt +I got this one: + +Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /KristianOellegaard/django-hvad/archive/2.0.0-beta.tar.gz (Caused by SSLError(SSLError(0, 'unknown error (_ssl.c:3715)'),)) + +I feel that these 2 errors are linked to each other, but I want to know how can I fix the first one?","We get this all the time for various 'git' actions. We have our own CA + intermediary and we don't customize our software installations enough to accomodate that fact. +Our general fix is update your ca-bundle.crt with the CA cert pems via either concatenation or replacement. +e.g. cat my_cert_chain.pem >> $(python -c ""import certifi; print(certifi.where())"") +This works great if you have an /etc/pki/tls/certs directory, but with python the python -c ""import certifi; print(certifi.where())"" tells you the location of python's ca-bundle.crt file. +Althought it's not a purist python answer, since we're not adding a new file / path, it solves alot of other certificate problems with other software when you understand the underlying issue. +I recommended concatenating in this case as I don't know what else the file is used for vis-a-vis pypi.",0.0,False,2,6152 +2019-06-24 20:31:18.433,Running Python Code in .NET Environment without Installing Python,"Is it possible to productionize Python code in a .NET/C# environment without installing Python and without converting the Python code to C#, i.e. just deploy the code as is? +I know installing the Python language would be the reasonable thing to do but my hesitation is that I just don't want to introduce a new language to my production environment and deal with its testing and maintenance complications, since I don't have enough manpower who know Python to take care of these issues. +I know IronPython is built on CLR, but don't know how exactly it can be hosted and maintained inside .NET. Does it enable one to treat PYthon code as a ""package"" that can be imported into C# code, without actually installing Python as a standalone language? How can IronPython make my life easier in this situation? Can python.net give me more leverage?","IronPython is limited compared to running Python with C based libraries needing the Python Interpreter, not the .NET DLR. I suppose it depends how you are using the Python code, if you want to use a lot of third party python libraries, i doubt that IronPython will fit your needs. +What about building a full Python application but running it all from Docker? +That would require your environments to have Docker installed, but you could then also deploy your .NET applications using Docker too, and they would all be isolated and not dirty your 'environment'. +There are base docker images out there that are specifically for Building Python and .NET Project and also for running.",0.3869120172231254,False,1,6153 +2019-06-25 13:23:01.350,No module named 'numpy' Even When Installed,"I'm using windows with Python 3.7.3, I installed NumPy via command prompt with ""pip install NumPy"", and it installed NumPy 1.16.4 perfectly. However, when I run ""import numpy as np"" in a program, it says ""ModuleNotFoundError: No module named 'numpy'"" +I only have one version of python installed, and I don't know how I can fix this. How do I fix this?","python3 is not supported under NumPy 1.16.4. Try to install a more recent version of NumPy: +pip uninstall numpy +pip install numpy",1.2,True,1,6154 +2019-06-26 02:23:52.283,How I get the error log generates from a flask app installed on CPanel?,"I have a flask application installed on cpanel and it's giving me some error while the application is running. Application makes an ajax request from the server, but server returns the response with a 500 error. I have no idea how I get the information that occurs to throw this error. +There's no information on the cpanel error log and is it possible to create some log file that logs errors when occur in the same application folder or something?",When you log into cPanel go to the Errors menu and it will give a more detailed response to your errors there. You can also try and check: /var/log/apache/error.log or /var/log/daemon.log,0.3869120172231254,False,1,6155 +2019-06-26 06:12:06.163,How can I output to a v4l2 driver using FFMPEG's avformat_write_header?,"I'm trying to use PyAV to output video to a V4l2 loopback device (/dev/video1), but I can't figure out how to do it. It uses the avformat_write_header() from libav* (ffmpeg bindings). +I've been able to get ffmpeg to output to the v4l2 device from the CLI but not from python.","Found the solution. The way to do this is: + +Set the container format to v4l2 +Set the stream format as ""rawvideo"" +Set the framerate (if it's a live stream, set the framerate to 1 fps higher than the stream is so that you don't get an error) +Set pixel format to either RGB24 or YUV420",0.0,False,1,6156 +2019-06-26 09:33:29.453,How to set up data collection for small-scale algorithmic trading software,"This is a question on a conceptual level. +I'm building a piece of small-scale algorithmic trading software, and I am wondering how I should set up the data collection/retrieval within that system. The system should be fully autonomous. +Currently my algorithm that I want to trade live is doing so on a very low frequency, however I would like to be able to trade with higher frequency in the future and therefore I think that it would be a good idea to set up the data collection using a websocket to get real time trades straight away. I can aggregate these later if need be. +My first question is: considering the fact that the data will be real time, can I use a CSV-file for storage in the beginning, or would you recommend something more substantial? +In any case, the data collection would proceed as a daemon in my application. +My second question is: are there any frameworks available to handle real-time incoming data to keep the database constant while the rest of the software is querying it to avoid conflicts? +My third and final question is: do you believe it is a wise approach to use a websocket in this case or would it be better to query every time data is needed for the application?","CSV is a nice exchange format, but as it is based on a text file, it is not good for real-time updates. Only my opinion but I cannot imagine a reason to prefere that to database. +In order to handle real time conflicts, you will later need a professional grade database. PostgreSQL has the reputation of being robust, MariaDB is probably a correct choice too. You could use a liter database in development mode like SQLite, but beware of the slight differences: it is easy to write something that will work on one database and will break on another one. On another hand, if portability across databases is important, you should use at least 2 databases: one at development time and a different one at integration time. +A question to ask yourself immediately is whether you want a relational database or a noSQL one. Former ensures ACID (Atomicity, Consistency, Isolation, Durability) transations, the latter offers greater scalability.",1.2,True,1,6157 +2019-06-27 05:15:37.540,"So when I run my python selenium script through jenkins, how should I write the 'driver = webdriver.Chrome()'?","So when I run my python selenium script through Jenkins, how should I write the driver = webdriver.Chrome() +How should I put the chrome webdriver EXE in jenkins? +Where should I put it?","If you have added your repository path in jenkins during job configuration, Jenkins will create a virtual copy of your workspace. So, as long as the webdriver file is somewhere in your project folder structure and as long as you are using relative path to reference it in your code, there shouldn't be any issues with respect to driver in invocation. +You question also depends on several params like: +1. Whether you are using Maven to run the test +2. Whether you are running tests on Jenkins locally or on a remote machine using Selenium Grid Architecture.",1.2,True,1,6158 +2019-06-27 08:57:46.013,Multiple header in Pandas DataFrame to_excel,"I need to export my DataFrame to Excel. Everything is good but I need two ""rows"" of headers in my output file. That mean I need two columns headers. I don't know how to export it and make double headers in DataFrame. My DataFrame is created with dictionary but I need to add extra header above. +I tried few dumb things but nothing gave me a good result. I want to have on first level header for every three columns and on second level header for each column. They must be different. +I expect output with two headers above columns.","Had a similar issue. Solved by persisting cell-by-cell using worksheet.write(i, j, df.iloc[i,j]), with i starting after the header rows.",0.0,False,1,6159 +2019-06-27 09:51:08.853,How can I find the index of a tuple inside a numpy array?,"I have a numpy array as: +groups=np.array([('Species1',), ('Species2', 'Species3')], dtype=object). +When I ask np.where(groups == ('Species2', 'Species3')) or even np.where(groups == groups[1]) I get an empty reply: (array([], dtype=int64),) +Why is this and how can I get the indexes for such an element?","It's not means search a tuple('Species2', 'Species3') from groups when you use +np.where(groups == ('Species2', 'Species3')) +it means search 'Species2' and 'Species3' separately if you have a Complete array like this +groups=np.array([('Species1',''), ('Species2', 'Species3')], dtype=object)",0.1016881243684853,False,1,6160 +2019-06-27 12:15:35.603,Aggregate Ranking using Khatri-Rao product,"I have constructed 2 graphs and calculated the eigenvector centrality of each node. Each node can be considered as an individual project contributor. Consider 2 different rankings of project contributors. They are ranked based on the eigenvector of the node. +Ranking #1: +Rank 1 - A +Rank 2 - B +Rank 3 - C +Ranking #2: +Rank 1 - B +Rank 2 - C +Rank 3 - A +This is a very small example but in my case, I have almost 400 contributors and 4 different rankings. My question is how can I merge all the rankings and get an aggregate ranking. Now I can't just simply add the eigenvector centralities and divide it by the number of rankings. I was thinking to use the Khatri-Rao product or Kronecker Product to get the result. +Can anyone suggest me how can I achieve this? +Thanks in advance.",Rank both graphs separately each node gets a rank in both graphs then do simple matrix addition. Now normalize the rank. This should keep the relationship like rank1>rank2>rank3>rank4 true and relationships like rank1+rank1>rank1+rank2 true. I don't know how it would help you taking the Khatri-Rao product of the matrix. That would make you end up with more than 400 nodes. Then you would need to compress them back to 400 nodes in-order to have 400 ranked nodes at the end. Who told you to use Khatri-Rao product?,0.0,False,1,6161 +2019-06-28 16:20:58.207,How to use Javascript in Spyder IDE?,"I want to use write code in Javascript, in the Spyder IDE, that is meant for Python. I have read that Spyder supports multiple languages but I'm not sure how to use it. I have downloaded Nodejs and added it to the environment variables. I'd like to know how get Javascript syntax colouring, possibly auto-completion and Help options as well ,and I'd also like to know how to conveniently execute the .js file and see the results in a console.","(Spyder maintainer here) Sorry but for now we only support Python for all the functionality that you are looking for (code completion, help and code execution). +Our next major version (Spyder 4, to be released later in 2019) will have the ability to give code completion and linting for other programming languages, but it'll be more of a power-user feature than something anyone can use.",1.2,True,1,6162 +2019-06-29 20:41:24.083,How to view pyspark temporary tables on Thrift server?,"I'm trying to make a temporary table a create on pyspark available via Thrift. My final goal is to be able to access that from a database client like DBeaver using JDBC. +I'm testing first using beeline. +This is what i'm doing. + +Started a cluster with one worker in my own machine using docker and added spark.sql.hive.thriftServer.singleSession true on spark-defaults.conf +Started Pyspark shell (for testing sake) and ran the following code: +from pyspark.sql import Row +l = [('Ankit',25),('Jalfaizy',22),('saurabh',20),('Bala',26)] +rdd = sc.parallelize(l) +people = rdd.map(lambda x: Row(name=x[0], age=int(x[1]))) +people = people.toDF().cache() +peebs = people.createOrReplaceTempView('peebs') +result = sqlContext.sql('select * from peebs') +So far so good, everything works fine. +On a different terminal I initialize spark thrift server: +./sbin/start-thriftserver.sh --hiveconf hive.server2.thrift.port=10001 --conf spark.executor.cores=1 --master spark://172.18.0.2:7077 +The server appears to start normally and I'm able to see both pyspark and thrift server jobs running on my spark cluster master UI. +I then connect to the cluster using beeline +./bin/beeline +beeline> !connect jdbc:hive2://172.18.0.2:10001 +This is what I got + +Connecting to jdbc:hive2://172.18.0.2:10001 + Enter username for jdbc:hive2://172.18.0.2:10001: + Enter password for jdbc:hive2://172.18.0.2:10001: + 2019-06-29 20:14:25 INFO Utils:310 - Supplied authorities: 172.18.0.2:10001 + 2019-06-29 20:14:25 INFO Utils:397 - Resolved authority: 172.18.0.2:10001 + 2019-06-29 20:14:25 INFO HiveConnection:203 - Will try to open client transport with JDBC Uri: jdbc:hive2://172.18.0.2:10001 + Connected to: Spark SQL (version 2.3.3) + Driver: Hive JDBC (version 1.2.1.spark2) + Transaction isolation: TRANSACTION_REPEATABLE_READ + +Seems to be ok. +When I list show tables; I can't see anything. + +Two interesting things I'd like to highlight is: + +When I start pyspark I get these warnings + +WARN ObjectStore:6666 - Version information not found in metastore. hive.metastore.schema.verification is not enabled so recording the schema version 1.2.0 +WARN ObjectStore:568 - Failed to get database default, returning NoSuchObjectException +WARN ObjectStore:568 - Failed to get database global_temp, returning NoSuchObjectException + +When I start the thrift server I get these: + +rsync from spark://172.18.0.2:7077 + ssh: Could not resolve hostname spark: Name or service not known + rsync: connection unexpectedly closed (0 bytes received so far) [Receiver] + rsync error: unexplained error (code 255) at io.c(235) [Receiver=3.1.2] + starting org.apache.spark.sql.hive.thriftserver.HiveThriftServer2, logging to ... + + +I've been through several posts and discussions. I see people saying we can't have temporary tables exposed via thrift unless you start the server from within the same code. If that's true how can I do that in python (pyspark)? +Thanks","createOrReplaceTempView creates an in-memory table. The Spark thrift server needs to be started on the same driver JVM where we created the in-memory table. +In the above example, the driver on which the table is created and the driver running STS(Spark Thrift server) are different. +Two options +1. Create the table using createOrReplaceTempView in the same JVM where the STS is started. +2. Use a backing metastore, and create tables using org.apache.spark.sql.DataFrameWriter#saveAsTable so that tables are accessible independent of the JVM(in fact without any Spark driver. +Regarding the errors: +1. Relates to client and server metastore version. +2. Seems like some rsync script trying to decode spark:\\ url +Both doesnt seems to be related to the issue.",0.0,False,1,6163 +2019-06-30 00:14:55.133,How do I store information about a front-end button on the Django server?,"Basically I want to store a buttons service server-side that way it can persist through browser closes and page refresh. +Here's what the user is trying to do + +The user searches in a search bar for a list of products. +When the results show up, they are shown a button that triggers an action for each individual product. They are also shown a master button that can trigger the same action for each product that is listed. +Upon clicking the button, I want to disable it for 30 seconds and have this persist through page refreshes and browser close. + +What I've done +Currently I have this implemented using AJAX calls on the client side, but if the page refreshes it resets the button and they can click it again. So I looked into using javascript's localStorage function, but in my situation it would be better just to store this on the server. +What I think needs to happen + +Create a model in my Django app for a button. Its attributes would be its status and maybe some meta data (last clicked, etc). +Whenever the client requests a list of products, the views will send the list of products and it will be able to query the database for the respective button's status and implement a disabled attribute directly into the template. +If the button is available to be pressed then the client side will make an AJAX POST call to the server and the server will check the buttons status. If it's available it will perform the action, update the buttons status to disabled for 30 seconds, and send this info back to the client in order to reflect it in the DOM. + +A couple questions + +Is it just a matter of creating a model for the buttons and then querying the database like normal? +How do I have Django update the database after 30 seconds to make a button's status go from disabled back to enabled? +When the user presses the button it's going to make it disabled, but it will only be making it disabled in the database. What is the proper way to actually disable the button without a page refresh on the client side? Do I just disable the button in javascript for 30 seconds, and then if they try to refresh the page then the views will see the request for the list of products and it will check the database for each button's status and it will serve the button correctly? + +Thank you very much for the help!!","Is it just a matter of creating a model for the buttons and then + querying the database like normal? + +Model could be something like Button (_id, last_clicked as timestamp, user_id) +While querying you could simply sort by timestamp and LIMIT 1 to get the last click. By not overwriting the original value it would ensure a bit faster write. +If you don't want the buttons to behave similarly for each user you will have to create a mapping of the button with the user who clicked it. Even if your current requirements don't need them, create an extensible solution where mapping the user with this table is quite easy. + +How do I have Django update the database after 30 seconds to make a + button's status go from disabled back to enabled? + +I avoid changing the database without a client request mapped to the change. This ensures the concurrency and access controls. And also has higher predictability for the current state of data. Following that, I would suggest not to update the db after the time delta(30 sec). +Instead of that you could simply compare the last_clicked timestamp and calculate the delta either server side before sending the response or in client side. +This decision could be important, consider a scenario when the client has a different time on his system than the server time. + +When the user presses the button it's going to make it disabled, but + it will only be making it disabled in the database. What is the proper + way to actually disable the button without a page refresh on the + client side? Do I just disable the button in javascript for 30 + seconds, and then if they try to refresh the page then the views will + see the request for the list of products and it will check the + database for each button's status and it will serve the button + correctly? + +You'd need to do a POST request to communicate the button press timestamp with the db. You'd also need to ensure that the POST request is successful as an unsuccessful request would not persist the data in case of browser closure. +After doing the above two you could disable the button only from the client side without trying the get the button last_clicked timestamp.",1.2,True,1,6164 +2019-06-30 05:53:43.637,"Using a Discord bot, how do I get a string of an embed message from another bot",I am creating a Discord bot that needs to check all messages to see if a certain string is in an embed message created by any other Discord bot. I know I can use message.content to get a string of the message a user has sent but how can I do something similar with bot embeds in Python?,Use message.embeds instead to get the embed string content,1.2,True,1,6165 +2019-07-01 09:49:35.957,Python magic is not recognizing the correct content,"I have parsed the content of a file to a variable that looks like this; + +b'8,092436.csv,,20f85' + +I would now like to find out what kind of filetype this data is coming from, with; + +print(magic.from_buffer(str(decoded, 'utf-8'), mime=True)) + +This prints; + +application/octet-stream + +Anyone know how I would be able to get a result saying 'csv'?","Use magic on the original file. +You also need to take into account that CSV is really just a text file that uses particular characters to delimit the content. There is no explicit identifier that indicates that the file is a CSV file. Even then the CSV module needs to be configured to use the appropriate delimiters. +The delimiter specification of a CSV file is either defined by your program or needs to be configured (see importing into Excel as an example, you are presented with a number of options to configure the type of CSV to import).",1.2,True,1,6166 +2019-07-01 15:01:58.223,Configure proxy with python,"I am looking to use a public API running on a distant server from within my company. For security reasons, I am supposed to redirect all the traffic via the company's PROXY. Does anyone know how to do this in Python?","Set the HTTP_PROXY environment variable before starting your python script +e.g. export HTTP_PROXY=http://proxy.host.com:8080",0.2012947653214861,False,2,6167 +2019-07-01 15:01:58.223,Configure proxy with python,"I am looking to use a public API running on a distant server from within my company. For security reasons, I am supposed to redirect all the traffic via the company's PROXY. Does anyone know how to do this in Python?","Directly in python you can do : +os.environ[""HTTP_PROXY""] = http://proxy.host.com:8080. +Or as it has been mentioned before launching by @hardillb on a terminal : +export HTTP_PROXY=http://proxy.host.com:8080",0.3869120172231254,False,2,6167 +2019-07-03 17:35:26.190,How can I find domain that has been used from a client to reach my server in python socket?,I just wonder how apache server can know the domain you come from you can see that in Vhost configuration,"By a reverse DNS lookup of the IP; socket.gethostbyaddr(). +Results vary; many IPs from consumer ISPs won't resolve to anything interesting, because of NAT and just not maintaining a generally informative reverse zone.",0.0,False,1,6168 +2019-07-03 22:16:01.657,How to write each dataframe partition into different tables,"I am using Databricks to connect to an Eventhub, where each message comming from the EventHub may be very different from another. +In the message, I have a body and an id. +I am looking for performance, so I am avoiding collecting data or doing unecessary processings, also I want to do the saving in parallel by partition. However I am not sure on how to do this in a proper way. +I want to append the body of each ID in a different AND SPECIFIC table in batches, the ID will give me the information I need to save in the right table. So in order to do that I have been trying 2 approachs: + +Partitioning: Repartition(numPartitions, ID) -> ForeachPartition +Grouping: groupBy('ID').apply(myFunction) #@pandas_udf GROUPED_MAP + +The approach 1 doens't look very attracting to me, the repartition process looks kind unecessary and I saw in the docs that even if I set a column as a partition, it may save many ids of that column in a single partition. It only garantees that all data related to that id is in the partition and not splitted +The approach 2 forces me to output from the pandas_udf, a dataframe with the same schema of the input, which is not going to happen since I am transforming the eventhub message from CSV to dataframe in order to save it to the table. I could return the same dataframe that I received, but it sounds weird. +Is there any nice approach I am not seeing?","If your Id has distinct number of values (kind of type/country column) you can use partitionBy to store and thereby saving them to different table will be faster. +Otherwise create a derive column(using withColumn) from you id column by using the logic same as you want to use while deviding data across tables. Then you can use that derive column as a partition column in order to have faster load.",1.2,True,1,6169 +2019-07-04 09:21:11.737,how to get the memebrs of a telegram group greater than 10000,"I am getting only upto 10000 members when using telethon how to get more than 10000 +I tried to run multiple times to check whether it is returning random 10000 members but still most of them are same only few changed that also not crossing two digits +Expected greater than 10000 +but actual is 10000","there is no simple way. you can play with queries like 'a*', 'b*' and so on",0.0,False,1,6170 +2019-07-04 12:44:56.280,Keras preprocessing for 3D semantic segmentation task,"For semantic image segmentation, I understand that you often have a folder with your images and a folder with the corresponding masks. In my case, I have gray-scale images with the dimensions (32, 32, 32). The masks naturally have the same dimensions. The labels are saved as intensity values (value 1 = label 1, value 2 = label 2 etc.). 4 classes in total. Imagine I have found a model that was built with the keras model API. How do I know how to prepare my label data for it to be accepted by the model? Does it depend on the loss function? Is it defined in the model (Input parameter). Do I just add another dimension (4, 32, 32, 32) in which the 4 represents the 4 different classes and one-hot code it? +I want to build a 3D convolutional neural network for semantic segmentation but I fail to understand how to feed in the data correctly in keras. The predicted output is supposed to be a 4-channel 3D image, each channel showing the probability values of each pixel to belong to a certain class.","The Input() function defines the shape of the input tensor of a given model. For 3D images, often a 5D Tensor is expected, e.g. (None, 32, 32, 32, 1), where None refers to the batch size. Therefore the training images and labels have to be reshaped. Keras offers the to_categorical function to one-hot encode the label data (which is necessary). The use of generators helps to feed in the data. In this case, I cannot use the ImageDataGenerator from keras as it can only deal with RGB and grayscale images and therefore have to write a custom script.",1.2,True,1,6171 +2019-07-04 23:38:40.930,"How to fix ""UnsatisfiableError: The following specifications were found to be incompatible with each other: - pip -> python=3.6""","So, i trying to install with the command ecmwf api client conda install -c conda-forge ecmwf-api-client then the warning in the title shows up. I don't know how to proceede +(base) C:\Users\caina>conda install -c conda-forge ecmwf-api-client +Collecting package metadata (current_repodata.json): done +Solving environment: failed +Collecting package metadata (repodata.json): done +Solving environment: failed +UnsatisfiableError: The following specifications were found to be incompatible with each other: + +pip -> python=3.6","Simply go to Anaconda navigator. +Go to Environments, Select Installed (packages, etc.) and then click the version of Python. Downgrade it to a lower version. In your case Python 3.6",-0.1016881243684853,False,2,6172 +2019-07-04 23:38:40.930,"How to fix ""UnsatisfiableError: The following specifications were found to be incompatible with each other: - pip -> python=3.6""","So, i trying to install with the command ecmwf api client conda install -c conda-forge ecmwf-api-client then the warning in the title shows up. I don't know how to proceede +(base) C:\Users\caina>conda install -c conda-forge ecmwf-api-client +Collecting package metadata (current_repodata.json): done +Solving environment: failed +Collecting package metadata (repodata.json): done +Solving environment: failed +UnsatisfiableError: The following specifications were found to be incompatible with each other: + +pip -> python=3.6","Install into a new environment instead of the conda base environment. Recent Anaconda and Miniconda installers have Python 3.7 in the base environment, but you're trying to install something that requires Python 3.6.",0.3869120172231254,False,2,6172 +2019-07-06 19:03:17.943,how to run my python code on google cloud without fear of getting disconnected - an absolute beginner?,"I have been trying to use python 3 for text mining on a 650 MB csv file, which my computer was not powerful enough to do. My second solution was to reach out to google cloud. I have set up my VMs and my jupyter notebook on google cloud, and it works perfectly well. The problem, however, is that I am in constant fear of getting disconnected. As a matter of fact, my connection with google server was lost a couple of time and so was my whole work. +My question: Is there a way to have the cloud run my code without fear of getting disconnected? I need to be able to have access to my csv file and also the output file. +I know there is more than one way to do this and have read a lot of material. However, they are too technical for a beginner like me to understand. I really appreciate a more dummy-friendly version. Thanks! +UPDATE: here is how I get access to my jupyter notebook on google cloud: +1- I run my instance on google cloud +2- I click on SSH +3- in the window that appears, I type the following: +jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser & +I have seen people recommend to add nohup to the beginning of the same commend. I have tried it and got this message: +nohup: ignoring input and appending output to 'nohup.out' +And nothing happens.","If I understand your problem correctly, you could just run the program inside a screen instance: +After connecting via ssh type screen +Run your command +Press ctrl + a, ctrl + d +Now you can disconnect from ssh and your code will continue to run. You can reconnect to the screen via screen -r",1.2,True,1,6173 +2019-07-08 15:13:46.557,Importing sknw on jupyter ModuleNotFoundError,"On my jupyter notebook, running import sknw throws a ModuleNotFoundError error. +I have tried pip install sknw and pip3 install sknw and python -m pip install sknw. It appears to have downloaded successfully, and get requirement already satisfied if I try to download it again. +Any help on how to get the sknw package to work in jupyter notebook would be very helpful!",check on which environment you using pip.,1.2,True,1,6174 +2019-07-08 16:03:06.770,What is the best approach to scrape a big website?,"Hello I am developing a web scraper and I am using in a particular website, this website has a lot of URLs, maybe more than 1.000.000, and for scraping and getting the information I have the following architecture. +One set to store the visited sites and another set to store the non-visited sites. +For scraping the website I am using multithreading with a limit of 2000 threads. +This architecture has a problem with a memory size and can never finish because the program exceeds the memory with the URLs +Before putting a URL in the set of non-visited, I check first if this site is in visited, if the site was visited then I will never store in the non-visited sites. +For doing this I am using python, I think that maybe a better approach would be storing all sites in a database, but I fear that this can be slow +I can fix part of the problem by storing the set of visited URLs in a database like SQLite, but the problem is that the set of the non-visited URL is too big and exceeds all memory +Any idea about how to improve this, with another tool, language, architecture, etc...? +Thanks","2000 threads is too many. Even 1 may be too many. Your scraper will probably be thought of as a DOS (Denial Of Service) attach and your IP address will be blocked. +Even if you are allowed in, 2000 is too many threads. You will bottleneck somewhere, and that chokepoint will probably lead to going slower than you could if you had some sane threading. Suggest trying 10. One way to look at it -- Each thread will flip-flop between fetching a URL (network intensive) and processing it (cpu intensive). So, 2 times the number of CPUs is another likely limit. +You need a database under the covers. This will let you top and restart the process. More importantly, it will let you fix bugs and release a new crawler without necessarily throwing away all the scraped info. +The database will not be the slow part. The main steps: + +Pick a page to go for (and lock it in the database to avoid redundancy). +Fetch the page (this is perhaps the slowest part) +Parse the page (or this could be the slowest) +Store the results in the database +Repeat until no further pages -- which may be never, since the pages will be changing out from under you. + +(I did this many years ago. I had a tiny 0.5GB machine. I quit after about a million analyzed pages. There were still about a million pages waiting to be scanned. And, yes, I was accused of a DOS attack.)",0.2012947653214861,False,2,6175 +2019-07-08 16:03:06.770,What is the best approach to scrape a big website?,"Hello I am developing a web scraper and I am using in a particular website, this website has a lot of URLs, maybe more than 1.000.000, and for scraping and getting the information I have the following architecture. +One set to store the visited sites and another set to store the non-visited sites. +For scraping the website I am using multithreading with a limit of 2000 threads. +This architecture has a problem with a memory size and can never finish because the program exceeds the memory with the URLs +Before putting a URL in the set of non-visited, I check first if this site is in visited, if the site was visited then I will never store in the non-visited sites. +For doing this I am using python, I think that maybe a better approach would be storing all sites in a database, but I fear that this can be slow +I can fix part of the problem by storing the set of visited URLs in a database like SQLite, but the problem is that the set of the non-visited URL is too big and exceeds all memory +Any idea about how to improve this, with another tool, language, architecture, etc...? +Thanks","At first, i never crawled pages using Python. My preferd language is c#. But python should be good, or better. +Ok, the first thing your detected is quiet important. Just operating on your memory will NOT work. Implementing a way to work on your harddrive is important. If you just want to work on memory, think about the size of the page. +In my opinion, you already got the best(or a good) architecture for webscraping/crawling. You need some kind of list, which represents the urls you already visited and another list in which you could store the new urls your found. Just two lists is the simplest way you could go. Cause that means, you are not implementing some kind of strategy in crawling. If you are not looking for something like that, ok. But think about it, because that could optimize the usage of memory. Therefor you should look for something like deep and wide crawl. Or recursive crawl. Representing each branch as a own list, or a dimension of an array. +Further, what is the problem with storing your not visited urls in a database too? Cause you only need on each thread. If your problem with putting it in db is the fact, that it could need some time swiping through it, then you should think about using multiple tables for each part of the page. +That means, you could use one table for each substring in url: +wwww.example.com/ +wwww.example.com/contact/ +wwww.example.com/download/ +wwww.example.com/content/ +wwww.example.com/support/ +wwww.example.com/news/ +So if your url is:""wwww.example.com/download/sweetcats/"", then you should put it in the table for wwww.example.com/download/. +When you have a set of urls, then you have to look at first for the correct table. Afterwards you can swipe through the table. +And at the end, i have just one question. Why are you not using a library or a framework which already supports these features? I think there should be something available for python.",1.2,True,2,6175 +2019-07-08 17:12:59.247,How to set Referrer in driver selenium python?,"I need to scrape a web page, but the problem is when i click on the link on website, it works fine, but when i go through the link manually by typing url in browser, it gives Access Denied error, so may be they are validating referrer on their end, Can you please tell me how can i sort this issue out using selenium in python ? +or any idea that can solve this issue? i am unable to scrape the page because its giving Access Denied error. +PS. i am working with python3 +Waiting for help. +Thanks","I solved myself by using seleniumwire ;) selenium doesn't support headers, but seleniumwire supports, so that solved my issue. +Thanks",0.0,False,1,6176 +2019-07-08 23:22:52.727,"While query data (web scraping) from a website with Python, how to avoid being blocked by the server?","I was trying to using python requests and mechanize to gather information from a website. This process needs me to post some information then get the results from that website. I automate this process using for loop in Python. However, after ~500 queries, I was told that I am blocked due to high query rate. It takes about 1 sec to do each query. I was using some software online where they query multiple data without problems. Could anyone help me how to avoid this issue? Thanks! +No idea how to solve this. +--- I am looping this process (by auto changing case number) and export data to csv.... +After some queries, I was told that my IP was blocked.","Optimum randomized delay time between requests. +Randomized real user-agents for +each request. +Enabling cookies. +Using a working proxy pool and +selecting a random proxy for each request.",0.0,False,1,6177 +2019-07-09 21:53:09.597,What is the purpose of concrete methods in abstract classes in Python?,"I feel like this subject is touched in some other questions but it doesn't get into Python (3.7) specifically, which is the language I'm most familiar with. +I'm starting to get the hang of abstract classes and how to use them as blueprints for subclasses I'm creating. +What I don't understand though, is the purpose of concrete methods in abstract classes. +If I'm never going to instantiate my parent abstract class, why would a concrete method be needed at all, shouldn't I just stick with abstract methods to guide the creation of my subclasses and explicit the expected behavior? +Thanks.","This question is not Python specific, but general object oriented. +There may be cases in which all your sub-classes need a certain method with a common behavior. It would be tedious to implement the same method in all your sub-classes. If you instead implement the method in the parent class, all your sub-classes inherit this method automatically. Even callers may call the method on your sub-class, although it is implemented in the parent class. This is one of the basic mechanics of class inheritance.",0.3869120172231254,False,1,6178 +2019-07-10 09:24:32.763,Building Kivy Android app with Tensorflow,"Recently, I want to deploy a Deeplearning model (Tensorflow) on mobile (Android/iOS) and I found that Kivy Python is a good choice to write cross-platform apps. (I am not familiar with Java Android) +But I don't know how to integrate Tensorflow libs when building .apk file. +The guide for writing ""buildozer recipe"" is quite complicate for this case. +Is there any solution for this problem without using native Java Android and Tensorflow Lite?","Fortunately found someone facing the same issues as I am but unfortunately I found that Kivy couldn't compile Tensorflow library yet. In other words, not supported, yet. I don't know when will they update the features.",0.0,False,1,6179 +2019-07-10 11:12:13.937,how do I produce unique random numbers as an array in Python?,"I have an array with size (4,4) that can have values 0 and 1, so I can have 65536 different arrays. I need to produce all these arrays without repeating. I use wt_random=np.random.randint(2, size=(65536,4,4)) but I am worried they are not unique. could you please tell me this code is correct or not and what should I do to produce all possible arrays? Thank you.","If you need all possible arrays in random order, consider enumerating them in any arbitrary deterministic order and then shuffling them to randomize the order. If you don't want all arrays in memory, you could write a function to generate the array at a given position in the deterministic list, then shuffle the positions. Note that Fisher-Yates may not even need a dense representation of the list to shuffle... if you keep track of where the already shuffled entries end up you should have enough.",0.0,False,1,6180 +2019-07-10 11:43:17.540,How to add a column of seconds to a column of times in python?,"I have a file contain some columns which the second column is time. Like what I show below. I need to add a column of time which all are in seconds like this: ""2.13266 2.21784 2.20719 2.02499 2.16543"", to the time column in the first file (below). My question is how to add these two time to each other. And maybe in some cases when I add these times, then it goes to next day, and in this case how to change the date in related row. +2014-08-26 19:49:32 0 +2014-08-28 05:43:21 0 +2014-08-30 11:47:54 0 +2014-08-30 03:26:10 0","Probably the easiest way is to read your file into a pandas data-frame and parse each row as a datetime object. Then you create a datetime.timedelta object passing the fractional seconds. +A datetime object + a timedelta handles wrapping around for days quite nicely so this should work without any additional code. Finally, write back your updated dataframe to a file.",0.0,False,2,6181 +2019-07-10 11:43:17.540,How to add a column of seconds to a column of times in python?,"I have a file contain some columns which the second column is time. Like what I show below. I need to add a column of time which all are in seconds like this: ""2.13266 2.21784 2.20719 2.02499 2.16543"", to the time column in the first file (below). My question is how to add these two time to each other. And maybe in some cases when I add these times, then it goes to next day, and in this case how to change the date in related row. +2014-08-26 19:49:32 0 +2014-08-28 05:43:21 0 +2014-08-30 11:47:54 0 +2014-08-30 03:26:10 0","Ok. Finally it is done via this code: + d= 2.13266 +dd= pd.to_timedelta (int(d), unit='s') +df= pd.Timestamp('2014-08-26 19:49:32') +new = df + dd",0.0,False,2,6181 +2019-07-10 15:34:08.677,how to average in a specific dimension with numpy.mean?,"I have a matrix called POS which has form (10,132) and I need to average those first 10 elements in such a way that my averaged matrix has the form of (1,132) +I have tried doing +means = pos.mean (axis = 1) +or +menas = np.mean(pos) +but the result in the first case is a matrix of (10,) and in the second it is a simple number +i expect the ouput a matrix of shape (1,132)","The solution is to specify the correct axis and use keepdims=True which is noted by several commenters (If you add your answer I will delete mine). +This can be done with either pos.mean(axis = 0,keepdims=True) or np.mean(pos,axis=0,keepdims=True)",1.2,True,1,6182 +2019-07-10 20:56:07.317,Delete empty directory from Jupyter notebook error,"I am trying to delete an empty directory in Jupyter notebook. +When I select the folder and click Delete, an error message pops up saying: +'A directory must be empty before being deleted.' +There are no files or folders in the directory and it is empty. +Any advice on how to delete it? +Thank you!","Usually, Jupyter itself creates a hidden .ipynb_checkpoints folder within the directory when you inspect it. You can check its existence (or any other hidden file/folders) in the directory using ls -a in a terminal that has a current working directory as the corresponding folder.",1.2,True,2,6183 +2019-07-10 20:56:07.317,Delete empty directory from Jupyter notebook error,"I am trying to delete an empty directory in Jupyter notebook. +When I select the folder and click Delete, an error message pops up saying: +'A directory must be empty before being deleted.' +There are no files or folders in the directory and it is empty. +Any advice on how to delete it? +Thank you!","Go to your local directory where it stores the workbench files, ex:(C:\Users\prasadsarada) +You can see all the folders you have created in Jupyter Notebook. delete it there.",0.0,False,2,6183 +2019-07-10 21:47:53.280,TCP Socket on Server Side Using Python with select on Windows,"By trying to find an optimization to my server on python, I have stumbled on a concept called select. By trying to find any code possible to use, no matter where I looked, Windows compatibility with this subject is hard to find. +Any ideas how to program a TCP server with select on windows? I know about the idea of unblocking the sockets to maintain the compatibility with it. Any suggestions will be welcomed.","Using select() under Windows is 99% the same as it is under other OS's, with some minor variations. The minor variations (at least the ones I know about) are: + +Under Windows, select() only works for real network sockets. In particular, don't bother trying to select() on stdin under Windows, as it won't work. +Under Windows, if you attempt a non-blocking TCP connection and the TCP connection fails asynchronously, you will get a notification of that failure via the third (""exception"") fd_set only. (Under other OS's you will get notified that the failed-to-connect TCP-socket is ready-for-read/write also) +Under Windows, select() will fail if you don't pass in at least one valid socket to it (so you can't use select([], [], [], timeoutInSeconds) as an alternative to time.sleep() like you can under some other OS's) + +Other than that select() for Windows is like select() for any other OS. (If your real question about how to use select() in general, you can find information about that using a web search)",0.3869120172231254,False,1,6184 +2019-07-11 11:48:58.680,Tensorflow 2.0: Accessing a batch's tensors from a callback,"I'm using Tensorflow 2.0 and trying to write a tf.keras.callbacks.Callback that reads both the inputs and outputs of my model for the batch. +I expected to be able to override on_batch_end and access model.inputs and model.outputs but they are not EagerTensor with a value that I could access. Is there anyway to access the actual tensors values that were involved in a batch? +This has many practical uses such as outputting these tensors to Tensorboard for debugging, or serializing them for other purposes. I am aware that I could just run the whole model again using model.predict but that would force me to run every input twice through the network (and I might also have non-deterministic data generator). Any idea on how to achieve this?","No, there is no way to access the actual values for input and output in a callback. That's not just part of the design goal of callbacks. Callbacks only have access to model, args to fit, the epoch number and some metrics values. As you found, model.input and model.output only points to the symbolic KerasTensors, not actual values. +To do what you want, you could take the input, stack it (maybe with RaggedTensor) with the output you care about, and then make it an extra output of your model. Then implement your functionality as a custom metric that only reads y_pred. Inside your metric, unstack the y_pred to get the input and output, and then visualize / serialize / etc. Metrics +Another way might be to implement a custom Layer that uses py_function to call a function back in python. This will be super slow during serious training but may be enough for use during diagnostic / debugging.",0.3869120172231254,False,1,6185 +2019-07-11 13:34:12.703,Drone control by python,"I am new in drone, can you please explain one thing: +Is it possible to have RC controller programmed by python? +As I understood using telemetry module and DroneKit, it is possible to control the drone using python. +But usually telemetry module supporting drones are custom drones and as I understood telemetry module does not work as good as RC. +So to have cheaper price, can someone suggest me solution about how to control RC drone using python?",You can use tello drones .These drones can be programmed as per your requirement using python .,0.0,False,1,6186 +2019-07-11 17:14:00.880,Is there a way of deleting specific text for the user in Python?,"I am making a program in python and want to clear what the user has enterd, this is because I am using the keyboard function to register input as is is given, but there is still text left over after a keypress is registerd and I don't want this to happen. +I was woundering if there is a module that exists to remove text that is being entered +Any help would be greatly apreciated, and just the name of a module is fine; I can figure out how to use it, just cant find an appropriate module. +EDIT: +Sorry if i did not make my self clear, I dont really want to clear the whole screen, just what the user has typed. So that they don't have to manually back space after their input has been taken.",'sys.stdout.write' is the moduel I was looking for.,0.0,False,1,6187 +2019-07-13 01:06:02.247,Quickest way to insert zeros into numpy array,"I have a numpy array ids = np.array([1,1,1,1,2,2,2,3,4,4]) +and another array of equal length vals = np.array([1,2,3,4,5,6,7,8,9,10]) +Note: the ids array is sorted by ascending order +I would like to insert 4 zeros before the beginning of each new id - i.e. +new array = np.array([0,0,0,0,1,2,3,4,0,0,0,0,5,6,7,0,0,0,0,8,0,0,0,0,9,10]) +Only, way I am able to produce this is by iterating through the array which is very slow - and I am not quite sure how to do this using insert, pad, or expand_dim ...","u can use np.zeros and append it to your existing array like +newid=np.append(np.zeros((4,), dtype=int),ids) +Good Luck!",0.0,False,1,6188 +2019-07-13 23:37:40.520,How can I put my curvilinear coordinate data on a map projection?,"I'm working with NetCDF files from NCAR and I'm trying to plot sea-ice thickness. This variable is on a curvilinear (TLAT,TLON) grid. What is the best way to plot this data on a map projection? Do I need to re-grid it to a regular grid or is there a way to plot it directly? I'm fairly new to Python so any help would be appreciated. Please let me know if you need any more information. Thank you! +I've tried libraries like iris, scipy, and basemap, but I couldn't really get a clear explanation on how to implement them for my case.","I am pretty sure you can already use methods like contour, contourf, pcolormesh from Python's matplotlib without re-gridding the data. The same methods work for Basemap.",1.2,True,1,6189 +2019-07-15 07:29:41.747,how to use natural language generation from a csv file input .which python module we should use.can any one share a sample tutorial?,take a input as a csv file and generate text/sentence using nlg. I have tried with pynlg and markov chain.But nothing worked .What else I can use?,"There are not much python libraries for NLG!!. Try out nlglib a python wrapper around SimpleNLG. For tutorial purposes, you could read Building Natural Language Generation systems by e.reiter.",-0.3869120172231254,False,1,6190 +2019-07-15 10:55:05.307,[How to run code by using cmd from sublime text 3 ],"I am a newbie in Python, and have a problem. When I code Python using Sublime Text 3 and run directly on it, it does not find some Python library which I already imported. I Googled this problem and found out Sublime Text is just a Text Editor. +I already had code in Sublime Text 3 file, how can I run it without this error? +For example: + +'ModuleNotFoundError: No module named 'matplotlib'. + +I think it should be run by cmd but I don't know how.","Depending on what OS you are using this is easy. On Windows you can press win + r, then type cmd. This will open up a command prompt. Then, type in pip install matplotlib. This will make sure that your module is installed. Then, navigate to the folder which your code is located in. You can do this by typing in cd Documents if you first need to get to your documents and then for each subsequent folder. +Then, try typing in python and hitting enter. If a python shell opens up then type quit() and then type python filename.py and it will run. +If no python shell opens up then you need to change your environment variables. Press the windows key and pause break at the same time, then click on Advanced system settings. Then press Environment Variables. Then double click on Path. Then press New. Then locate the installation folder of you Python install, which may be in C:\Users\YOURUSERNAME\AppData\Local\Programs\Python\Python36 Now put in the path and press ok. You should now be able to run python from your command line.",1.2,True,1,6191 +2019-07-15 11:09:48.323,how can I use gpiozero robot library to change speeds of motors via L298N,"In my raspberry pi, i need to run two motors with a L298N. +I can pwm on enable pins to change speeds. But i saw that gpiozero robot library can make things a lot easier. But +When using gpiozero robot library, how can i alter speeds of those motors by giving signel to the enable pins.","I have exactly the same situation. You can of course program the motors separately but it is nice to use the robot class. +Looking into the gpiocode for this, I find that in our case the left and right tuples have a third parameter which is the pin for PWM motor speed control. (GPIO Pins 12 13 18 19 have hardware PWM support). The first two outout pins in the tuple are to be signalled as 1, 0 for forward, 0,1 for back. +So here is my line of code: + Initio = Robot(left=(4, 5, 12), right=(17, 18, 13)) +Hope it works for you! +I have some interesting code on the stocks for controlling the robot's absolute position, so it can explore its environment.",0.2012947653214861,False,1,6192 +2019-07-15 20:45:58.190,Does Kivy have laserjet printer support?,"Is there a way to print a Page/Widget/Label in Kivy? (or some other way in python). +Unfortunately, I don't know how to ask the question correctly since I am new to software development. +I want to build a price tracking app for my business in which i will have to print some stuff.","Not directly, no, but the printing part isn't really Kivy's responsibility - probably you can find another Python module to handle this. +In terms of what is printed, you can export an image of any part of the Kivy gui and print that.",0.6730655149877884,False,1,6193 +2019-07-16 11:12:04.277,How to access python dictionary from C?,"I have a dictionary in python and I need to access that dictionary from a C program? +or for example, convert this dictionary into struct map in C +I don't have any idea how this could be done. +I will be happy to get some hints regarding that or if there are any libraries that could help. +Update: +the dictionary is generated from the abstract syntax tree of C program by using pycparser. +so, I wrote a python function to generate this dictionary and I can dump it using pickle or save it as a text file. +Now I want to use keys and their values from a c program and I don't know how to access that dictionary.",You could export the dictionary to a JSON and parse the JSON file from C...,0.3869120172231254,False,1,6194 +2019-07-16 12:46:43.023,Flask non-template HTML files included by Jinja,"In my Flask application, I have one html file that holds some html and some js that semantically belongs together and cannot be used separately in a sensible way. I include this file in 2 of my html templates by using Jinja's {%include ... %}. +Now my first approach was to put this file in my templates folder. However, I never call render_template on this file, so it seems unapt to store it in that directory. +Another approach would be to put it into the static folder, since its content is indeed static. But then I don't know how to tell Jinja to look for it in a different directory, since all the files using Jinja are in the templates folder. +Is there a way to accomplish this with Jinja, or is there a better approach altogether?","You're over-thinking this. If it's included by Jinja, then it's a template file and belongs in the templates directory.",1.2,True,1,6195 +2019-07-16 13:11:16.803,"Keras, Tensorflow are reserving all GPU memory on model build","my GPU is NVIDIA RTX 2080 TI +Keras 2.2.4 +Tensorflow-gpu 1.12.0 +CUDA 10.0 +Once I load build a model ( before compilation ), I found that GPU memory is fully allocated +[0] GeForce RTX 2080 Ti | 50'C, 15 % | 10759 / 10989 MB | issd/8067(10749M) +What could be the reason, how can i debug it? +I don't have spare memory to load the data even if I load via generators +I have tried to monitor the GPUs memory usage found out it is full just after building the layers (before compiling model)","I meet a similar problem when I load pre-trained ResNet50. The GPU memory usage just surges to 11GB while ResNet50 usually only consumes less than 150MB. +The problem in my case is that I also import PyTorch without actually used it in my code. After commented it, everything works fine. +But I have another PC with the same code that works just fine. So I uninstall and reinstall the Tensorflow and PyTorch with the correct version. Then everything works fine even if I import PyTorch.",0.0,False,1,6196 +2019-07-16 13:41:47.907,how is every object related to pyObject when c does not have Inheritance,"I have been going through source code of python. It looks like every object is derived from PyObject. But, in C, there is no concept of object oriented programming. So, how exactly is this implemented without inheritance?","What makes the Object Oriented programming paradigm is the relation between ""classes"" as templates for a data set and functions that will operate on this data set. And, the inheritance mechanism which is a relation from a class to ancestor classes. +These relations, however, do not depend on a particular language Syntax - just that they are present in anyway. +So, nothing stops one from doing ""object orientation"" in C, and in fact, organized libraries, even without an OO framework, end up with an organization related to OO. +It happens that the Python object system is entirely defined in pure C, with objects having a __class__ slot that points to its class with a C pointer - only when ""viwed"" from Python the full represenation of the class is resented. Classes in their turn having a __mro__ and __bases__ slots that point to the different arrangements of superclasses (the pointers this time are for containers that will be seen from Python as sequences). +So, when coding in C using the definitions and API of the Python runtime, one can use OOP just in the same way as coding in Python - and in fact use Python objects that are interoperable with the Python language. (The cython project will even transpile a superset of the Python language to C and provide transparent ways f writing native code with Python syntax) +There are other frameworks available to C that provide different OOP systems, that are equaly conformant, for example, glib - which defines ""gobject"" and is the base for all GTK+ and GNOME applications.",0.3869120172231254,False,1,6197 +2019-07-16 15:52:02.673,How can I verify if there is an incoming message to my node with MPI?,"I'm doing a project using Python with MPI. Every node of my project needs to know if there is any incoming message for it before continuing the execution of other tasks. +I'm working on a system where multiple nodes executes some operations. Some nodes may need the outputs of another nodes and therefore needs to know if this output is available. +For illustration purposes, let's consider two nodes, A and B. A needs the output of B to execute it's task, but if the output is not available A needs to do some other tasks and then verify if B has send it's output again, in a loop. What I want to do is this verification of availability of output from B in A. +I made some research and found something about a method called probe, but don't understood neither found a usefull documentation about what it does or how to use. So, I don't know if it solves my problem. +The idea of what I want is ver simple: I just need to check if there is data to be received when I use the method ""recv"" of mpi4py. If there is something the code do some tasks, if there ins't the code do some other taks.","(elaborating on Gilles Gouaillardet's comment) +If you know you will eventually receive a message, but want to be able to run some computations while it is being prepared and sent, you want to use non-blocking receives, not probe. +Basically use MPI_Irecv to setup a receive request as soon as possible. If you want to know whether the message is ready yet, use MPI_Test to check the request. +This is much better than using probes, because you ensure that a receive buffer is ready as early as possible and the sender is not blocked, waiting for the receiver to see that there is a message and post the receive. +For the specific implementation you will have to consult the manual of the Python MPI wrapper you use. You might also find helpful information in the MPI standard itself.",1.2,True,1,6198 +2019-07-17 14:40:06.277,Getting the Raw Data Out of an Excel Pivot Table in Python,"I have a pivot table in excel that I want to read the raw data from that table into python. Is it possible to do this? I do not see anything in the documentation on it or on Stack Overflow. +If the community could be provided some examples on how to read the raw data that drives pivot tables, this could greatly assist in routine analytical tasks. +EDIT: +In this scenario there are no raw data tabs. I want to know how to ping the pivot table get the raw data and read it into python.","First, recreate raw data from the pivot table. The pivot table has full information to rebuild the raw data. + +Make sure that none of the items in the pivot table fields are hidden -- clear all the filters and Slicers that have been applied. +The pivot table does not need to contain all the fields -- just make sure that there is at least one field in the Values area. +Show the grand totals for rows and columns. If the totals aren't visible, select a cell in the pivot table, and on the Ribbon, under PivotTable Tools, click the Analyze tab. In the Layout group, click Grand totals, then click On for Rows and Columns. +Double-click the grand total cell at the bottom right of the pivot table. This should create a new sheet with the related records from the original source data. + +Then, you could read the raw data from the source.",0.0,False,1,6199 +2019-07-18 11:24:22.350,how to add custom Keras model in OpenCv in python,"i have created a model for classification of two types of shoes +now how to deploy it in OpenCv (videoObject detection)?? +thanks in advance","You would save the model to H5 file model.save(""modelname.h5"") , then load it in OpenCV code load_model(""modelname.h5""). Then in a loop detect the objects you find via model.predict(ImageROI)",0.0,False,1,6200 +2019-07-18 17:58:17.687,How to remove a virtualenv which is created by PyCharm?,"Since I have selected my project's interpreter as Pipenv during project creation, PyCharm has automatically created the virtualenv. Now, when I try to remove the virtualenv via pipenv --rm, I get the error You are attempting to remove a virtualenv that Pipenv did not create. Aborting. So, how can I properly remove this virtualenv?","the command ""pipenv"" actually comes from the virtualenv,he can't remove himself.you should close the project and remove it without activated virtualenv",0.9950547536867304,False,1,6201 +2019-07-18 22:58:53.810,How to deal with infrequent data in a time series prediction model,"I am trying to create a basic model for stock price prediction and some of the features I want to include come from the companies quarterly earnings report (every 3 months) so for example; if my data features are Date, OpenPrice, Close Price, Volume, LastQrtrRevenue how do I include LastQrtrRevenue if I only have a value for it every 3 months? Do I leave the other days blank (or null) or should I just include a constant of the LastQrtrRevenue and just update it on the day the new figures are released? Please if anyone has any feedback on dealing with data that is released infrequently but is important to include please share.... Thank you in advance.","I would be tempted to put the last quarter revenue in a separate table, with a date field representing when that quarter began (or ended, it doesn't really matter). Then you can write queries to work the way that most suits your application. You could certainly reconstitute the view you mention above using that table, as long as you can relate it to the main table. +You would just need to join the main table by company name, while selected the max() of the last quarter revenue table.",0.3869120172231254,False,1,6202 +2019-07-19 11:26:59.093,Compare list items in pythonic way,"For a list say l = [1, 2, 3, 4] how do I compare l[0] < l[1] < l[2] < l[3] in pythonic way?",Another way would be to use the .sort() method in which case you'd have to return a new list altogether.,0.0,False,1,6203 +2019-07-19 18:13:40.823,How does log in spark stage/tasks help in understanding actual spark transformation it corresponds to,"Often during debugging Spark Jobs on failure we can find the appropriate Stage and task responsible for the failure such as String Index Out of Bounds exception but it becomes difficult to understand which transformation is responsible for this failure.The UI shows information such as Exchange/HashAggregate/Aggregate but finding the actual transformation responsible for this failure becomes really difficult in 500+ lines of code, so how should it be possible to debug Spark task failures and tracing the transformation responsible for the same?","Break your execution down. It's the easiest way to understand where the error might be coming from. Running a 500+ line of code for the first time is never a good idea. You want to have the intermediate results while you are working with it. Another way is to use an IDE and walk through the code. This can help you understand where the error originated from. I prefer PyCharm (Community Edition is free), but VS Code might be a good alternative too.",0.0,False,1,6204 +2019-07-20 16:40:06.663,How to host a Python script on the cloud?,"I wrote a Python script which scrapes a website and sends emails if a certain condition is met. It repeats itself every day in a loop. +I converted the Python file to an EXE and it runs as an application on my computer. But I don't think this is the best solution to my needs since my computer isn't always on and connected to the internet. +Is there a specific website I can host my Python code on which will allow it to always run? +More generally, I am trying to get the bigger picture of how this works. What do you actually have to do to have a Python script running on the cloud? Do you just upload it? What steps do you have to undertake? +Thanks in advance!","well i think one of the best option is pythonanywhere.com there you can upload your python script(script.py) and then run it and then finish. +i did this with my telegram bot",0.3869120172231254,False,2,6205 +2019-07-20 16:40:06.663,How to host a Python script on the cloud?,"I wrote a Python script which scrapes a website and sends emails if a certain condition is met. It repeats itself every day in a loop. +I converted the Python file to an EXE and it runs as an application on my computer. But I don't think this is the best solution to my needs since my computer isn't always on and connected to the internet. +Is there a specific website I can host my Python code on which will allow it to always run? +More generally, I am trying to get the bigger picture of how this works. What do you actually have to do to have a Python script running on the cloud? Do you just upload it? What steps do you have to undertake? +Thanks in advance!",You can deploy your application using AWS Beanstalk. It will provide you with the whole python environment along with server configuration likely to be changed according to your needs. Its a PAAS offering from AWS cloud.,0.2655860252697744,False,2,6205 +2019-07-20 19:16:43.307,Using Python Libraries or Codes in My Java Application,"I'm trying to build an OCR desktop application using Java and, to do this, I have to use libraries and functions that were created using the Python programming language, so I want to figure out: how can I use those libraries inside my Java application? +I have already seen Jython, but it is only useful for cases when you want to run Java code in Python; what I want is the other way around (using Python code in Java applications).","I have worked in projects where Python was used for ML (machine learning) tasks and everything else was written in Java. +We separated the execution environments entirely. Instead of mixing Python and Java in some esoteric way, you create independent services (one for Python, one for Java), and then handle inter-process communication via HTTP or messaging or some other mechanism. ""Mircoservices"" if you will.",1.2,True,1,6206 +2019-07-21 23:11:36.943,Spotfire - Dynamically creating buttons using,"Hello I am creating a spotfire dashboard which I would like to be reusable for each year. +Currently my layout is designed as a page with 8 buttons containing the names of stores, if clicked on, spotfire applies a filter so that only informations relating to that store shows. (these were individually created manually) +Is there a way to automate this with JS or Iron Python, so that for each store a button is automatically created, and in action control for each button is to apply that stores filter? +I have looked around but cannot find anything relating to dynamically creating buttons. Not asking for you to code this for me, but if someone can point me towards some resources or general logic on how this could be done it would be much appreciated.","Why not just putting a textarea on your page? Inside this textarea, you add a filter control that filters data the way you want ;) +With this you don't have problem with elements to create dynamically, because it's impossible to create spotfirecontrols dynamically.",0.1352210990936997,False,3,6207 +2019-07-21 23:11:36.943,Spotfire - Dynamically creating buttons using,"Hello I am creating a spotfire dashboard which I would like to be reusable for each year. +Currently my layout is designed as a page with 8 buttons containing the names of stores, if clicked on, spotfire applies a filter so that only informations relating to that store shows. (these were individually created manually) +Is there a way to automate this with JS or Iron Python, so that for each store a button is automatically created, and in action control for each button is to apply that stores filter? +I have looked around but cannot find anything relating to dynamically creating buttons. Not asking for you to code this for me, but if someone can point me towards some resources or general logic on how this could be done it would be much appreciated.","Think txemsukr is right. This is not possible. To do it with JS or IP, the API would have to exist. Several of the elements you mentioned (action controls), you can't control with the API.",0.1352210990936997,False,3,6207 +2019-07-21 23:11:36.943,Spotfire - Dynamically creating buttons using,"Hello I am creating a spotfire dashboard which I would like to be reusable for each year. +Currently my layout is designed as a page with 8 buttons containing the names of stores, if clicked on, spotfire applies a filter so that only informations relating to that store shows. (these were individually created manually) +Is there a way to automate this with JS or Iron Python, so that for each store a button is automatically created, and in action control for each button is to apply that stores filter? +I have looked around but cannot find anything relating to dynamically creating buttons. Not asking for you to code this for me, but if someone can point me towards some resources or general logic on how this could be done it would be much appreciated.","instead of buttons, why not a dropdown populated by the unique values in the ""store names"" column to set a document property, and have your data listing limit the data to [store_name] = ${store_name}",0.2655860252697744,False,3,6207 +2019-07-22 05:27:22.927,Can I use GCP for training only but predict with my own AI machine?,"My laptop had a problem with training big a dataset but not for predicting. Can I use Google Cloud Platform for training, only then export and download some sort of weights or model of that machine learning, so I can use it on my own laptop, and if so how to do it?","Decide if you want to use Tensorflow or Keras etc. Prepare scripts to train and save model, and another script to use it for prediction. +It should be simple enough to use GCP for training and download the model to use on your machine. You can choose to use a high end machine (lot of memory, cores, GPU) on GCP. Training in distributed mode may be more complex. Then download the model and use it on local machine. +If you run into issues, post your scripts and ask another question.",0.0,False,1,6208 +2019-07-23 06:15:00.117,Define dynamic environment path variables for different system configuration,"I'm not sure if this is a valid question, but I'm stuck doing this. +I've a python script which does some operation on my local system +Users/12345/Desktop/Sample/one.py +I want the same to be run on remote server whose path is +Server/Users/23552/Dir/ASR/Desktop/Sample/one.py +I know how to do this in PHP using define path APP_HOME sort of I'm baffled in Python +Can someone pl help me?","You can always use the relative path, I guess relative path should solve your issue.",0.0,False,1,6209 +2019-07-23 06:31:38.687,how to get best fit line when we have data on vertical line?,"I started learning Linear Regression and I was solving this problem. When i draw scatter plot between independent variable and dependent variable, i get vertical lines. I have 0.5M sample data. X-axis data is given within range of let say 0-20. In this case I am getting multiple target value for same x-axis point hence it draws vertical line. +My question is, Is there any way i can transform the data in such a way that it doesn't perform vertical line and i can get my model working. There are 5-6 such independent variable that draw the same pattern. +Thanks in advance.","Instead of fitting y as a function of x, in this case you should fit x as a function of y.",0.0,False,1,6210 +2019-07-23 23:56:46.253,How to best(most efficiently) read the first sheet in Excel file into Pandas Dataframe?,"Loading the excel file using read_excel takes quite long. Each Excel file has several sheets. The first sheet is pretty small and is the sheet I'm interested in but the other sheets are quite large and have graphs in them. Generally this wouldn't be a problem if it was one file, but I need to do this for potentially thousands of files and pick and combine the necessary data together to analyze. If somebody knows a way to efficiently load in the file directly or somehow quickly make a copy of the Excel data as text that would be helpful!","The method read_excel() reads the data into a Pandas Data Frame, where the first parameter is the filename and the second parameter is the sheet. +df = pd.read_excel('File.xlsx', sheetname='Sheet1')",-0.2012947653214861,False,1,6211 +2019-07-24 04:43:32.027,How can I combine 2 pivot ( Sale and Pos Order ) into 1 pivot view on my new module?,"I have a problem because I'm new guy in Odoo 11, my task is combine 2 pivot ( Sales and Pos Order ) into 1 pivot view of new Module that i create. So how can i do this? step by step, because I'm just new guy. Please help me, thanks in advance","You Can use select queries for both the models and there is no need for same field or relation you can just use Union All.For Example +select pos_order as po +LEFT JOIN pos_order_line pol ON(pol.order_id = po.id) +UNION ALL +select sale_order so +LEFT JOIN sale_order_line sol ON(sol.order_id = so.id) +Hope this will help you in this regard and don't forget to define the fields you want to show on the pivot view.",0.0,False,1,6212 +2019-07-24 09:38:40.803,What is the difference between the _tkinter and tkinter modules?,I am also trying to understand how to use Tkinter so could you please explain the basics?,"What is the difference between the _tkinter and tkinter modules? + +_tkinter is a C-based module that exposes an embedded tcl/tk interpreter. When you import it, and only it, you get access to this interpreter but you do not get access to any of the tkinter classes. This module is not designed to be imported by python scripts. +tkinter provides python-based classes that use the embedded tcl/tk interpreter. This is the module that defines Tk, Button, Text, etc.",0.3869120172231254,False,1,6213 +2019-07-24 13:11:20.187,How to send a query or stored procedure execution request to a specific location/region of cosmosdb?,"I'm trying to multi-thread some tasks using cosmosdb to optimize ETL time, and I can't find how, using the python API (but I could do something in REST if required) if I have a stored procedure to call twice for two partitions keys, I could send it to two different regions (namely 'West Europe' and 'Central France) +I defined those as PreferredLocations in the connection policy but don't know how to include to a query, the instruction to route it to a specific location.","The only place you could specify that on would be the options objects of the requests. However there is nothing related to the regions. +What you can do is initialize multiple clients that have a different order in the preferred locations and then spread the load that way in different regions. +However, unless your apps are deployed on those different regions and latency is less, there is no point in doing so since Cosmos DB will be able to cope with all the requests in a single region as long as you have the RUs needed.",1.2,True,1,6214 +2019-07-25 19:40:43.613,Is it possible to start using Django's migration system after years of not using it?,"A project I recently joined, for various reasons, decided not to use Django migration system and uses our own system (which is similar enough to Django's that we could possibly automate translations) +Primary Question +Is it possible to start using Django's migration system now? +More Granular Question(s) +Ideally, we'd like to find some way of saying ""all our tables and models are in-sync (i.e. there is no need to create and apply any migrations), Django does not need to produce any migrations for any existing model, only for changes we make. + + +Is it possible to do this? + +Is it simply a case of ""create the django migration table, generate migrations (necessary?), and manually update the migration table to say that they've all been ran""? + +Where can I find more information for how to go about doing this? Are there any examples of people doing this in the past? + + +Regarding SO Question Rules +I didn't stop to think for very long about whether or not this is an ""acceptable"" question to ask on SO. I assume that it isn't due to the nature of the question not having a clear, objective set of criteria for a correct answer. however, I think that this problem is surely common enough, that it could provide an extremely valuable resource for anyone in my shoes in the future. Please consider this before voting to remove.","I think you should probably be able to do manage.py makemigrations (you might need to use each app name the first time) which will create the migrations files. You should then be able to do manage.py migrate --fake which will mimic the migration run without actually impacting your tables. +From then on (for future changes), you would run makemigrations and migrate as normal.",0.3869120172231254,False,1,6215 +2019-07-25 19:50:15.017,Peewee incrementing an integer field without the use of primary key during migration,"I have a table I need to add columns to it, one of them is a column that dictates business logic. So think of it as a ""priority"" column, and it has to be unique and a integer field. It cannot be the primary key but it is unique for business logic purposes. +I've searched the docs but I can't find a way to add the column and add default (say starting from 1) values and auto increment them without setting this as a primarykey.. +Thus creating the field like + +example_column = IntegerField(null=False, db_column='PriorityQueue',default=1) + +This will fail because of the unique constraint. I should also mention this is happening when I'm migrating the table (existing data will all receive a value of '1') +So, is it possible to do the above somehow and get the column to auto increment?","It should definitely be possible, especially outside of peewee. You can definitely make a counter that starts at 1 and increments to the stop and at the interval of your choice with range(). You can then write each incremented variable to the desired field in each row as you iterate through.",1.2,True,2,6216 +2019-07-25 19:50:15.017,Peewee incrementing an integer field without the use of primary key during migration,"I have a table I need to add columns to it, one of them is a column that dictates business logic. So think of it as a ""priority"" column, and it has to be unique and a integer field. It cannot be the primary key but it is unique for business logic purposes. +I've searched the docs but I can't find a way to add the column and add default (say starting from 1) values and auto increment them without setting this as a primarykey.. +Thus creating the field like + +example_column = IntegerField(null=False, db_column='PriorityQueue',default=1) + +This will fail because of the unique constraint. I should also mention this is happening when I'm migrating the table (existing data will all receive a value of '1') +So, is it possible to do the above somehow and get the column to auto increment?","Depends on your database, but postgres uses sequences to handle this kind of thing. Peewee fields accept a sequence name as an initialization parameter, so you could pass it in that manner.",0.0,False,2,6216 +2019-07-26 08:32:45.950,How to check if a url is valid in Scrapy?,"I have a list of url and many of them are invalid. When I use scrapy to crawl, the engine will automatically filter those urls with 404 status code, but some urls' status code aren't 404 and will be crawled so when I open it, it says something like there's nothing here or the domain has been changed, etc. Can someone let me know how to filter these types of invalid urls?","In your callback (e.g. parse) implement checks that detect those cases of 200 responses that are not valid, and exit the callback right away (return) when you detect one of those requests.",0.0,False,1,6217 +2019-07-27 18:25:21.400,Unable to view django error pages on Google Cloud web app,"Settings.py DEBUG=True +But the django web application shows Server Error 500. +I need to see the error pages to debug what is wrong on the production server. +The web application works fine in development server offline. +The google logs does not show detail errors. Only shows the http code of the request.","Thank you all for replying to my question. The project had prod.py (production settings file, DEBUG=False) and a dev.py (development settings file). When python manage.py is called it directly calls dev.py(DEBUG=True). However, when I push to google app engine main.py is used to specify how to run the application. main.py calls wsgi.py which calls prod.pd (DEBUG=False). This is why the django error pages were not showing. I really appreciate you all. VictorTorres, Mahirq9 and ParthS007",0.0,False,1,6218 +2019-07-28 11:14:17.907,How to turn the image in the correct orientation?,"I have a paper on which there are scans of documents, I use tesseract to recognize the text, but sometimes the images are in the wrong orientation, then I cut these documents from the sheet and work with each one individually, but I need to turn them in the correct position, how to do it?","I’m not sure if there are simple ways, but you can rotate the document after you do not find adequate characters in it, if you see letters, then the document is in the correct orientation. +As I understand it, you use a parser, so the check can be very simple, if there are less than 5 keys, then the document is turned upside down incorrectly",1.2,True,2,6219 +2019-07-28 11:14:17.907,How to turn the image in the correct orientation?,"I have a paper on which there are scans of documents, I use tesseract to recognize the text, but sometimes the images are in the wrong orientation, then I cut these documents from the sheet and work with each one individually, but I need to turn them in the correct position, how to do it?","If all scans are in same orientation on the paper, then you can always try rotating it in reverse if tesseract is causing the problem in reading. If individual scans can be in arbitrary orientation, then you will have to use the same method on individual scans instead.",0.2012947653214861,False,2,6219 +2019-07-29 14:50:34.170,Tensorflow Serving number of requests in queue,"I have my own TensorFlow serving server for multiple neural networks. Now I want to estimate the load on it. Does somebody know how to get the current number of requests in a queue in TensorFlow serving? I tried using Prometheus, but there is no such option.","Actually ,the tf serving doesn't have requests queue , which means that the tf serving would't rank the requests, if there are too many requests. +The only thing that tf serving would do is allocating a threads pool, when the server is initialized. +when a request coming , the tf serving will use a unused thread to deal with the request , if there are no free threads, the tf serving will return a unavailable error.and the client shoule retry again later. +you can find the these information in the comments of tensorflow_serving/batching/streaming_batch_schedulor.h",1.2,True,2,6220 +2019-07-29 14:50:34.170,Tensorflow Serving number of requests in queue,"I have my own TensorFlow serving server for multiple neural networks. Now I want to estimate the load on it. Does somebody know how to get the current number of requests in a queue in TensorFlow serving? I tried using Prometheus, but there is no such option.","what 's more ,you can assign the number of threads by the --rest_api_num_threads or let it empty and automatically configured by tf serivng",0.0,False,2,6220 +2019-07-31 10:20:06.377,speed up pandas search for a certain value not in the whole df,"I have a large pandas DataFrame consisting of some 100k rows and ~100 columns with different dtypes and arbitrary content. +I need to assert that it does not contain a certain value, let's say -1. +Using assert( not (any(test1.isin([-1]).sum()>0))) results in processing time of some seconds. +Any idea how to speed it up?","Just to make a full answer out of my comment: +With -1 not in test1.values you can check if -1 is in your DataFrame. +Regarding the performance, this still needs to check every single value, which is in your case +10^5*10^2 = 10^7. +You only save with this the performance cost for summation and an additional comparison of these results.",1.2,True,1,6221 +2019-07-31 13:05:46.203,Is it possible to write a Python web scraper that plays an mp3 whenever an element's text changes?,"Trying to figure out how to make python play mp3s whenever a tag's text changes on an Online Fantasy Draft Board (ClickyDraft). +I know how to scrape elements from a website with python & beautiful soup, and how to play mp3s. But how do you think can I have it detect when a certain element changes so it can play the appropriate mp3? +I was thinking of having the program scrape the site every 0.5seconds to detect the changes, +but I read that that could cause problems? Is there any way of doing this?","The only way is too scrape the site on a regular basis. 0.5s is too fast. I don't know how time sensitive this project is. But scraping every 1/5/10 minute is good enough. If you need it quicker, just get a proxy (plenty of free ones out there) and you can scrape the site more often. +Just try respecting the site, Don't consume too much of the sites ressources by requesting every 0.5 seconds",1.2,True,1,6222 +2019-07-31 15:27:06.880,How to point Django app to new DB without dropping the previous DB?,"I am working on Django app on branch A with appdb database in settings file. Now I need to work on another branch(B) which has some new DB changes(eg. new columns, etc). The easiest for me is to point branch B to a different DB by changing the settings.py and then apply the migrations. I did the migrations but I am getting error like 1146, Table 'appdb_b.django_site' doesn't exist. So how can I use a different DB for my branchB code without dropping database appdb?","The existing migration files have information that causes the migrate command to believe that the tables should exist and so it complains about them not existing. +You need to MOVE the migration files out of the migrations directory (everything except init.py) and then do a makemigrations and then migrate.",0.3869120172231254,False,1,6223 +2019-08-01 09:16:33.917,Stop music from playing in headless browser,"I was learning how to play music using selenium so I wrote a program which would be used as a module to play music. Unfortunately I exited the python shell without exiting the headless browser and now the song is continuously playing. +Could someone tell me how I can find the current headless browser and exit it?","If you are on a Linux box, You can easily find the process Id with ps aux| grep chrome command and Kill it. If you are on Windows kill the process via Task Manager",0.2012947653214861,False,2,6224 +2019-08-01 09:16:33.917,Stop music from playing in headless browser,"I was learning how to play music using selenium so I wrote a program which would be used as a module to play music. Unfortunately I exited the python shell without exiting the headless browser and now the song is continuously playing. +Could someone tell me how I can find the current headless browser and exit it?",You need to include in your script to stop the music before closing the session of your headless browser.,0.2012947653214861,False,2,6224 +2019-08-01 13:21:36.583,How to install a new python module on VSCode?,"I'm trying to install new python modules on my computer and I know how to install through the terminal, but I wish to know if there is a way to install a new module directly through VSCode (like it is possible on PyCharm)? +I already installed through the terminal, it isn't a problem, but I want to install without be obligate to open the terminal when I'm working on VSCode.","Unfortunately! for now, only possible way is terminal.",0.2655860252697744,False,1,6225 +2019-08-01 19:24:54.457,feeding annotations as ground truth along with the images to the model,"I am working on an object detection model. I have annotated images whose values are stored in a data frame with columns (filename,x,y,w,h, class). I have my images inside /drive/mydrive/images/ directory. I have saved the data frame into a CSV file in the same directory. So, now I have annotations in a CSV file and images in the images/ directory. +I want to feed this CSV file as the ground truth along with the image so that when the bounding boxes are recognized by the model and it learns contents of the bounding box. +How do I feed this CSV file with the images to the model so that I can train my model to detect and later on use the same to predict bounding boxes of similar images? +I have no idea how to proceed. +I do not get an error. I just want to know how to feed the images with bounding boxes so that the network can learn those bounding boxes.","We need to feed the bounding boxes to the loss function. We need to design a custom loss function, preprocess the bounding boxes and feed it back during back propagation.",0.0,False,1,6226 +2019-08-02 14:20:48.933,Detecting which words are the same between two pieces of text,"I need some python advice to implement an algorithm. +What I need is to detect which words from text 1 are in text 2: + +Text 1: ""Mary had a dog. The dog's name was Ethan. He used to run down + the meadow, enjoying the flower's scent."" +Text 2: ""Mary had a cat. The cat's name was Coco. He used to run down + the street, enjoying the blue sky."" + +I'm thinking I could use some pandas datatype to check repetitions, but I'm not sure. +Any ideas on how to implement this would be very helpful. Thank you very much in advance.","Since you do not show any work of your own, I'll just give an overall algorithm. +First, split each text into its words. This can be done in several ways. You could remove any punctuation then split on spaces. You need to decide if an apostrophe as in dog's is part of the word--you probably want to leave apostrophes in. But remove periods, commas, and so forth. +Second, place the words for each text into a set. +Third, use the built-in set operations to find which words are in both sets. +This will answer your actual question. If you want a different question that involves the counts or positions of the words, you should make that clear.",0.0,False,2,6227 +2019-08-02 14:20:48.933,Detecting which words are the same between two pieces of text,"I need some python advice to implement an algorithm. +What I need is to detect which words from text 1 are in text 2: + +Text 1: ""Mary had a dog. The dog's name was Ethan. He used to run down + the meadow, enjoying the flower's scent."" +Text 2: ""Mary had a cat. The cat's name was Coco. He used to run down + the street, enjoying the blue sky."" + +I'm thinking I could use some pandas datatype to check repetitions, but I'm not sure. +Any ideas on how to implement this would be very helpful. Thank you very much in advance.","You can use dictionary to first store words from first text and than just simply look up while iterating the second text. But this will take space. +So best way is to use regular expressions.",0.0,False,2,6227 +2019-08-03 16:17:51.303,I can not get pigments highlighting for Python to work in my Sphinx documentation,I've tried adding highlight_language and pygments_style in the config.py and also tried various ways I found online inside the .rst file. Can anyone offer any advice on how to get the syntax highlighting working?,"Sorry, it turns out that program arguments aren't highlighted (the test I was using)",0.0,False,1,6228 +2019-08-04 03:43:05.637,Install & run an extra APK file with Kivy,I am currently developing mobile applications in Kivy. I would like to create an app to aid in the development process. This app would download an APK file from a network location and install/run it. I know how to download files of course. How can I programmatically install and run an Android APK file in Kivy/Android/Python3?,"Look up how you would do it in Java, then you should be able to do it from Kivy using Pyjnius.",0.0,False,1,6229 +2019-08-04 09:57:01.713,Java code to convert between UTF8 and UTF16 offsets (Java string offsets to/from Python 3 string offsets),"Given a Java string and an offset into that String, what is the correct way of calculating the offset of that same location into an UTF8 string? +More specifically, given the offset of a valid codepoint in the Java string, how can one map that offset to a new offset of that codepoint in a Python 3 string? And vice versa? +Is there any library method which already provides the mapping between Java String offsets and Python 3 string offsets?","No, there cannot be. UTF-16 uses a varying number of code units per codepoint and so does UTF-8. So, the indices are entirely dependent on the codepoints in the string. You have to scan the string and count. +There are relationships between the encodings, though. A codepoint has two UTF-16 code units if and only if it has four UTF-8 code units. So, an algorithm could tally UTF-8 code units by scanning UTF-16 codepoints: 4 four a high surrogate, 0 for a low surrogate, 3 for some range, 2 for another and 1 for another.",0.0,False,1,6230 +2019-08-04 13:24:08.390,Why converting dictionaries to lists only returns keys?,"I am wondering why when I use list(dictionary) it only returns keys and not their definitions into a list? +For example, I import a glossary with terms and definitions into a dictionary using CSV reader, then use the built in list() function to convert the dictionary to a list, and it only returns keys in the list. +It's not really an issue as it actually allows my program to work well, was just wondering is that just how it is supposed to behave or? +Many thanks for any help.","In short: In essence it works that way, because it was designed that way. It makes however sense if we take into account that x in some_dict performs a membercheck on the dictionary keys. + +Frequently Python code iterates over a collection, and does not know the type of the collection it iterates over: it can be a list, tuple, set, dictionary, range object, etc. +The question is, do we see a dictionary as a collection, and if yes, a collection of what? If we want to make it collection, there are basically three logical answers to the second question: we can see it as a collection of the keys, of the values, or key-value pairs. Especially keys and key-value pairs are popular. C# for example sees a dictionary as a collection of KeyValuePairs. Python provides the .values() and .items() method to iterate over the values and key-value pairs. +Dictionaries are mainly designed to perform a fast lookup for a key and retrieve the corresponding value. Therefore the some_key in some_dict would be a sensical query, or (some_key, some_value) in some_dict, since the latter chould check if the key is in the dictionary, and then check if it matches with some_value. The latter is however less flexible, since often we might not want to be interested in the corresponding value, we simply want to check if the dictionary contains a certain key. We furthermore can not support both use cases concurrently, since if the dictionary would for example contain 2-tuples as keys, then that means it is ambiguous if (1, 2) in some_dict would mean that for key 1 the value is 2; or if (1, 2) is a key in the dictionary. +Since the designers of Python decided to define the membership check on dictionaries on the keys, it makes more sense to make a dictionary an iterable over its keys. Indeed, one usually expects that if x in some_iterable holds, then x in list(some_iterable) should hold as well. If the iterable of a dictionary would return 2-tuples of key-value pairs (like C# does), then if we would make a list of these 2-tuples, it would not be in harmony with the membership check on the dictionary itself. Since if 2 in some_dict holds, 2 in list(some_dict) would fail.",0.0,False,1,6231 +2019-08-04 13:31:10.467,How do I bulk download images (70k) from urls with a restriction on the simultaneous downloads?,"I'm a bit clueless. I have a csv file with these columns: name - picture url +I would like to bulk download the 70k images into a folder, rename the images with the name in the first column and number them if there is more than one per name. +Some are jpegs some are pngs. +I'm guessing I need to use pandas to get the data from the csv but I don't know how to make the downloading/renaming part without starting all the downloads at the same time, which will for sure crash my computer (It did, I wasn't even mad). +Thanks in advance for any light you can shed on this.",Try downloading in batches like 500 images...then sleep for some 1 seconds and loop it....quite time consuming...but sure fire method....for the coding reference you can explore packges like urllib (for downloading) and as soon as u download the file use os.rename() to change the name....As u already know for that csv file use pandas...,0.2012947653214861,False,1,6232 +2019-08-05 03:07:24.777,Standard Deviation of every pixel in an image in Python,"I have an image stored in a 2D array called data. I know how to calculate the standard deviation of the entire array using numpy that outputs one number quantifying how much the data is spread. However, how can I made a standard deviation map (of the same size as my image array) and each element in this array is the standard deviation of the corresponding pixel in the image array (i.e, data).","Use slicing, given images[num, width, height] you may calculate std. deviation of a single image using images[n].std() or for a single pixel: images[:, x, y].std()",1.2,True,1,6233 +2019-08-05 06:28:35.310,Convert each row in a PySpark DataFrame to a file in s3,"I'm using PySpark and I need to convert each row in a DataFrame to a JSON file (in s3), preferably naming the file using the value of a selected column. +Couldn't find how to do that. Any help will be very appreciated.","I think directly we can't store for each row as a JSON based file. Instead of that we can do like iterate for each partition of dataframe and connect to S3 using AWS S3 based library's (to connect to S3 on the partition level). Then, On each partition with the help of iterator, we can convert the row into JSON based file and push to S3.",0.0,False,1,6234 +2019-08-06 04:52:59.987,what do hidden layers mean in a neural network?,"in a standard neural network, I'm trying to understand, intuitively, what the values of a hidden layer mean in the model. +I understand the calculation steps, but I still dont know how to think about the hidden layers and how interpret the results (of the hidden layer) +So for example, given the standard MNIST datset that is used to train and predict handwritten digits between 0 to 9, a model would look like this: + +An image of a handwritten digit will have 784 pixels. +Since there are 784 pixels, there would be 784 input nodes and the value of each node is the pixel intensity(0-255) +each node branches out and these branches are the weights. +My next layer is my hidden layer, and the value of a given node in the hidden layer is the weighted sum of my input nodes (pixels*weights). +Whatever value I get, I squash it with a sigmoid function and I get a value between 0 and 1. + +That number that I get from the sigmoid. What does it represent exactly and why is it relevant? My understanding is that if I want to build more hidden layers, I'll be using the values of my initial hidden layer, but at this point, i'm stuck as to what the values of the first hidden layer mean exactly. +Thank you!","AFAIK, for this digit recognition case, one way to think about it is each level of the hidden layers represents the level of abstraction. +For now, imagine the neural network for digit recognition has only 3 layers which is 1 input layer, 1 hidden layer and 1 output layer. +Let's take a look at a number. To recognise that it is a number we can break the picture of the number to a few more abstract concepts such as lines, circles and arcs. If we want to recognise 6, we can first recognise the more abstract concept that is exists in the picture. for 6 it would be an arc and a circle for this example. For 8 it would be 2 circles. For 1 it would be a line. +It is the same for a neural network. We can think of layer 1 for pixels, layer 2 for recognising the abstract concept we talked earlier such as lines, circles and arcs and finally in layer 3 we determine which number it is. +Here we can see that the input goes through a series of layers from the most abstract layer to the less abstract layer (pixels -> line, circle, arcs -> number). In this example we only have 1 hidden layer but in real implementation it would be better to have more hidden layer that 1 depending on your interpretation of the neural network. Sometime we don't even have to think about what each layer represents and let the training do it fo us. That is the purpose of the training anyway.",0.0,False,3,6235 +2019-08-06 04:52:59.987,what do hidden layers mean in a neural network?,"in a standard neural network, I'm trying to understand, intuitively, what the values of a hidden layer mean in the model. +I understand the calculation steps, but I still dont know how to think about the hidden layers and how interpret the results (of the hidden layer) +So for example, given the standard MNIST datset that is used to train and predict handwritten digits between 0 to 9, a model would look like this: + +An image of a handwritten digit will have 784 pixels. +Since there are 784 pixels, there would be 784 input nodes and the value of each node is the pixel intensity(0-255) +each node branches out and these branches are the weights. +My next layer is my hidden layer, and the value of a given node in the hidden layer is the weighted sum of my input nodes (pixels*weights). +Whatever value I get, I squash it with a sigmoid function and I get a value between 0 and 1. + +That number that I get from the sigmoid. What does it represent exactly and why is it relevant? My understanding is that if I want to build more hidden layers, I'll be using the values of my initial hidden layer, but at this point, i'm stuck as to what the values of the first hidden layer mean exactly. +Thank you!","A hidden layer in a neural network may be understood as a layer that is neither an input nor an output, but instead is an intermediate step in the network's computation. +In your MNIST case, the network's state in the hidden layer is a processed version of the inputs, a reduction from full digits to abstract information about those digits. +This idea extends to all other hidden layer cases you'll encounter in machine learning -- a second hidden layer is an even more abstract version of the input data, a recurrent neural network's hidden layer is an interpretation of the inputs that happens to collect information over time, or the hidden state in a convolutional neural network is an interpreted version of the input with certain features isolated through the process of convolution. +To reiterate, a hidden layer is an intermediate step in your neural network's process. The information in that layer is an abstraction of the input, and holds information required to solve the problem at the output.",0.0,False,3,6235 +2019-08-06 04:52:59.987,what do hidden layers mean in a neural network?,"in a standard neural network, I'm trying to understand, intuitively, what the values of a hidden layer mean in the model. +I understand the calculation steps, but I still dont know how to think about the hidden layers and how interpret the results (of the hidden layer) +So for example, given the standard MNIST datset that is used to train and predict handwritten digits between 0 to 9, a model would look like this: + +An image of a handwritten digit will have 784 pixels. +Since there are 784 pixels, there would be 784 input nodes and the value of each node is the pixel intensity(0-255) +each node branches out and these branches are the weights. +My next layer is my hidden layer, and the value of a given node in the hidden layer is the weighted sum of my input nodes (pixels*weights). +Whatever value I get, I squash it with a sigmoid function and I get a value between 0 and 1. + +That number that I get from the sigmoid. What does it represent exactly and why is it relevant? My understanding is that if I want to build more hidden layers, I'll be using the values of my initial hidden layer, but at this point, i'm stuck as to what the values of the first hidden layer mean exactly. +Thank you!","Consider a very basic example of AND, OR, NOT and XOR functions. +You may already know that a single neuron is only suitable when the problem is linearly separable. +Here in this case, AND, OR and NOT functions are linearly separable and so they can be easy handled using a single neuron. +But consider the XOR function. It is not linearly separable. So a single neuron will not be able to predict the value of XOR function. +Now, XOR function is a combination of AND, OR and NOT. Below equation is the relation between them: + +a XOR b = (a AND (NOT b)) OR ((NOT a) AND b) + +So, for XOR, we can use a network which contain three layers. +First layer will act as NOT function, second layer will act as AND of the output of first layer and finally the output layer will act as OR of the 2nd hidden layer. +Note: This is just a example to explain why it is needed, XOR can be implemented in various other combination of neurons.",0.0,False,3,6235 +2019-08-06 09:58:13.633,Showing text coordinate from png on raw .pdf file,"I am doing OCR on Raw PDF file where in i am converting into png images and doing OCR on that. My objective is to extract coordinates for a certain keyword from png and showcase those coordinates on actual raw pdf. +I have already tried showing those coordinates on png images using opencv but i am not able to showcase those coordinates on actual raw pdf since the coordinate system of both format are different. Can anyone please helpme on how to showcase bounding box on actual raw pdf based on the coordinates generated from png images.","All you need to do is map the coordinates of the OCR token (which would be given for the image) to that of the pdf page. +For instance, +image_dimensions = [1800, 2400] # width, height +pdf_page_dimension = [595, 841] # these are coordinates of the specific page of the pdf +Assuming, on OCRing the image, a word has coordinates = [400, 700, 450, 720] , the same can be rendered on the pdf by multiplying them with scale on each axis +x_scale = pdf_page_dimension[0] / image_dimensions[0] +y_scale = pdf_page_dimension[1] / image_dimensions[1] +scaled_coordinates = [400*x_scale, 700*y_scale, 450*x_scale, 720*y_scale] +Pdf page dimensions can be obtained from any of the packages: poppler, pdfparser, pdfminer, pdfplumber",-0.3869120172231254,False,1,6236 +2019-08-06 13:48:46.087,How to evaluate HDBSCAN text clusters?,"I'm currently trying to use HDBSCAN to cluster movie data. The goal is to cluster similar movies together (based on movie info like keywords, genres, actor names, etc) and then apply LDA to each cluster and get the representative topics. However, I'm having a hard time evaluating the results (apart from visual analysis, which is not great as the data grows). With LDA, although it's hard to evaluate it, i've been using the coherence measure. However, does anyone have any idea on how to evaluate the clusters made by HDBSCAN? I haven't been able to find much info on it, so if anyone has any idea, I'd very much appreciate!","Its the same problem everywhere in unsupervised learning. +It is unsupervised, you are trying to discover something new and interesting. There is no way for the computer to decide whether something is actually interesting or new. It can decide and trivial cases when the prior knowledge is coded in machine processable form already, and you can compute some heuristics values as a proxy for interestingness. But such measures (including density-based measures such as DBCV are actually in no way better to judge this than the clustering algorithm itself is choosing the ""best"" solution). +But in the end, there is no way around manually looking at the data, and doing the next steps - try to put into use what you learned of the data. Supposedly you are not invory tower academic just doing this because of trying to make up yet another useless method... So use it, don't fake using it.",1.2,True,1,6237 +2019-08-06 14:54:30.430,Best Practice for Batch Processing with RabbitMQ,"I'm looking for the best way to preform ETL using Python. +I'm having a channel in RabbitMQ which send events (can be even every second). +I want to process every 1000 of them. +The main problem is that RabbitMQ interface (I'm using pika) raise callback upon every message. +I looked at Celery framework, however the batch feature was depreciated in version 3. +What is the best way to do it? I thinking about saving my events in a list, and when it reaches 1000 to copy it to other list and preform my processing. However, how do I make it thread-safe? I don't want to lose events, and I'm afraid of losing events while synchronising the list. +It sounds like a very simple use-case, however I didn't find any good best practice for it.","First of all, you should not ""batch"" messages from RabbitMQ unless you really have to. The most efficient way to work with messaging is to process each message independently. +If you need to combine messages in a batch, I would use a separate data store to temporarily store the messages, and then process them when they reach a certain condition. Each time you add an item to the batch, you check that condition (for example, you reached 1000 messages) and trigger the processing of the batch. +This is better than keeping a list in memory, because if your service dies, the messages will still be persisted in the database. +Note : If you have a single processor per queue, this can work without any synchronization mechanism. If you have multiple processors, you will need to implement some sort of locking mechanism.",0.2012947653214861,False,1,6238 +2019-08-07 07:44:51.857,"Pycharm is not letting me run my script 'test_splitter.py' , but instead 'Nosetests in test_splitter.py'?","I see many posts on 'how to run nosetests', but none on how to make pycharm et you run a script without nosetests. And yet, I seem to only be able to run or debug 'Nosetests test_splitter.py' and not ust 'test_splitter.py'! +I'm relatively new to pycharm, and despite going through the documentation, I don't quite understand what nosetests are about and whether they would be preferrable for me testing myscript. But I get an error + +ModuleNotFoundError: No module named 'nose' +Process finished with exit code 1 +Empty suite + +I don't have administartive access so cannot download nosetests, if anyone would be sugesting it. I would just like to run my script! Other scripts are letting me run them just fine without nosetests!","I found the solution: I can run without nosetests from the 'Run' dropdown options in the toolbar, or Alt+Shift+F10.",0.0,False,1,6239 +2019-08-07 11:43:33.013,How do I display a large black rectangle with a moveable transparent circle in pygame?,"That question wasn't very clear. +Essentially, I am trying to make a multi-player Pac-Man game whereby the players (when playing as ghosts) can only see a certain radius around them. My best guess for going about this is to have a rectangle which covers the whole maze and then somehow cut out a circle which will be centred on the ghost's rect. However, I am not sure how to do this last part in pygame. +I'd just like to add if it's even possible in pygame, it would be ideal for the circle to be pixelated and not a smooth circle, but this is not essential. +Any suggestions? Cheers.","The best I can think of is kind of a hack. Build an image outside pygame that is mostly black with a circle of zero-alpha in the center, then blit that object on top of your ghost character to only see a circle around it. I hope there is a better way but I do not know what that is.",0.2012947653214861,False,1,6240 +2019-08-07 16:34:16.810,How do I convert scanned PDF into searchable PDF in Python (Mac)? e.g. OCRMYPDF module,"I am writing a program in python that can read pdf document, extract text from the document and rename the document using extracted text. At first, the scanned pdf document is not searchable. I would like to convert the pdf into searchable pdf on Python instead of using Google doc, Cisdem pdf converter. +I have read about ocrmypdf module which can used to solve this. However, I do not know how to write the code due to my limited knowledge. +I expect the output to convert the scanned pdf into searchable pdf.","I suggest working on the working through the turoial, will maybe take you some time but it should be wortht it. +I'm not exactly sure what you exactly want. In my project the settings below work fine in Most of the Cases. +import ocrmypdf , tesseract +def ocr(file_path, save_path): + ocrmypdf.ocr(file_path, save_path, rotate_pages=True, + remove_background=True,language=""en"", deskew=True, force_ocr=True)",0.5457054096481145,False,2,6241 +2019-08-07 16:34:16.810,How do I convert scanned PDF into searchable PDF in Python (Mac)? e.g. OCRMYPDF module,"I am writing a program in python that can read pdf document, extract text from the document and rename the document using extracted text. At first, the scanned pdf document is not searchable. I would like to convert the pdf into searchable pdf on Python instead of using Google doc, Cisdem pdf converter. +I have read about ocrmypdf module which can used to solve this. However, I do not know how to write the code due to my limited knowledge. +I expect the output to convert the scanned pdf into searchable pdf.","This would be done well into two steps + +Create Python OCR Python function +import ocrmypdf +def ocr(file_path, save_path): +ocrmypdf.ocr(file_path, save_path) + +Call and use a function. +ocr(""input.pdf"",""output.pdf"") + + +Thank you, if you got any question ask please.",0.0,False,2,6241 +2019-08-07 16:55:55.510,How to direct the same Amazon S3 events into several different SQS queues?,"I'm working with AWS Lambda functions (in Python), that process new files that appear in the same Amazon S3 bucket and folders. +When new file appears in s3:/folder1/folderA, B, C, an event s3:ObjectCreated:* is generated and it goes into sqs1, then processed by Lambda1 (and then deleted from sqs1 after successful processing). +I need the same event related to the same new file that appears in s3:/folder1/folderA (but not folderB, or C) to go also into sqs2, to be processed by Lambda2. Lambda1 modifies that file and saves it somewhere, Lambda2 gets that file into DB, for example. +But AWS docs says that: + +Notification configurations that use Filter cannot define filtering rules with overlapping prefixes, overlapping suffixes, or prefix and suffix overlapping. + +So question is how to bypass this limitation? Are there any known recommended or standard solutions?","Instead of set up the S3 object notification of (S3 -> SQS), you should set up a notification of (S3 -> Lambda). +In your lambda function, you parse the S3 event and then you write your own logic to send whatever content about the S3 event to whatever SQS queues you like.",0.2012947653214861,False,1,6242 +2019-08-08 08:08:44.877,Triggering actions in Python Flask via cron or similar,"I'm needing to trigger an action at a particular date/time either in python or by another service. +Let's say I have built an application that stores the expiry dates of memberships in a database. I'm needing to trigger a number of actions when the member expires (for example, changing the status of the membership and sending an expiry email to the member), which is fine - I can deal with the actions. +However, what I am having trouble with is how do I get these actions to trigger when the expiry date is reached? Are there any concepts or best practices that I should stick to when doing this? +Currently, I've achieved this by executing a Google Cloud Function every day (via Google Cloud Scheduler) which checks if the membership expiry is equal to today, and completes the action if it is. I feel like this solution is quite 'hacky'.","I'm not sure which database you are using but I'm inferring you have a table that have the ""membership"" details of all your users. And each day you run a Cron job that queries this table to see which row has ""expiration_date = today"", is that correct?. +I believe that's an efficient way to do it (it will be faster if you have few columns on that table).",1.2,True,1,6243 +2019-08-09 10:59:47.240,How to deploy and run python scripts inside nodejs application?,"I'm working with a MEAN stack application, that passes a file to python script, and this script doing some tasks and then it returns some results. +The question is and how to install the required python packages when I deploy it? +Thanks! +I've tried to run python code inside nodejs application, using python shell.","Place python script along with requirements.txt(which has your python dependencies) in your nodejs project +directory. +During deployment , call pip install on the requirements.txt and it +should install the packages for you. +You can call python script from nodejs just like any shell command +using inbuild child_process module or python-shell.",1.2,True,1,6244 +2019-08-09 14:23:00.953,Trying to extract Certificate information in Python,"I am very new to python and cannot seem to figure out how to accomplish this task. I want to connect to a website and extract the certificate information such as issuer and expiration dates. +I have looked all over, tried all kinds of steps but because I am new I am getting lost in the socket, wrapper etc. +To make matters worse, I am in a proxy environment and it seems to really complicate things. +Does anyone know how I could connect and extract the information while behind the proxy?",Python SSL lib don't deal with proxies.,0.0,False,1,6245 +2019-08-09 22:16:56.867,Python - Using RegEx to extract only the String in between pattern,"Hoping somebody can point me in the right direction. +I am trying to parse log file to figure out how many users are logging into the system on a per-day basis. +The log file gets generated in the pattern listed below. +""<""Commit ts=""20141001114139"" client=""ABCREX/John Doe""> +""8764"",""ABCREX/John Doe"",""00.000.0.000"",""User 'ABCREX/John Doe' successfully logged in from address '00.000.0.000'."" +""<""/Commit> +""<""Commit ts=""20141001114139"" client=""ABCREX/John Doe""> +""8764"",""ABCREX/Jerry Doe"",""00.000.0.000"",""User 'ABCREX/Jerry Doe' successfully logged in from address '00.000.0.000'."" +""<""/Commit> +""<""Commit ts=""20141001114139"" client=""ABCREX/John Doe""> +""8764"",""ABCREX/Jane Doe"",""00.000.0.000"",""User 'ABCREX/Jane Doe' successfully logged in from address '00.000.0.000'."" +""<""/Commit> +I am trying to capture the username from the above lines and load into DB. +so I am interested only in values +John Doe, Jerry Doe, Jane Doe +but the when I do pattern match using REGEX it returns the below +client=""ABCREX/John Doe""> +then using the code I am employing I have to apply multiple replace to remove + ""Client"", ""ABCREX/"", "">""...etc +I currently have code which is working but I feel its highly inefficient and resource consuming. I am performing split on tags then parsing reading line by line. +'''extract the user login Name''' +UserLoginName = str(re.search('client=(.*)>',items).group()).replace('ABCREX/', '').replace('client=""','').replace('"">', '') +print(UserLoginName) +Is there any way I can tell the REGEX to grab only the string found within the pattern and not include the pattern in the results as well?","pattern = r'User\s\'ABCREX/(.*?)\'' +list_of_usernames = re.findall(pattern, output) +That would match the pattern +""User 'ABCREX/Jerry Doe'"" and pull out the username and add it to a list. Is that helpful? I'm new here too so let me know if there is more I can help answer.",0.0,False,1,6246 +2019-08-10 05:15:41.640,SelectField to create dropdown menu,"I have a database with some tables in it. I want now on my website has the dropdown and the choices are the names of people from a column of the table from my database and every time I click on a name it will show me a corresponding ID also from a column from this table. how I can do that? or maybe a guide where should I find an answer ! +many thanks!!!","You have to do that in python(if that's what you are using in the backend). +You can create functions in python that gets the list of name of tables which then you can pass to your front-end code. Similarly, you can setup functions where you get the specific table name from HTML and pass it to python and do all sort of database queries. +If all these sounds confusing to you. I suggest you take a Full stack course on udemy, youtube, etc because it can't really be explained in one simple answer. +I hope it was helpful. Feel free to ask me more",0.0,False,1,6247 +2019-08-10 21:15:17.527,Using the original python packages instead of the jython packages,"I am trying to create a hybrid application with python back-end and java GUI and for that purpose I am using jython to access the data from the GUI. +I wrote code using a standard Python 3.7.4 virtual environment and it worked ""perfectly"". But when I try to run the same code on jython it doesn't work so it seems that in jython some packages like threading are overwritten with java functionality. +My question is how can I use the threading package for example from python but in jython environment? +Here is the error: + +Exception in thread Thread-1:Traceback (most recent call last): + File ""/home/dexxrey/jython2.7.0/Lib/threading.py"", line 222, in _Thread__bootstrap + self.run() + self._target(*self._args, **self._kwargs)","Since you have already decoupled the application i.e using python for backend and java for GUI, why not stick to that and build in a communication layer between the backend and frontend, this layer could either be REST or any Messaging framework.",0.2012947653214861,False,1,6248 +2019-08-11 22:56:25.070,How to get the rand() function in excel to rerun when accessing an excel file through python,"I am trying to access an excel file using python for my physics class. I have to generates data that follows a function but creates variance so it doesn’t line up perfectly to the function(simulating the error experienced in experiments). I did this by using the rand() function. We need to generate a lot of data sets so that we can average them together and eliminate the error/noise creates by the rand() function. I tried to do this by loading the excel file and recording the data I need, but then I can’t figure out how to get the rand() function to rerun and create a new data set. In excel it reruns when i change the value of any cell on the excel sheet, but I don’t know how to do this when I’m accessing the file with Python. Can someone help me figure out how to do this? Thank You.","Excel formulas like RAND(), or any other formula, will only refresh when Excel is actually running and recalculating the worksheet. +So, even though you may be access the data in an Excel workbook with Python, you won't be able to run Excel calculations that way. You will need to find a different approach.",1.2,True,1,6249 +2019-08-12 13:56:37.400,Jupyter notebook: need to run a cell even though close the tab,"My notebook is located on a server, which means that the kernel will still run even though I close the notebook tab. I was thus wondering if it was possible to let the cell running by itself while closing the window? As the notebook is located on a server the kernel will not stop running... +I tried to read previous questions but could not find an answer. Any idea on how to proceed? +Thanks!",You can make open a new file and write outputs to it. I think that's the best that you can do.,0.2012947653214861,False,2,6250 +2019-08-12 13:56:37.400,Jupyter notebook: need to run a cell even though close the tab,"My notebook is located on a server, which means that the kernel will still run even though I close the notebook tab. I was thus wondering if it was possible to let the cell running by itself while closing the window? As the notebook is located on a server the kernel will not stop running... +I tried to read previous questions but could not find an answer. Any idea on how to proceed? +Thanks!","If you run the cell before closing the tab it will continue to run once the tab has been closed. However, the output will be lost (anything using print functions to stdout or plots which display inline) unless it is written to file.",0.0,False,2,6250 +2019-08-12 16:37:23.493,Rasa NLU model to old,"I have a problem. I am trying to use my model with Rasa core, but it gives me this error: + +rasa_nlu.model.UnsupportedModelError: The model version is to old to + be loaded by this Rasa NLU instance. Either retrain the model, or run + withan older version. Model version: 0.14.6 Instance version: 0.15.1 + +Does someone know which version I need to use then and how I can install that version?","I believe you trained this model on the previous version of Rasa NLU and updated Rasa NLU to a new version (Rasa NLU is a dependency for Rasa Core, so changes were made in requirenments.txt file). +If this is a case, there are 2 ways to fix it: + +Recommended solution. If you have data and parameters, train your NLU model again using current dependencies (this one that you have running now). So you have a new model which is compatible with your current version of Rasa +If you don't have a data or can not retrain a model for some reason, then downgrade Rasa NLU to version 0.14.6. I'm not sure if your current Rasa core is compatible with NLU 0.14.6, so you might also need to downgrade Rasa core if you see errors. + +Good luck!",1.2,True,1,6251 +2019-08-12 18:34:13.630,how can i split a full name to first name and last name in python?,"I'm a novice in python programming and i'm trying to split full name to first name and last name, can someone assist me on this ? so my example file is: +Sarah Simpson +I expect the output like this : Sarah,Simpson","name = ""Thomas Winter"" +LastName = name.split()[1] +(note the parantheses on the function call split.) +split() creates a list where each element is from your original string, delimited by whitespace. You can now grab the second element using name.split()[1] or the last element using name.split()[-1]",0.0,False,1,6252 +2019-08-12 19:59:30.143,pythonanwhere newbie: I don't see sqlite option,"I see an option for MySql and Postgres, and have read help messages for sqlite, but I don't see anyway to use it or to install it. So it appears that it's available or else there wouldn't be any help messages, but I can't find it. I can't do any 'sudo', so no 'apt install', so don't know how to invoke and use it!",sqlite is already installed. You don't need to invoke anything to install it. Just configure your web app to use it.,0.3869120172231254,False,1,6253 +2019-08-12 21:44:29.637,Python/Django and services as classes,"Are there any conventions on how to implement services in Django? Coming from a Java background, we create services for business logic and we ""inject"" them wherever we need them. +Not sure if I'm using python/django the wrong way, but I need to connect to a 3rd party API, so I'm using an api_service.py file to do that. The question is, I want to define this service as a class, and in Java, I can inject this class wherever I need it and it acts more or less like a singleton. Is there something like this I can use with Django or should I build the service as a singleton and get the instance somewhere or even have just separate functions and no classes?","Adding to the answer given by bruno desthuilliers and TreantBG. +There are certain questions that you can ask about the requirements. +For example one question could be, does the api being called change with different type of objects ? +If the api doesn't change, you will probably be okay with keeping it as a method in some file or class. +If it does change, such that you are calling API 1 for some scenario, API 2 for some and so on and so forth, you will likely be better off with moving/abstracting this logic out to some class (from a better code organisation point of view). +PS: Python allows you to be as flexible as you want when it comes to code organisation. It's really upto you to decide on how you want to organise the code.",0.0,False,1,6254 +2019-08-14 01:33:36.937,Does it make sense to use a part of the dataset to train my model?,"The dataset I have is a set of quotations that were presented to various customers in order to sell a commodity. Prices of commodities are sensitive and standardized on a daily basis and therefore negotiations are pretty tricky around their prices. I'm trying to build a classification model that had to understand if a given quotation will be accepted by a customer or rejected by a customer. +I made use of most classifiers I knew about and XGBClassifier was performing the best with ~95% accuracy. Basically, when I fed an unseen dataset it was able to perform well. I wanted to test how sensitive is the model to variation in prices, in order to do that, I synthetically recreated quotations with various prices, for example, if a quote was being presented for $30, I presented the same quote at $5, $10, $15, $20, $25, $35, $40, $45,.. +I expected the classifier to give high probabilities of success as the prices were lower and low probabilities of success as the prices were higher, but this did not happen. Upon further investigation, I found out that some of the features were overshadowing the importance of price in the model and thus had to be dealt with. Even though I dealt with most features by either removing them or feature engineering them to better represent them I was still stuck with a few features that I just cannot remove (client-side requirements) +When I checked the results, it turned out the model was sensitive to 30% of the test data and was showing promising results, but for the rest of the 70% it wasn't sensitive at all. +This is when the idea struck my mind to feed only that segment of the training data where price sensitivity can be clearly captured or where the success of the quote is inversely related to the price being quoted. This created a loss of about 85% of the data, however the relationship that I wanted the model to learn was being captured perfectly well. +This is going to be an incremental learning process for the model, so each time a new dataset comes, I'm thinking of first evaluating it for the price sensitivity and then feeding in only that segment of the data for training which is price sensitive. +Having given some context to the problem, some of the questions I had were: + +Does it make sense to filter out the dataset for segments where the kind of relationship I'm looking for is being exhibited? +Post training the model on the smaller segment of the data and reducing the number of features from 21 to 8, the model accuracy went down to ~87%, however it seems to have captured the price sensitivity bit perfectly. The way I evaluated price sensitivity is by taking the test dataset and artificially adding 10 rows for each quotation with varying prices to see how the success probability changes in the model. Is this a viable approach to such a problem?","To answer your first question, deleting the part of the dataset that doesn't work is not a good idea because then your model will overfit on the data that gives better numbers. This means that the accuracy will be higher, but when presented with something that is slightly different from the dataset, the probability of the network adapting is lower. +To answer the second question, it seems like that's a good approach, but again I'd recommend keeping the full dataset.",0.3869120172231254,False,1,6255 +2019-08-14 15:13:27.587,should jedi be install in every python project environment?,"I am using jedi and more specifically deoplete-jedi in neovim and I wonder if I should install it in every project as a dependency or if I can let jedi reside in the same python environment as neovim uses (and set the setting to tell deoplete-jedi where to look) +It seems wasteful to have to install it in ever project but then again IDK how it would find my project environment from within the neovim environment either.","If by the word ""project""you mean Python virtual environments then yes, you have to install every program and every library that you use to every virtualenv separately. flake8, pytest, jedi, whatever. Python virtual environments are intended to protect one set of libraries from the other so that you could install different sets of libraries and even different versions of libraries. The price is that you have to duplicate programs/libraries that are used often. +There is a way to connect a virtualenv to the globally installed packages but IMO that brings more harm than good.",0.6730655149877884,False,1,6256 +2019-08-15 00:11:44.450,ModuleNotFoundError: no module named efficientnet.tfkeras,"I attempted to do import segmentation_models as sm, but I got an error saying efficientnet was not found. So I then did pip install efficientnet and tried it again. I now get ModuleNotFoundError: no module named efficientnet.tfkeras, even though Keras is installed as I'm able to do from keras.models import * or anything else with Keras +how can I get rid of this error?",To install segmentation-models use the following command: pip install git+https://github.com/qubvel/segmentation_models,1.2,True,1,6257 +2019-08-15 03:25:14.913,Editing a python package,"The question is really simple: +I have a python package installed using pip3 and I'd like to tweak it a little to perform some computations. I've read (and it seems logical) that is very discouraged to not to edit the installed modules. Thus, how can I do this once I downloaded the whole project folder to my computer? Is there any way to, once edited this source code install it with another name? How can I avoid mixing things up? +Thanks!","You can install the package from its source code, instead of PyPi. + +Download the source code - do a git clone of the package +Instead of pip install , install with pip install -e +Change code in the source code, and it will be picked up automatically.",0.0,False,1,6258 +2019-08-15 04:06:41.070,Setting up keras and tensoflow to operate with AMD GPU,"I am trying to set up Keras in order to run models using my GPU. I have a Radeon RX580 and am running Windows 10. +I saw realized that CUDA only supports NVIDIA GPUs and was having difficulty finding a way to get my code to run on the GPU. I tried downloading and setting up plaidml but afterwards from tensorflow.python.client import device_lib +print(device_lib.list_local_devices()) +only printed that I was running on a CPU and there was not a GPU available even though the plaidml setup was a success. I have read that PyOpenCl is needed but have not gotten a clear answer as to why or to what capacity. Does anyone know how to set up this AMD GPU to work properly? any help would be much appreciated. Thank you!","To the best of my knowledge, PlaidML was not working because I did not have the required prerequisites such as OpenCL. Once I downloaded the Visual Studio C++ build tools in order to install PyopenCL from a .whl file. This seemed to resolve the issue",1.2,True,1,6259 +2019-08-15 19:33:15.593,How to deploy flask GUI web application only locally with exe file?,"I'd like to build a GUI for a few Python functions I've written that pull data from MS SQL Server. My boss wants me to share the magic of Python & SQL with the rest of the team, without them having to learn any coding. +I've decided to go down the route of using Flask to create a webapp and creating an executable file using pyinstaller. I'd like it to work similarly to Jupyter Notebook, where you click on the file and it opens the notebook in your browser. +I was able to hack together some code to get a working prototype of the GUI. The issue is I don't know how to deploy it. I need the GUI/Webapp to only run on the local computer for the user I sent the file to, and I don't want it accessible via the internet (because of proprietary company data, security issues, etc). +The only documentation I've been able to find for deploying Flask is going the routine route of a web server. +So the question is, can anyone provide any guidance on how to deploy my GUI WebApp so that it's only available to the user who has the file, and not on the world wide web? +Thank you!","So, a few assumptions-- since you're a business and you're rocking a SQLServer-- you likely have Active Directory, and the computers that you care to access this app are all hooked into that domain (so, in reality, you, or your system admin does have full control over those computers). +Also, the primary function of the app is to access a SQLServer to populate itself with data before doing something with that data. If you're deploying that app, I'm guessing you're probably also including the SQLServer login details along with it. +With that in mind, I would just serve the Flask app on the network on it's own machine (maybe even the SQLServer machine if you have the choice), and then either implement security within the app that feeds off AD to authenticate, or just have a simple user/pass authentication you can distribute to users. By default random computers online aren't going to be able to access that app unless you've set your firewalls to deliberately route WAN traffic to it. +That way, you control the Flask server-- updates only have to occur at one point, making development easier, and users simply have to open up a link in an email you send, or a shortcut you leave on their desktop.",0.2012947653214861,False,2,6260 +2019-08-15 19:33:15.593,How to deploy flask GUI web application only locally with exe file?,"I'd like to build a GUI for a few Python functions I've written that pull data from MS SQL Server. My boss wants me to share the magic of Python & SQL with the rest of the team, without them having to learn any coding. +I've decided to go down the route of using Flask to create a webapp and creating an executable file using pyinstaller. I'd like it to work similarly to Jupyter Notebook, where you click on the file and it opens the notebook in your browser. +I was able to hack together some code to get a working prototype of the GUI. The issue is I don't know how to deploy it. I need the GUI/Webapp to only run on the local computer for the user I sent the file to, and I don't want it accessible via the internet (because of proprietary company data, security issues, etc). +The only documentation I've been able to find for deploying Flask is going the routine route of a web server. +So the question is, can anyone provide any guidance on how to deploy my GUI WebApp so that it's only available to the user who has the file, and not on the world wide web? +Thank you!","Unfortunately, you do not have control over a give users computer. +You are using flask, so your application is a web application which will be exposing your data to some port. I believe the default flask port is 5000. +Regardless, if your user opens the given port in their firewall, and this is also open on whatever router you are connected to, then your application will be publicly visible. +There is nothing that you can do from your python application code to prevent this. +Having said all of that, if you are running on 5000, it is highly unlikely your user will have this port publicly exposed. If you are running on port 80 or 8080, then the chances are higher that you might be exposing something. +A follow up question would be where is the database your web app is connecting to? Is it also on your users machine? If not, and your web app can connect to it regardless of whose machine you run it on, I would be more concerned about your DB being publicly exposed.",0.0,False,2,6260 +2019-08-18 17:11:06.800,how to host python script in a Web Server and access it by calling an API from xamarin application?,"I need to work with opencv in my xamarin application . +I found that if I use openCV directly in xamarin , the size of the app will be huge . +the best solution I found for this is to use the openCV in python script then to host the python script in a Web Server and access it by calling an API from xamarin . +I have no idea how to do this . +any help please ? +and is there is a better solutions ?",You can create your web server using Flask or Django. Flask is a simple micro framework whereas Django is a more advanced MVC like framework.,0.3869120172231254,False,1,6261 +2019-08-20 02:11:48.553,Python: Reference forked project in requirements.txt,"I have a Python project which uses an open source package registered as a dependency in requirements.txt +The package has some deficiencies, so I forked it on Github and made some changes. Now I'd like to test out these changes by running my original project, but I'd like to use the now forked (updated) code for the package I'm depending on. +The project gets compiled into a Docker image; pip install is used to add the package into the project during the docker-compose build command. +What are the standard methods of creating a docker image and running the project using the newly forked dependency, as opposed to the original one? Can requirements.txt be modified somehow or do I need to manually include it into the project? If the latter, how?",you can use git+https://github.com/...../your_forked_repo in your requirements.txt instead of typing Package==1.1.1,1.2,True,1,6262 +2019-08-20 17:45:25.027,Parsing in Python where delimiter also appears in the data,"Wow, I'm thankful for all of the responses on this! To clarify the data pattern does repeat. Here is a sample: +Item: some text Name: some other text Time recorded: hh:mm Time left: hh:mm + other unrelated text some other unrelated text lots more text that is unrelated Item: some text Name: some other text Time recorded: hh:mm Time left: hh:mm other unrelated text some other unrelated text lots more text that is unrelated Item: some text Name: some other text Time recorded: hh:mm Time left: hh:mm + and so on and so on +I am using Python 3.7 to parse input from a text file that is formatted like this sample: +Item: some text Name: some other text Time recorded: hh:mm Time left: hh:mm and the pattern repeats, with other similar fields, through a few hundred pages. +Because there is a "":"" value in some of the values (i.e. hh:mm), I not sure how to use that as a delimiter between the key and the value. I need to obtain all of the values associated with ""Item"", ""Name"", and ""Time left"" and output all of the matching values to a CSV file (I have the output part working) +Any suggestions? Thank you! +(apologies, I asked this on Stack Exchange and it was deleted, I'm new at this)",Use the ': ' (with a space) as a delimiter.,0.1016881243684853,False,1,6263 +2019-08-20 20:09:50.087,Getting error 'file is not a database' after already accessing the database,"I am currently helping with some NLP code and in the code we have to access a database to get the papers. I have fun the code successfully before but every time I try to run the code again I get the error sqlite3.DatabaseError: file is not a database. I am not sure what is happening here because the database is still in the same exact position and the path doesn't change. +I've tried looking up this problem but haven't found similar issues. +I am hoping that someone can explain what is happening here because I don't even know how to start with this issue because it runs once but not again.","I got the same issue. I have a program that print some information from my database but after running it again and again, I got an error that my database was unable to load. For me I think it may be because I have tried to be connected to my database that this problem occurs. And what I suggest you is to reboot your computer or to research the way of being connected several times to the database",1.2,True,1,6264 +2019-08-21 11:32:33.130,How do I stop a Python script from running in my command line?,"I recently followed a tutorial on web scraping, and as part of that tutorial, I had to execute (?) the script I had written in my command line.Now that script runs every hour and I don't know how to stop it. +I want to stop the script from running. I have tried deleting the code, but the script still runs. What should I do?","I can't comment, but you must show us the script or part of the script so we can try to find out the problem or the video you were watching. Asking just a question without an example doesn't help us as much figure out the problem. + +If you're using Flask, in the terminal or CMD you're running the script. Type in CTRL+C and it should stop the script. OR set the debug to false eg. app.run(debug=False) turn that to False because sometimes that can make it run in background and look for updates even though the script was stopped. In conclusion: Try to type CTRL+C or if not set debug to False",0.2012947653214861,False,2,6265 +2019-08-21 11:32:33.130,How do I stop a Python script from running in my command line?,"I recently followed a tutorial on web scraping, and as part of that tutorial, I had to execute (?) the script I had written in my command line.Now that script runs every hour and I don't know how to stop it. +I want to stop the script from running. I have tried deleting the code, but the script still runs. What should I do?",You can kill it from task manager.,1.2,True,2,6265 +2019-08-23 04:11:30.900,How to insert variables into a text cell using google colab,"I would like to insert a python variable into a text cell, in google colab. +For example, if a=10, I would like to insert the a into a text cell and render the value. +So in the text cell (using Jupyter Notebook with nbextensions) I would like to write the following in the text cell: +There will be {{ a }} pieces of fruit at the reception. +It should show up as: +There will be 10 pieces of fruit at the reception. +The markdown cheatsheets and explanations do not say how to achieve this. Is this possible currently?",It's not possible to change 'input cell' (either code or markdown) programmatically. You can change only the output cells. Input cells always require manually change. (even %load doesn't work),0.9950547536867304,False,1,6266 +2019-08-24 07:50:39.733,How to get a callback when the specified epoch number is over?,"I want to fine turn my model when using Keras, and I want to change my training data and learning rate to train when the epochs arrive 10, So how to get a callback when the specified epoch number is over.","Actually, the way keras works this is probably not the best way to go, it would be much better to treat this as fine tuning, meaning that you finish the 10 epochs, save the model and then load the model (from another script) and continue training with the lr and data you fancy. +There are several reasons for this. + +It is much clearer and easier to debug. You check you model properly after the 10 epochs, verify that it works properly and carry on +It is much better to do several experiments this way, starting from epoch 10. + +Good luck!",0.0,False,1,6267 +2019-08-25 13:10:47.760,Is Python's pipenv slow?,"I tried switching from venv & conda to pipenv to manage my virtual environments, but one thing I noticed about pipenv that it's oddly slow when it's doing ""Locking"" and it gets to the point where it stops executing for ""Running out of time"". Is it usually this slow or is it just me? Also, could you give me some advice regarding how to make it faster?","Pipenv is literally a joke. I spent 30 minutes staring at ""Locking"", which eventually fails after exactly 15 minutes, and I tried two times. +The most meaningless thirty minutes in my life. +Was my Pipfile complex? No. I included ""flask"" with ""flake8"" + ""pylint"" + ""mypy"" + ""black"". +Every time someone tries to fix the ""dependency management"" of Python, it just gets worse. +I'm expecting Poetry to solve this, but who knows. +Maybe it's time to move on to typed languages for web development.",0.9950547536867304,False,2,6268 +2019-08-25 13:10:47.760,Is Python's pipenv slow?,"I tried switching from venv & conda to pipenv to manage my virtual environments, but one thing I noticed about pipenv that it's oddly slow when it's doing ""Locking"" and it gets to the point where it stops executing for ""Running out of time"". Is it usually this slow or is it just me? Also, could you give me some advice regarding how to make it faster?","try using --skip-lock like this : +pipenv install --skip-lock +Note : do not skip-lock when going in production",0.1618299653758019,False,2,6268 +2019-08-26 01:21:16.273,Python script denied in terminal,"I have a folder on my desktop that contains my script and when I run it in the pycharm ide it works perfectly but when I try to run from the terminal I get /Users/neelmukherjee/Desktop/budgeter/product_price.py: Permission denied +I'm not quite sure as to why this is happening +I tried using ls -al to check the permissions and for some reason, the file is labelled as +drwx------@ 33 neelmukherjee staff 1056 26 Aug 09:03 Desktop +I'm assuming this means that I should run this file as an admin. But how exactly can I do that? +My goal is to run my script from the terminal successfully and that may be possible by running it as an admin how should I do that?","Ok, so I was able to figure it out. I had to use +chmod +x to help make it executable first. +chmod +x /Users/neelmukherjee/Desktop/budgeter/product_price.py +and the run /Users/neelmukherjee/Desktop/budgeter/product_price.py",1.2,True,1,6269 +2019-08-26 06:10:10.417,How to watch an hdfs directory and copy the latest file that arrives in hdfs to local?,"I want to write a script in bash/python such that the script copies the latest file which arrives at hdfs directory.I know I can use inotify in local, but how to implement it in hdfs? +Can you please share the sample code for it. When I searched for it in google it gives me long codes.Is there a simpler way other than inotify(if its too complex)","Inelegant hack: +Mount hdfs using FUSE then periodically use find -cmin n to get a list of files created in the last n minutes. +Then use find -anewer to sort them.",0.0,False,1,6270 +2019-08-26 22:11:31.383,PySpark Group and apply UDF row by row operation,"I have a dataset that contains 'tag' and 'date'. I need to group the data by 'tag' (this is pretty easy), then within each group count the number of row that the date for them is smaller than the date in that specific row. I basically need to loop over the rows after grouping the data. I don't know how to write a UDF which takes care of that in PySpark. I appreciate your help.","you need an aggregation ? +df.groupBy(""tag"").agg({""date"":""min""}) +what about that ?",0.0,False,1,6271 +2019-08-26 23:20:06.887,How to install stuff like Requests and BeautifulSoup to use in Python?,"I am an extreme beginner with Python and its libraries and installation in general. I want to make an extremely simple google search web scraping tool. I was told to use Requests and BeautifulSoup. I have installed python3 on my Mac by using brew install python3 and I am wondering how to get those two libraries +I googled around and many results said that by doing brew install python3 it will automatically install pip so I can use something like pip install requests but it says pip: command not found. +by running python3 --version it says Python 3.7.4","Since you're running with Python3, not Python (which usually refers to 2.7), you should try using pip3. +pip on the other hand, is the package installer for Python, not Python3.",1.2,True,1,6272 +2019-08-27 14:17:56.143,Stop subprocess.check_output to print on video,"I'm writing a python program which uses subprocess to send files via cURL. It works, but for each file/zip it outputs the loading progress, time and other stuff which I don't want to be shown. Does anyone know how to stop it?",You should add stderr=subprocess.DEVNULL or stderr=subprocess.PIPE to your check_output call,1.2,True,1,6273 +2019-08-27 15:22:51.420,In a Jupyter Notebook how do I split a bulleted list in multiple text cells?,"Suppose I have a bulleted list in Jupyter in a markdown cell like this: + +Item1 +Item2 +Item3 + +Is there a way to convert this one cell list in three markdown text cells?","Ctrl + Shift + - will split a cell on cursor. Else, cannot process a text of a cell with code unless you're importing a notebook within another notebook.",0.0,False,1,6274 +2019-08-27 17:48:12.200,Saving large numpy 2d arrays,"I have an array with ~1,000,000 rows, each of which is a numpy array of 4,800 float32 numbers. +I need to save this as a csv file, however using numpy.savetxt has been running for 30 minutes and I don't know how much longer it will run for. +Is there a faster method of saving the large array as a csv? +Many thanks, +Josh","As pointed out in the comments, 1e6 rows * 4800 columns * 4 bytes per float32 is 18GiB. Writing a float to text takes ~9 bytes of text (estimating 1 for integer, 1 for decimal, 5 for mantissa and 2 for separator), which comes out to 40GiB. This takes a long time to do, since just the conversion to text itself is non-trivial, and disk I/O will be a huge bottle-neck. +One way to optimize this process may be to convert the entire array to text on your own terms, and write it in blocks using Python's binary I/O. I doubt that will give you too much benefit though. +A much better solution would be to write the binary data to a file instead of text. Aside from the obvious advantages of space and speed, binary has the advantage of being searchable and not requiring transformation after loading. You know where every individual element is in the file, if you are clever, you can access portions of the file without loading the entire thing. Finally, a binary file is more likely to be highly compressible than a relatively low-entropy text file. +Disadvantages of binary are that it is not human-readable, and not as portable as text. The latter is not a problem, since transforming into an acceptable format will be trivial. The former is likely a non-issue given the amount of data you are attempting to process anyway. +Keep in mind that human readability is a relative term. A human can not read 40iGB of numerical data with understanding. A human can process A) a graphical representation of the data, or B) scan through relatively small portions of the data. Both cases are suitable for binary representations. Case A) is straightforward: load, transform and plot the data. This will be much faster if the data is already in a binary format that you can pass directly to the analysis and plotting routines. Case B) can be handled with something like a memory mapped file. You only ever need to load a small portion of the file, since you can't really show more than say a thousand elements on screen at one time anyway. Any reasonable modern platform should be able to keep upI/O and binary-to-text conversion associated with a user scrolling around a table widget or similar. In fact, binary makes it easier since you know exactly where each element belongs in the file.",1.2,True,1,6275 +2019-08-28 08:59:57.570,Overriding celery result table (celery_taskmeta) for Postgres,"I am using celery to do some distributed tasks and want to override celery_taskmeta and add some more columns. I use Postgres as DB and SQLAlchemy as ORM. I looked up celery docs but could not find out how to do it. +Help would be appreciated.","I would suggest a different approach - add an extra table with your extended data. This table would have a foreign-key constraint that would ensure each record is related to the particular entry in the celery_taskmeta. Why this approach? - It separates your domain (domain of your application), from the Celery domain. Also it does not involve modifying the table structure that may (in theory it should not) cause trouble.",0.3869120172231254,False,1,6276 +2019-08-28 14:01:28.443,how to remove airflow install,"I tried pip uninstall airflow and pip3 uninstall airflow and both return + +Cannot uninstall requirement airflow, not installed + +I'd like to remove airflow completely and run clean install.",Airflow now is apache-airflow.,1.2,True,1,6277 +2019-08-28 16:38:47.373,ImportError: cannot import name 'deque' from 'collections' how to clear this?,"I have get + +ImportError: cannot import name 'deque' from 'collections' + +How to resolve this issue? I have already changed module name (the module name is collections.py) but this is not worked.",In my case I had to rename my python file from keyword.py to keyword2.py.,0.0,False,2,6278 +2019-08-28 16:38:47.373,ImportError: cannot import name 'deque' from 'collections' how to clear this?,"I have get + +ImportError: cannot import name 'deque' from 'collections' + +How to resolve this issue? I have already changed module name (the module name is collections.py) but this is not worked.","I had the same problem when i run the command python -m venv . Renamed my file from: collections.py to my_collections.py. +It worked!",0.0,False,2,6278 +2019-08-30 04:47:58.880,Authenticating Google Cloud Storage SDK in Cloud Functions,"This is probably a really simple question, but I can't seem to find an answer online. +I'm using a Google Cloud Function to generate a CSV file and store the file in a Google Storage bucket. I've got the code working on my local machine using a json service account. +I'm wanting to push this code to a cloud function, however, I can't use the json service account file in the cloud environment - so how do I authenticate to my storage account in the cloud function?","You don't need the json service account file in the cloud environment. +If the GCS bucket and GCF are in the same project, you can just directly access it. +Otherwise, add your GCF default service account(Note: it's App Engine default service account ) to your GCS project's IAM and grant relative GSC permission.",0.999329299739067,False,1,6279 +2019-08-30 15:12:00.713,Can selenium post real traffic on a website?,"I have written a script in selenium python which is basically opening up a website and clicking on links in it and doing this thing multiple times.. +Purpose of the software was to increase traffic on the website but after script was made it has observed that is not posting real traffic on website while website is just taking it as a test and ignoring it. +Now I am wondering whether it is basically possible with selenium or not? +I have searched around and I suppose it is possible but don't know how. Do anyone know about this? Or is there any specific piece of code for this?","It does create traffic, the problem is websites sometimes defends from bots and can guess if the income connection is a bot or not, maybe you should put some time.wait(seconds) between actions to deceive the website control and make it thinks you are a person",0.0,False,1,6280 +2019-08-30 22:08:19.797,what are the options to implement random search?,"So i want to implement random search but there is no clear cut example as to how to do this. I am confused between the following methods: + +tune.randint() +ray.tune.suggest.BasicVariantGenerator() +tune.sample_from(lambda spec: blah blah np.random.choice()) + +Can someone please explain how and why these methods are same/different for implementing random search.","Generally, you don't need to use ray.tune.suggest.BasicVariantGenerator(). +For the other two choices, it's up to what suits your need. tune.randint() is just a thin wrapper around tune.sample_from(lambda spec: np.random.randint(...)). You can do more expressive/conditional searches with the latter, but the former is easier to use.",0.0,False,1,6281 +2019-09-01 08:27:48.270,Python Linter installation issue with VScode,"[warning VSCode newbie here] +When installing pylinter from within VScode I got this message: +The script isort.exe is installed in 'C:\Users\fjanssen\AppData\Roaming\Python\Python37\Scripts' which is not on PATH. +Which is correct. However, my Python is installed in C:\Program Files\Python37\ +So I am thinking Python is installed for all users, while pylinter seems to be installed for the user (me). +Checking the command-line that VScode threw to install pylinter it indeed seems to install for the user: + +& ""C:/Program Files/Python37/python.exe"" -m pip install -U pylint --user + +So, I have some questions on resolving this issue; +1 - how can I get the immediate issue resolved? +- remove pylinter as user +- re-install for all users +2 - Will this (having python installed for all users) keep bugging me in the future? +- should I re-install python for the current user only when using it with VScode?","If the goal is to simply use pylint with VS Code, then you don't need to install it globally. Create a virtual environment and select that in VS Code as your Python interpreter and then pylint will be installed there instead of globally. That way you don't have to worry about PATH.",0.3869120172231254,False,1,6282 +2019-09-01 14:17:27.727,Taking specified number of user inputs and storing each in a variable,"I am a beginner in python and want to know how to take just the user specified number of inputs in one single line and store each input in a variable. +For example: +Suppose I have 3 test cases and have to pass 4 integers separated by a white space for each such test case. +The input should look like this: +3 +1 0 4 3 +2 5 -1 4 +3 7 1 9 +I know about the split() method that helps you to separate integers with a space in between. But since I need to input only 4 integers, I need to know how to write the code so that the computer would take only 4 integers for each test case, and then the input line should automatically move, asking the user for input for the next test case. +Other than that, the other thing I am looking for is how to store each integer for each test case in some variable so I can access each one later.","For the first part, if you would like to store input in a variable, you would do the following... + (var_name) = input() +Or if you want to treat your input as an integer, and you are sure it is an integer, you would want to do this + (var_name) = int(input()) +Then you could access the input by calling up the var_name. +Hope that helped :D",0.0,False,1,6283 +2019-09-02 11:48:46.377,How to automatically update view once the database is updated in django?,"I have a problem in which I have to show data entered into a database without having to press any button or doing anything. +I am creating an app for a hospital, it has two views, one for a doctor and one for a patient. +I want as soon as the patient enters his symptoms, it shows up on doctor immediately without having to press any button. +I have no idea how to do this. +Any help would be appreciated. +Thanks in advance","You can't do that with Django solely. You have to use some JS framework (React, Vue, Angular) and WebSockets, for example.",0.0,False,1,6284 +2019-09-04 11:00:26.350,how do I give permission to bash to run to multiple gcloud commands from local jupyter notebook,"I am practicing model deployment to GCP cloud ML Engine. However, I receive errors stated below when I execute the following code section in my local jupyter notebook. Please note I do have bash installed in my local PC and environment variables are properly set. +%%bash +gcloud config set project $PROJECT +gcloud config set compute/region $REGION +Error messages: +-bash: line 1: /mnt/c/Users/User/AppData/Local/Google/Cloud SDK/google-cloud-sdk/bin/gcloud: Permission denied +-bash: line 2: /mnt/c/Users/User/AppData/Local/Google/Cloud SDK/google-cloud-sdk/bin/gcloud: Permission denied +CalledProcessError: Command 'b'gcloud config set project $PROJECT\ngcloud config set compute/region $REGION\n\n'' returned non-zero exit status 126.","Perhaps you installed Google Cloud SDK with root? +try +sudo gcloud config set project $PROJECT +and +sudo gcloud config set compute/region $REGION",0.0,False,1,6285 +2019-09-04 13:31:44.333,how to use breakpoint in mydll.dll using python3 and pythonnet,"I have function imported from a DLL file using pythonnet: +I need to trace my function(in a C# DLL) with Python.",you can hook a Visual Studio debugger to python.exe which runs your dll,0.0,False,1,6286 +2019-09-04 13:40:07.500,Python Oracle DB Connect without Oracle Client,"I am trying to build an application in python which will use Oracle Database installed in corporate server and the application which I am developing can be used in any local machine. +Is it possible to connect to oracle DB in Python without installing the oracle client in the local machine where the python application will be stored and executed? +Like in Java, we can use the jdbc thin driver to acheive the same, how it can be achieved in Python. +Any help is appreciated +Installing oracle client, connect is possible through cx_Oracle module. +But in systems where the client is not installed, how can we connect to the DB.","It is not correct that java can connect to oracle without any oracle provided software. +It needs a compatible version of ojdbc*.jar to connect. Similarly python's cx_oracle library needs oracle instant-client software from oracle to be installed. +Instant client is free software and has a small footprint.",0.2655860252697744,False,2,6287 +2019-09-04 13:40:07.500,Python Oracle DB Connect without Oracle Client,"I am trying to build an application in python which will use Oracle Database installed in corporate server and the application which I am developing can be used in any local machine. +Is it possible to connect to oracle DB in Python without installing the oracle client in the local machine where the python application will be stored and executed? +Like in Java, we can use the jdbc thin driver to acheive the same, how it can be achieved in Python. +Any help is appreciated +Installing oracle client, connect is possible through cx_Oracle module. +But in systems where the client is not installed, how can we connect to the DB.",Installing Oracle client is a huge pain. Could you instead create a Webservice to a system that does have OCI and then connect to it that way? This might end being a better solution rather than direct access.,0.0,False,2,6287 +2019-09-05 03:55:31.020,How to take multi-GPU support to the OpenNMT-py (pytorch)?,"I used python-2.7 version to run the PyTorch with GPU support. I used this command to train the dataset using multi-GPU. +Can someone please tell me how can I fix this error with PyTorch in OpenNMT-py or is there a way to take pytorch support for multi-GPU using python 2.7? +Here is the command that I tried. + + +CUDA_VISIBLE_DEVICES=1,2 + python train.py -data data/demo -save_model demo-model -world_size 2 -gpu_ranks 0 1 + + +This is the error: + +Traceback (most recent call last): + File ""train.py"", line 200, in + main(opt) + File ""train.py"", line 60, in main + mp = torch.multiprocessing.get_context('spawn') + AttributeError: 'module' object has no attribute 'get_context'","Maybe you can check whether your torch and python versions fit the openmt requiremen. +I remember their torch is 1.0 or 1.2 (1.0 is better). You have to lower your latest of version of torch. Hope that would work",0.0,False,1,6288 +2019-09-05 18:28:58.863,What does wave_read.readframes() return if there are multiple channels?,"I understand how the readframes() method works for mono audio input, however I don't know how it will work for stereo input. Would it give a tuple of two byte objects?","A wave file has: +sample rate of Wave_read.getframerate() per second (e.g 44100 if from an audio CD). +sample width of Wave_read.getsampwidth() bytes (i.e 1 for 8-bit samples, 2 for 16-bit samples) +Wave_read.getnchannels() channels (typically 1 for mono, 2 for stereo) +Every time you do a Wave_read.getframes(N), you get N * sample_width * n_channels bytes.",0.0,False,1,6289 +2019-09-07 03:28:26.677,Does SciPy have utilities for parsing and keeping track of the units associated with its constants?,"scipy.constants.physical_constants returns (value, unit, uncertainty) tuples for many specific physical constants. The units are given in the form of a string. (For example, one of the options for the universal gas constant has a unit field of 'J kg^-1 K^-1'.) +At first blush, this seems pretty useful. Keeping track of your units is very important in scientific calculations, but, for the life of me, I haven't been able to find any facilities for parsing these strings into something that can be tracked. Without that, there's no way to simplify the combined units after different values have been added, subtracted, etc with eachother. +I know I can manually declare the units of constants with separate libraries such as what's available in SymPy, but that would make ScyPy's own units completely useless (maybe just a convenience for printouts). That sounds pretty absurd. I can't imagine that ScyPy doesn't know how to deal with units. +What am I missing? +Edit: +I know that SciPy is a stack, and I am well aware of what libraries are part of it. My questions is about if SciPy knows how to work with the very units it spits out with its constants (or if I have to throw out those units and manually redefine everything). As far as I can see, it can't actually parse its own unit strings (and nothing else in the ecosystem seems to know how to make heads or tails of them either). This doesn't make sense to me because if SciPy proper can't deal with these units, why would they be there in the first place? Not to mention, keeping track of your units across your calculations is the exact kind of thing you need to do in science. Forcing manual redefinitions of all the units someone went through the trouble of associating with all these constants doesn't make sense.","No, scipy the library does not have any notion of quantities with units and makes no guarantees when operating on quantities with units (from e.g. pint, astropy.Quantity or other objects from other unit-handling packages).",0.0,False,1,6290 +2019-09-07 11:50:52.290,LightGBM unexpected behaviour outside of jupyter,"I have this strange but when I'm using a LightGBM model to calculate some predictions. +I trained a LightGBM model inside of jupyter and dumped it into a file using pickle. This model is used in an external class. +My problem is when I call my prediction function from this external class outside of jupyter it always predicts an output of 0.5 (on all rows). When I use the exact same class inside of jupyter I get the expected output. In both cases the exact same model is used with the exact same data. +How can this behavior be explained and how can I achieve to get the same results outside of jupyter? Has it something to do with the fact I trained the model inside of jupyter? (I can't imagine why it would, but atm have no clue where this bug is coming from) +Edit: Used versions: +Both times the same lgb version is used (2.2.3), I also checked the python version which are equal (3.6.8) and all system paths (sys.path output). The paths are equal except of '/home/xxx/.local/lib/python3.6/site-packages/IPython/extensions' and '/home/xxx/.ipython'. +Edit 2: I copied the code I used inside of my jupyter and ran it as a normal python file. The model made this way works now inside of jupyter and outside of it. I still wonder why this bug accrued.",It can't be a jupyter problem since jupyter is just an interface to communicate with python. The problem could be that you are using different python environment and different version of lgbm... Check import lightgbm as lgb and lgb.__version__ on both jupyter and your python terminal and make sure there are the same (or check if there has been some major changements between these versions),0.3869120172231254,False,1,6291 +2019-09-08 16:32:01.487,Create Python setup,I have to create a setup screen with tk that starts only at the first boot of the application where you will have to enter names etc ... a sort of setup. Does anyone have any ideas on how to do so that A) is performed only the first time and B) the input can be saved and used in the other scripts? Thanks in advance,"Why not use a file to store the details? You could use a text file or you could use pickle to save a python object then reload it. On starting your application you could check to see if the file exists and contains the necessary information, if it doesn't you can activate your setup screen, if not skip it.",0.3869120172231254,False,1,6292 +2019-09-09 13:09:00.117,What is the best way to combine two data sets that depend on each other?,"I am encountering a task and I am not entirely sure what the best solution is. +I currently have one data set in mongo that I use to display user data on a website, backend is in Python. A different team in the company recently created an API that has additional data that I would let to show along side the user data, and the data from the newly created API is paired to my user data (Shows specific data per user) that I will need to sync up. +I had initially thought of creating a cron job that runs weekly (as the ""other"" API data does not update often) and then taking the information and putting it directly into my data after pairing it up. +A coworker has suggested caching the ""other"" API data and then just returning the ""mixed"" data to display on the website. +What is the best course of action here? Actually adding the data to our data set would allow us to have 1 source of truth and not rely on the other end point, as well as doing less work each time we need the data. Also if we end up needing that information somewhere else in the project, we already have the data in our DB and can just use it directly without needing to re-organize/pair it. +Just looking for general pro's and cons for each solution. Thanks!","Synchronization will always cost more than federation. I would either A) embrace CORS and integrate it in the front-end, or B) create a thin proxy in your Python App. +Which you choose depends on how quickly this API changes, whether you can respond to those changes, and whether you need graceful degradation in case of remote API failure. If it is not mission-critical data, and the API is reliable, just integrate it in the browser. If they support things like HTTP cache-control, all the better, the user's browser will handle it. +If the API is not scalable/reliable, then consider putting in a proxy server-side so that you can catch errors and provide graceful degradation.",1.2,True,1,6293 +2019-09-09 20:26:07.763,pandas pd.options.display.max_rows not working as expected,"I’m using pandas 0.25.1 in Jupyter Lab and the maximum number of rows I can display is 10, regardless of what pd.options.display.max_rows is set to. +However, if pd.options.display.max_rows is set to less than 10 it takes effect and if pd.options.display.max_rows = None then all rows show. +Any idea how I can get a pd.options.display.max_rows of more than 10 to take effect?","min_rows displays the number of rows to be displayed from the top (head) and from the bottom (tail) it will be evenly split..despite putting in an odd number. If you only want a set number of rows to be displayed without reading it into the memory, +another way is to use nrows = 'putnumberhere'. +e.g. results = pd.read_csv('ex6.csv', nrows = 5) # display 5 rows from the top 0 - 4 +If the dataframe has about 100 rows and you want to display only the first 5 rows from the top...NO TAIL use .nrows",-0.2012947653214861,False,1,6294 +2019-09-11 00:46:34.683,Using tensorflow object detection for either or detection,"I have used Tensorflow object detection for quite awhile now. I am more of a user, I dont really know how it works. I am wondering is it possible to train it to recognize an object is something and not something? For example, I want to detect cracks on the tiles. Can i use object detection to do so where i show an image of a tile and it can tell me if there is a crack (and also show the location), or it will tell me if there is no crack on the tile? +I have tried to train using pictures with and without defect, using 2 classes (1 for defect and 1 for no defect). But the results keep showing both (if the picture have defect) in 1 picture. Is there a way to show only the one with defect? +Basically i would like to do defect checking. This is a simplistic case of 1 defect. but the actual case will have a few defects. +Thank you.","In case you're only expecting input images of tiles, either with defects or not, you don't need a class for no defect. +The API adds a background class for everything which is not the other classes. +So you simply need to state one class - defect, and tiles which are not detected as such are not defected. +So in your training set - simply give bounding boxes of defects, and no bounding box in case of no defect, and then your model should learn to detect the defects as mentioned above.",1.2,True,1,6295 +2019-09-11 16:52:17.283,How can I find memory leaks without external packages?,"I am writing a data mining script to pull information off of a program called Agisoft PhotoScan for my lab. PhotoScan uses its own Python library (and I'm not sure how to access pip for this particular build), which has caused me a few problems installing other packages. After dragging, dropping, and praying, I've gotten a few packages to work, but I'm still facing a memory leak. If there is no way around it, I can try to install some more packages to weed out the leak, but I'd like to avoid this if possible. +My understanding of Python garbage collection so far is, when an object loses its reference, it should be deleted. I used sys.getrefcount() to check all my variables, but they all stay constant. I have a hunch that the issue could be in the mysql-connector package I installed, or in PhotoScan itself, but I am not sure how to go about testing. I will be more than happy to provide code if that will help!","It turns out that the memory leak was indeed with the PhotoScan program. I've worked around it by having a separate script open and close it, running my original script once each time. Thank you all for the help!",0.0,False,1,6296 +2019-09-15 06:56:39.743,Start cmd and run multiple commands in the created cmd instance,"I am trying to start cmd window and then running a chain of cmds in succession one after the other in that cmd window. +something like start cmd /k pipenv shell && py manage.py runserver the start cmd should open a new cmd window, which actually happens, then the pipenv shell should start a virtual environment within that cmd instance, also happens, and the py manage.py runserver should run in the created environment but instead it runs where the script is called. +Any ideas on how I can make this work?","Your py manage.py runserver command calling python executor in your major environment. In your case, you could use pipenv run manage.py runserver that detect your virtual env inside your pipfile and activate it to run your command. An alternative way is to use virtualenv that create virtual env directly inside your project directory and calling envname\Scripts\activate each time you want to run something inside your virtual env.",0.2012947653214861,False,1,6297 +2019-09-15 21:33:55.463,"structured numpy ndarray, how to get values","I have a structured numpy ndarray la = {'val1':0,'val2':1} and I would like to return the vals using the 0 and 1 as keys, so I wish to return val1 when I have 0 and val2 when I have 1 which should have been straightforward however my attempts have failed, as I am not familiar with this structure. +How do I return only the corresponding val, or an array of all vals so that I can read in order?","Just found out that I can use la.tolist() and it returns a dictionary, somehow? when I wanted a list, alas from there on I was able to solve my problem.",0.0,False,1,6298 +2019-09-16 15:19:19.583,impossible to use pip,"I start on python, I try to use mathplotlib on my code but I have an error ""ModuleNotFoundError: No module named 'matplotlib'"" on my cmd. So I have tried to use pip on the cmd: pip install mathplotlib. +But I have an other error ""No python at 'C:...\Microsoft Visual Studio..."" +Actually I don't use microsoft studio anymore so I usinstall it but I think I have to change the path for the pip modul but I don't know how... I add the link of the script of the python folder on the variables environment but it doesn't change anything. How can I use pip ? +Antoine","Your setup seems messed up. A couple of ideas: + +long term solution: Uninstall everything related to Python, make sure your PATH environment variables are clean, and reinstall Python from scratch. +short term solution: Since py seems to work, you could go along with it: py, py -3 -m pip install , and so on. +If you feel comfortable enough you could try to salvage what works by looking at the output of py -0p, this should tell you where are the Python installations that are potentially functional, and you could get rid of the rest.",0.0,False,1,6299 +2019-09-16 16:45:45.577,How to create button based chatbot,"I have created a chatbot using RASA to work with free text and it is working fine. As per my new requirement i need to build button based chatbot which should follow flowchart kind of structure. I don't know how to do that what i thought is to convert the flowchart into graph data structure using networkx but i am not sure whether it has that capability. I did search but most of the examples are using dialogue or chat fuel. Can i do it using networkx. +Please help.","Sure, you can. +You just need each button to point to another intent. The payload of each button should point have the /intent_value as its payload and this will cause the NLU to skip evaluation and simply predict the intent. Then you can just bind a trigger to the intent or use the utter_ method. +Hope that helps.",1.2,True,1,6300 +2019-09-16 19:35:35.813,Teradataml: Remove all temporary tables created by Teradata MLE functions,In teradataml how should the user remove temporary tables created by Teradata MLE functions?,At the end of a session call remove_context() to trigger the dropping of tables.,0.0,False,1,6301 +2019-09-17 06:03:09.647,How to inherit controller of a third party module for customization Odoo 12?,"I have a module with a controller and I need to inherit it in a newly created module for some customization. I searched about the controller inheritance in Odoo and I found that we can inherit Odoo's base modules' controllers this way: +from odoo.addons.portal.controllers.portal import CustomerPortal, pager as portal_pager, get_records_pager +but how can I do this for a third party module's controller? In my case, the third party module directory is one step back from my own module's directory. If I should import the class of a third party module controller, how should I do it?","It is not a problem whether you are using a custom module.If the module installed in the database you can import as from odoo.addons. +Eg : from odoo.addons.your_module.controllers.main import MyClass",1.2,True,1,6302 +2019-09-17 13:31:40.087,how to deal with high cardinal categorical feature into numeric for predictive machine learning model?,"I have two columns of having high cardinal categorical values, one column(area_id) has 21878 unique values and other has(page_entry) 800 unique values. I am building a predictive ML model to predict the hits on a webpage. +column information: +area_id: all the locations that were visited during the session. (has location code number of different areas of a webpage) +page_entry: describes the landing page of the session. +how to change these two columns into numerical apart from one_hot encoding? +thank you.","One approach could be to group your categorical levels into smaller buckets using business rules. In your case for the feature area_id you could simply group them based on their geographical location, say all area_ids from a single district (or for that matter any other level of aggregation) will be replaced by a single id. Similarly, for page_entry you could group similar pages based on some attributes like nature of the web page like sports, travel, etc. In this way you could significantly reduce the number dimensions of your variables. +Hope this helps!",0.0,False,1,6303 +2019-09-18 17:09:01.753,How to restrict the maximum size of an element in a list in Python?,"Problem Statement: +There are 5 sockets and 6 phones. Each phone takes 60 minutes to charge completely. What is the least time required to charge all phones? +The phones can be interchanged along the sockets +What I've tried: +I've made a list with 6 elements whose initial value is 0. I've defined two functions. Switch function, which interchanges the phone one socket to the left. Charge function, which adds value 10(charging time assumed) to each element, except the last (as there are only 5 sockets). As the program proceeds, how do I restrict individual elements to 60, while other lower value elements still get added 10 until they attain the value of 60?","You cannot simply restrict the maximum element size. What you can do is check the element size with a if condition and terminate the process. +btw, answer is 6x60/5=72 mins.",0.0,False,2,6304 +2019-09-18 17:09:01.753,How to restrict the maximum size of an element in a list in Python?,"Problem Statement: +There are 5 sockets and 6 phones. Each phone takes 60 minutes to charge completely. What is the least time required to charge all phones? +The phones can be interchanged along the sockets +What I've tried: +I've made a list with 6 elements whose initial value is 0. I've defined two functions. Switch function, which interchanges the phone one socket to the left. Charge function, which adds value 10(charging time assumed) to each element, except the last (as there are only 5 sockets). As the program proceeds, how do I restrict individual elements to 60, while other lower value elements still get added 10 until they attain the value of 60?","In the charge function, add an if condition that checks the value of the element. +I'm not sure what you're add function looks like exactly, but I would define the pseudocode to look something like this: +if element < 60: +add 10 to the element +This way, if an element is greater than or equal to 60, it won't get caught by the if condition and won't get anything added to it.",0.0,False,2,6304 +2019-09-18 18:44:22.307,how to display plot images outside of jupyter notebook?,"So, this might be an utterly dumb question, but I have just started working with python and it's data science libs, and I would like to see seaborn plots displayed, but I prefer to work with editors I have experience with, like VS Code or PyCharm instead of Jupyter notebook. Of course, when I run the python code, the console does not display the plots as those are images. So how do I get to display and see the plots when not using jupyter?","You can try to run an matplotlib example code with python console or ipython console. They will show you a window with your plot. +Also, you can use Spyder instead of those consoles. It is free, and works well with python libraries for data science. Of course, you can check your plots in Spyder.",0.0,False,1,6305 +2019-09-19 18:35:33.863,Tasks linger in celery amqp when publisher is terminated,"I am using Celery with a RabbitMQ server. I have a publisher, which could potentially be terminated by a SIGKILL and since this signal cannot be watched, I cannot revoke the tasks. What would be a common approach to revoke the tasks where the publisher is not alive anymore? +I experimented with an interval on the worker side, but the publisher is obviously not registered as a worker, so I don't know how I can detect a timeout","Another solution, which works in my case, is to add the next task only if the current processed ones are finished. In this case the queue doesn't fill up.",1.2,True,2,6306 +2019-09-19 18:35:33.863,Tasks linger in celery amqp when publisher is terminated,"I am using Celery with a RabbitMQ server. I have a publisher, which could potentially be terminated by a SIGKILL and since this signal cannot be watched, I cannot revoke the tasks. What would be a common approach to revoke the tasks where the publisher is not alive anymore? +I experimented with an interval on the worker side, but the publisher is obviously not registered as a worker, so I don't know how I can detect a timeout","There's nothing built-in to celery to monitor the producer / publisher status -- only the worker / consumer status. There are other alternatives that you can consider, for example by using a redis expiring key that has to be updated periodically by the publisher that can serve as a proxy for whether a publisher is alive. And then in the task checking to see if the flag for a publisher still exists within redis, and if it doesn't the task returns doing nothing.",0.6730655149877884,False,2,6306 +2019-09-19 19:03:13.597,"Python ""Magic methods"" are realy methods?","I know how to use magical methods in python, but I would like to understand more about them. +For it I would like to consider three examples: +1) __init__: +We use this as constructor in the beginning of most classes. If this is a method, what is the object associated with it? Is it a basic python object that is used to generate all the other objects? +2) __add__ +We use this to change the behaviour of the operator +. The same question above. +3) __name__: +The most common use of it is inside this kind of structure:if __name__ == ""__main__"": +This is return True when you are running the module as the main program. +My question is __name__ a method or a variable? If it is a variable what is the method associated with it. If this is a method, what is the object associated with it? +Since I do not understand very well these methods, maybe the questions are not well formulated. I would like to understand how these methods are constructed in Python.","The object is the class that's being instantiated, a.k.a. the Foo in Foo.__init__(actual_instance) +In a + b the object is a, and the expression is equivalent to a.__add__(b) +__name__ is a variable. It can't be a method because then comparisons with a string would always be False since a function is never equal to a string",0.2012947653214861,False,1,6307 +2019-09-19 21:07:37.810,Python - how to check if user is on the desktop,"I am trying to write a program with python that works like android folders bit for Windows. I want the user to be able to single click on a desktop icon and then a window will open with the contents of the folder in it. After giving up trying to find a way to allow single click to open a desktop application (for only one application I am aware that you can allow single click for all files and folders), I decided to check if the user clicked in the location of the file and if they were on the desktop while they were doing that. So what I need to know is how to check if the user is viewing the desktop in python. +Thanks, +Harry +TLDR; how to check if user is viewing the desktop - python","I don't know if ""single clicking"" would work in any way but you can use Pyautogui to automatically click as many times as you want",0.0,False,1,6308 +2019-09-20 11:50:30.050,How to fine-tune a keras model with existing plus newer classes?,"Good day! +I have a celebrity dataset on which I want to fine-tune a keras built-in model. SO far what I have explored and done, we remove the top layers of the original model (or preferably, pass the include_top=False) and add our own layers, and then train our newly added layers while keeping the previous layers frozen. This whole thing is pretty much like intuitive. +Now what I require is, that my model learns to identify the celebrity faces, while also being able to detect all the other objects it has been trained on before. Originally, the models trained on imagenet come with an output layer of 1000 neurons, each representing a separate class. I'm confused about how it should be able to detect the new classes? All the transfer learning and fine-tuning articles and blogs tell us to replace the original 1000-neuron output layer with a different N-neuron layer (N=number of new classes). In my case, I have two celebrities, so if I have a new layer with 2 neurons, I don't know how the model is going to classify the original 1000 imagenet objects. +I need a pointer on this whole thing, that how exactly can I have a pre-trained model taught two new celebrity faces while also maintaining its ability to recognize all the 1000 imagenet objects as well. +Thanks!","With transfer learning, you can make the trained model classify among the new classes on which you just trained using the features learned from the new dataset and the features learned by the model from the dataset on which it was trained in the first place. Unfortunately, you can not make the model to classify between all the classes (original dataset classes + second time used dataset classes), because when you add the new classes, it keeps their weights only for classification. +But, let's say for experimentation you change the number of output neurons (equal to the number of old + new classes) in the last layer, then it will now give random weights to these neurons which on prediction will not give you meaningful result. +This whole thing of making the model to classify among old + new classes experimentation is still in research area. +However, one way you can achieve it is to train your model from scratch on the whole data (old + new).",0.5457054096481145,False,1,6309 +2019-09-20 13:43:24.297,Nvenc session limit per GPU,"I'm using Imageio, the python library that wraps around ffmpeg to do hardware encoding via nvenc. My issue is that I can't get more than 2 sessions to launch (I am using non-quadro GPUs). Even using multiple GPUs. I looked over NVIDIA's support matrix and they state only 2 sessions per gpu, but it seems to be per system. +For example I have 2 GPUs in a system. I can either use the env variable CUDA_VISIBLE_DEVICES or set the ffmpeg flag -gpu to select the GPU. I've verified gpu usage using Nvidia-smi cli. I can get 2 encoding sessions working on a single gpu. Or 1 session working on 2 separate gpus each. But I can't get 2 encoding sessions working on 2 gpus. +Even more strangely if I add more gpus I am still stuck at 2 sessions. I can't launch a third encoding session on a 3rd gpu. I am always stuck at 2 regardless of the # of gpus. Any ideas on how to fix this?","Nvidia limits it 2 per system Not 2 per GPU. The limitation is in the driver, not the hardware. There have been unofficially drivers posted to github which remove the limitation",1.2,True,1,6310 +2019-09-21 07:16:21.710,Setup of the Divio CMS Repositories,"The Divio Django CMS offers two servers: TEST and LIVE. Are these also two separate repositories? Or how is this done in the background? +I'm wondering because I would have the feeling the LIVE server is its own repository that just pulls from the TEST whenever I press deploy. Is that correct?","All Divio projects (django CMS, Python, PHP, whatever) have a Live and Test environment. +By default, both build the project from its repository's master branch (in older projects, develop). +On request, custom tracking branches can be enabled, so that the Live and Test environments will build from separate branches. +When a build successfully completes, the Docker image can be reused until changes are made to the project's repository. This means that after a successful deployment on Test, the Docker image doesn't need to be rebuilt, and the Live environment can be deployed much faster from the pre-built image. (Obviously this is only possible when they are on the same branch.)",0.3869120172231254,False,1,6311 +2019-09-22 12:12:44.420,How do i retrain the model without losing the earlier model data with new set of data,"for my current requirement, I'm having a dataset of 10k+ faces from 100 different people from which I have trained a model for recognizing the face(s). The model was trained by getting the 128 vectors from the facenet_keras.h5 model and feeding those vector value to the Dense layer for classifying the faces. +But the issue I'm facing currently is + +if want to train one person face, I have to retrain the whole model once again. + +How should I get on with this challenge? I have read about a concept called transfer learning but I have no clues about how to implement it. Please give your suggestion on this issue. What can be the possible solutions to it?","With transfer learning you would copy an existing pre-trained model and use it for a different, but similar, dataset from the original one. In your case this would be what you need to do if you want to train the model to recognize your specific 100 people. +If you already did this and you want to add another person to the database without having to retrain the complete model, then I would freeze all layers (set layer.trainable = False for all layers) except for the final fully-connected layer (or the final few layers). Then I would replace the last layer (which had 100 nodes) to a layer with 101 nodes. You could even copy the weights to the first 100 nodes and maybe freeze those too (I'm not sure if this is possible in Keras). In this case you would re-use all the trained convolutional layers etc. and teach the model to recognise this new face.",0.2012947653214861,False,1,6312 +2019-09-22 13:48:06.487,How to debug (500) Internal Server Error on Python Waitress server?,"I'm using Python and Flask, served by Waitress, to host a POST API. I'm calling the API from a C# program that posts data and gets a string response. At least 95% of the time, it works fine, but sometimes the C# program reports an error: +(500) Internal Server Error. +There is no further description of the error or why it occurs. The only clue is that it usually happens in clusters -- when the error occurs once, it likely occurs several times in a row. Without any intervention, it then goes back to running normally. +Since the error is so rare, it is hard to troubleshoot. Any ideas as to how to debug or get more information? Is there error handling I can do from either the C# side or the Flask/Waitress side?","Your flask application should be logging the exception when it occurs. Aside from combing through your logs (which should be stored somewhere centrally) you could consider something like Sentry.io, which is pretty easy to setup with Flask apps.",0.0,False,1,6313 +2019-09-23 05:52:42.417,Check inputs in csv file,"I`m new to python. I have a csv file. I need to check whether the inputs are correct or not. The ode should scan through each rows. +All columns for a particular row should contain values of same type: Eg: +All columns of second row should contain only string, +All columns of third row should contain only numbers... etc +I tried the following approach, (it may seem blunder): +I have only 15 rows, but no idea on number of columns(Its user choice) +df.iloc[1].str.isalpha() +This checks for string. I don`t know how to check ??","Simple approach that can be modified: + +Open df using df = pandas.from_csv() +For each column, use df[''] = df[''].astype(str) (str = string, int = integer, float = float64, ..etc). + +You can check column types using df.dtypes",0.3869120172231254,False,1,6314 +2019-09-23 11:00:06.643,how do I upgrade pip on Mac?,"I cannot upgrade pip on my Mac from the Terminal. +According to the documentation I have to type the command: +pip install -U pip +I get the error message in the Terminal: +pip: command not found +I have Mac OS 10.14.2, python 3.7.2 and pip 18.1. +I want to upgrade to pip 19.2.3","I have found an answer that worked for me: +sudo pip3 install -U pip --ignore-installed pip +This installed pip version 19.2.3 correctly. +It was very hard to find the correct command on the internet...glad I can share it now. +Thanks.",0.1352210990936997,False,3,6315 +2019-09-23 11:00:06.643,how do I upgrade pip on Mac?,"I cannot upgrade pip on my Mac from the Terminal. +According to the documentation I have to type the command: +pip install -U pip +I get the error message in the Terminal: +pip: command not found +I have Mac OS 10.14.2, python 3.7.2 and pip 18.1. +I want to upgrade to pip 19.2.3","pip3 install --upgrade pip + +this works for me!",0.4247838355242418,False,3,6315 +2019-09-23 11:00:06.643,how do I upgrade pip on Mac?,"I cannot upgrade pip on my Mac from the Terminal. +According to the documentation I have to type the command: +pip install -U pip +I get the error message in the Terminal: +pip: command not found +I have Mac OS 10.14.2, python 3.7.2 and pip 18.1. +I want to upgrade to pip 19.2.3",I came on here to figure out the same thing but none of this things seemed to work. so I went back and looked how they were telling me to upgrade it but I still did not get it. So I just started trying things and next thing you know I seen the downloading lines and it told me that my pip was upgraded. what I used was (pip3 install -- upgrade pip). I hope this can help anyone else in need.,0.0,False,3,6315 +2019-09-23 22:18:51.993,how to remove duplicates when using pandas concat to combine two dataframe,"I have two data from. +df1 with columns: id,x1,x2,x3,x4,....xn +df2 with columns: id,y. +df3 =pd.concat([df1,df2],axis=1) +when I use pandas concat to combine them, it became +id,y,id,x1,x2,x3...xn. +there are two id here.How can I get rid of one. +I have tried : +df3=pd.concat([df1,df2],axis=1).drop_duplicates().reset_index(drop=True). +but not work.","drop_duplicates() only removes rows that are completely identical. +what you're looking for is pd.merge(). +pd.merge(df1, df2, on='id)",0.0,False,1,6316 +2019-09-25 00:25:17.317,Supremum Metric in Python for Knn with Uncertain Data,"I'm trying to make a classifier for uncertain data (e.g ranged data) using python. in certain dataset, the list is a 2D array or array of record (contains float numbers for data and a string for labels), where in uncertain dataset the list is a 3D array (contains range of float numbers for data and a string for labels). i managed to manipulate a certain dataset to be uncertain using uniform probability distribution. A research paper says that i have to use supremum distance metric. how do i implement this metric in python? note that in uncertain dataset, both test set and training set is uncertain",I found out using scipy spatial distance and tweaking for-loops in standard knn helps a lot,1.2,True,1,6317 +2019-09-25 13:06:45.637,Dataflow Sideinputs - Worker Cache Size in SDK 2.x,"I am experiencing performance issues in my pipeline in a DoFn that uses large side input of ~ 1GB. The side input is passed using the pvalue.AsList(), which forces materialization of the side input. +The execution graph of the pipeline shows that the particular step spends most of the time for reading the side input. The total amount of data read exceeds the size of the side input by far. Consequently, I conclude that the side input does not fit into memory / cache of the workers even though their RAM is sufficient (using n1-highmem4 workers with 26 GB RAM). +How do I know how big this cache actually is? Is there a way to control its size using Beam Python SDK 2.15.0 (like there was the pipeline option --workerCacheMb=200 for Java 1.x SDK)? +There is no easy way of shrinking my side input more than 10%.","If you are using AsList, you are correct that the whole side input should be loaded into memory. It may be that your worker has enough memory available, but it just takes very long to read 1GB of data into the list. Also, the size of the data that is read depends on the encoding of it. If you can share more details about your algorithm, we can try to figure out how to write a pipeline that may run more efficiently. + +Another option may be to have an external service to keep your side input - for instance, a Redis instance that you write to on one side, and red from on the other side.",0.0,False,1,6318 +2019-09-26 08:40:43.480,Install packages with Conda for a second Python installation,"I recently installed Anaconda in my Windows. I did that to use some packages from some specific channels required by an application that is using Python 3.5 as its scripting language. +I adjusted my PATH variable to use Conda, pointing to the Python environment of the particular program, but now I would like to use Conda as well for a different Python installation that I have on my Windows. +When installing Anaconda then it isn't asking for a Python version to be related to. So, how can I use Conda to install into the other Python installation. Both Python installations are 'physical' installations - not virtual in any way.","Uninstall the other python installation and create different conda environments, that is what conda is great at. +Using conda from your anaconda installation to manage packages from another, independent python installation is not possible and not very feasible. +Something like this could serve your needs: + +Create one env for python 3.5 conda create -n py35 python=3.5 +Create one env for some other python version you would like to use, e.g. 3.6: conda create -n py36 python=3.6 +Use conda activate py35, conda deactivate, conda activate py36 to switch between your virtual environments.",1.2,True,1,6319 +2019-09-26 14:54:39.137,S3 file to Mysql AWS via Airflow,"I been learning how to use Apache-Airflow the last couple of months and wanted to see if anybody has any experience with transferring CSV files from S3 to a Mysql database in AWS(RDS). Or from my Local drive to MySQL. +I managed to send everything to an S3 bucket to store them in the cloud using airflow.hooks.S3_hook and it works great. I used boto3 to do this. +Now I want to push this file to a MySQL database I created in RDS, but I have no idea how to do it. Do I need to use the MySQL hook and add my credentials there and then write a python function? +Also, It doesn't have to be S3 to Mysql, I can also try from my local drive to Mysql if it's easier. +Any help would be amazing!","were you able to resolve the 'MySQLdb._exceptions.OperationalError: (2068, 'LOAD DATA LOCAL INFILE file request rejected due to restrictions on access' issue",0.0,False,1,6320 +2019-09-27 16:26:03.963,Change column from Pandas date object to python datetime,"I have a dataset with the first column as date in the format: 2011-01-01 and type(data_raw['pandas_date']) gives me pandas.core.series.Series +I want to convert the whole column into date time object so I can extract and process year/month/day from each row as required. +I used pd.to_datetime(data_raw['pandas_date']) and it printed output with dtype: datetime64[ns] in the last line of the output. I assume that values were converted to datetime. +but when I run type(data_raw['pandas_date']) again, it still says pandas.core.series.Series and anytime I try to run .dt function on it, it gives me an error saying this is not a datetime object. +So, my question is - it looks like to_datetime function changed my data into datetime object, but how to I apply/save it to the pandas_date column? I tried +data_raw['pandas_date'] = pd.to_datetime(data_raw['pandas_date']) +but this doesn't work either, I get the same result when I check the type. Sorry if this is too basic.","type(data_raw['pandas_date']) will always return pandas.core.series.Series, because the object data_raw['pandas_date'] is of type pandas.core.series.Series. What you want is to get the dtype, so you could just do data_raw['pandas_date'].dtype. + +data_raw['pandas_date'] = pd.to_datetime(data_raw['pandas_date']) + +This is correct, and if you do data_raw['pandas_date'].dtype again afterwards, you will see that it is datetime[64].",1.2,True,1,6321 +2019-09-28 00:05:03.313,Using BFS/DFS To Find Path With Maximum Weight in Directed Acyclic Graph,"You have a 2005 Honda Accord with 50 miles (weight max) left in the tank. Which McDonalds locations (graph nodes) can you visit within a 50 mile radius? This is my question. +If you have a weighted directed acyclic graph, how can you find all the nodes that can be visited within a given weight restriction? +I am aware of Dijkstra's algorithm but I can't seem to find any documentation of its uses outside of min-path problems. In my example, theres no node in particular that we want to end at, we just want to go as far as we can without going over the maximum weight. It seems like you should be able to use BFS/DFS in order to solve this, but I cant find documentation for implementing those in graphs with edge weights (again, outside of min-path problems).","Finding the longest path to a vertex V (a McDonald's in this case) can be accomplished using topological sort. We can start by sorting our nodes topologically, since sorting topologically will always return the source node U, before the endpoint, V, of a weighted path. Then, since we would now have access to an array in which each source vertex precedes all of its adjacent vertices, we can search through every path beginning with vertex U and ending with vertex V and set a value in an array with an index corresponding to U to the maximum edge weight we find connecting U to V. If the sum of the maximal distances exceeds 50 without reaching a McDonalds, we can backtrack and explore the second highest weight path going from U to V, and continue backtracking should we exhaust every path exiting from vertex U. Eventually we will arrive at a McDonalds, which will be the McDonalds with the maximal distance from our original source node while maintaining a total spanning distance under 50.",0.0,False,2,6322 +2019-09-28 00:05:03.313,Using BFS/DFS To Find Path With Maximum Weight in Directed Acyclic Graph,"You have a 2005 Honda Accord with 50 miles (weight max) left in the tank. Which McDonalds locations (graph nodes) can you visit within a 50 mile radius? This is my question. +If you have a weighted directed acyclic graph, how can you find all the nodes that can be visited within a given weight restriction? +I am aware of Dijkstra's algorithm but I can't seem to find any documentation of its uses outside of min-path problems. In my example, theres no node in particular that we want to end at, we just want to go as far as we can without going over the maximum weight. It seems like you should be able to use BFS/DFS in order to solve this, but I cant find documentation for implementing those in graphs with edge weights (again, outside of min-path problems).","For this problem, you will want to run a DFS from the starting node. Recurse down the graph from each child of the starting node until a total weight of over 50 is reached. If a McDonalds is encountered along the traversal record the node reached in a list or set. By doing so, you will achieve the most efficient algorithm possible as you will not have to create a complete topological sort as the other answer to this question proposes. Even though this algorithm still technically runs in O(ElogV) time, by recursing back on the DFS when a path distance of over 50 is reached you avoid traversing through the entire graph when not necessary.",0.0,False,2,6322 +2019-09-29 23:15:06.167,How does Qt Designer work in terms of creating more than 1 dialog per file?,"I'm starting to use Qt Designer. +I am trying to create a game, and the first task that I want to do is to create a window where you have to input the name of the map that you want to load. If the map exists, I then switch to the main game window, and if the name of the map doesn't exist, I want to display a popup window that tells the user that the name of the map they wrote is not valid. +I'm a bit confused with the part of showing the ""not valid"" pop-up window. +I realized that I have two options: + +Creating 2 separated .ui files, and with the help of the .show() and .hide() commands show the correspoding window if the user input is invalid. +The other option that I'm thinking of creating both windows in the same .ui file, which seems to be a better option, but I don't really know how to work with windows that come from the same file. Should I create a separate class for each of the windows that come from the Qt Designer file? If not, how can I access both windows from the same class?","Your second option seems impossible, it would be great to share the .ui since in my years that I have worked with Qt Designer I have not been able to implement what you point out. +An .ui is an XML file that describes the elements and their properties that will be used to create a class that is used to fill a particular widget. So considering the above, your second option is impossible. +This concludes that the only viable option is its first method.",1.2,True,1,6323 +2019-10-01 02:27:00.000,Start at 100 and count up till 999,"So, this is for my assignment and I have to create a flight booking system. One of the requirements is that it should create 3 digit passenger code that does not start with zeros (e.g. 100 is the smallest acceptable value) and I have no idea how I can do it since I am a beginner and I just started to learn Python. I have made classes for Passenger, Flight, Seating Area so far because I just started on it today. Please help. Thank you.","I like list comprehension for making a list of 100 to 999: +flights = [i for i in range(100, 1000)] +For the random version, there is probably a better way, but Random.randint(x, y) creates a random in, inclusive of the endpoints: +from random import Random +rand = Random() +flight = rand.randint(100,999) +Hope this helps with your homework, but do try to understand the assignment and how the code works...lest you get wrecked on the final!",0.0,False,1,6324 +2019-10-01 07:26:35.203,String problem / Select all values > 8000 in pandas dataframe,"I want to select all values bigger than 8000 within a pandas dataframe. +new_df = df.loc[df['GM'] > 8000] +However, it is not working. I think the problem is, that the value comes from an Excel file and the number is interpreted as string e.g. ""1.111,52"". Do you know how I can convert such a string to float / int in order to compare it properly?","You can see value of df.dtypes to see what is the type of each column. Then, if the column type is not as you want to, you can change it by df['GM'].astype(float), and then new_df = df.loc[df['GM'].astype(float) > 8000] should work as you want to.",0.2012947653214861,False,1,6325 +2019-10-03 19:17:11.890,Can we detect multiple objects in image using caltech101 dataset containing label wise images?,"I have a caltech101 dataset for object detection. Can we detect multiple objects in single image using model trained on caltech101 dataset? +This dataset contains only folders (label-wise) and in each folder, some images label wise. +I have trained model on caltech101 dataset using keras and it predicts single object in image. Results are satisfactory but is it possible to detect multiple objects in single image? +As I know some how regarding this. for detecting multiple objects in single image, we should have dataset containing images and bounding boxes with name of objects in images. +Thanks in advance","The dataset can be used for detecting multiple objects but with below steps to be followed: + +The dataset has to be annotated with bounding boxes on the object present in the image +After the annotations are done, you can use any of the Object detectors to do transfer learning and train on the annotated caltech 101 dataset + +Note: - Without annotations, with just the caltech 101 dataset, detecting multiple objects in a single image is not possible",1.2,True,1,6326 +2019-10-04 13:40:16.797,Data type to save expanding data for data logging in Python,"I am writing a serial data logger in Python and am wondering which data type would be best suited for this. Every few milliseconds a new value is read from the serial interface and is saved into my variable along with the current time. I don't know how long the logger is going to run, so I can't preallocate for a known size. +Intuitively I would use an numpy array for this, but appending / concatenating elements creates a new array each time from what I've read. +So what would be the appropriate data type to use for this? +Also, what would be the proper vocabulary to describe this problem?","Python doesn't have arrays as you think of them in most languages. It has ""lists"", which use the standard array syntax myList[0] but unlike arrays, lists can change size as needed. using myList.append(newItem) you can add more data to the list without any trouble on your part. +Since you asked for proper vocabulary in a useful concept to you would be ""linked lists"" which is a way of implementing array like things with varying lengths in other languages.",0.0,False,1,6327 +2019-10-04 20:01:45.247,How do you push in pycharm if the commit was already done?,Once you commit in pycharm it takes you to a second window to go through with the push. But if you only hit commit and not commit/push then how do you bring up the push option. You can't do another commit unless changes are made.,In the upper menu [VCS] -> [Git...] -> [Push],0.6730655149877884,False,1,6328 +2019-10-06 17:33:10.463,ModuleNotFoundError: No module named 'telegram',"Trying to run the python-telegram-bot library through Jupyter Notebook I get this question error. I tried many ways to reinstall it, but nothing from answers at any forums helped me. What should be a mistake and how to avoid it while installing?","Do you have a directory with ""telegram"" name? If you do,rename your directory and try it again to prevent import conflict. +good luck:)",0.3869120172231254,False,1,6329 +2019-10-07 20:48:55.507,argparse.print_help() ArgumentParser message string,"I am writing a slack bot, and I am using argsparse to parse the arguments sent into the slackbot, but I am trying to figure out how to get the help message string so I can send it back to the user via the slack bot. +I know that ArgumentParser has a print_help() method, but that is printed via console and I need a way to get that string.",I just found out that there's a method called format_help() that generates that help string,0.3869120172231254,False,1,6330 +2019-10-07 22:25:21.107,"Is it possible to have a c++ dll run a python program in background and have it populate a map of vectors? If so, how?","There will be an unordered_map in c++ dll containing some 'vectors' mapped to its 'names'. For each of these 'names', the python code will keep on collecting data from a web server every 5 seconds and fill the vectors with it. +Is such a dll possible? If so, how to do it?","You can make the Python code into an executable. Run the executable file from the DLL as a separate process and communicate with it via TCP localhost socket - or some other Windows utility that allows to share data between different processes. +That's a slow mess. I agree, but it works. +You can also embed Python interpreter and run the script it on the dll... I suppose.",0.0,False,1,6331 +2019-10-08 00:10:57.677,What is the difference between spline filtering and spline interpolation?,"I'm having trouble connecting the mathematical concept of spline interpolation with the application of a spline filter in python. My very basic understanding of spline interpolation is that it's fitting the data in a piece-wise fashion, and the piece-wise polynomials fitted are called splines. But its applications in image processing involve pre-filtering the image and then performing interpolation, which I'm having trouble understanding. +To give an example, I want to interpolate an image using scipy.ndimage.map_coordinates(input, coordinates, prefilter=True), and the keyword prefilter according to the documentation: + +Determines if the input array is prefiltered with spline_filter before interpolation + +And the documentation for scipy.ndimage.interpolation.spline_filter simply says the input is filtered by a spline filter. So what exactly is a spline filter and how does it alter the input data to allow spline interpolation?","I'm guessing a bit here. In order to calculate a 2nd order spline, you need the 1st derivative of the data. To calculate a 3rd order spline, you need the second derivative. I've not implemented an interpolation motor beyond 3rd order, but I suppose the 4th and 5th order splines will require at least the 3rd and 4th derivatives. +Rather than recalculating these derivatives every time you want to perform an interpolation, it is best to calculate them just once. My guess is that spline_filter is doing this pre-calculation of the derivatives which then get used later for the interpolation calculations.",0.3869120172231254,False,1,6332 +2019-10-08 08:59:39.373,How to show a highlighted label when The mouse is on widget,"I need to know how to make a highlighted label(or small box )appears when the mouse is on widget like when you are using browser and put the mouse on (reload/back/etc...) button a small box will appear and tell you what this button do +and i want that for any widget not only widgets on toolbar","As the comment of @ekhumoro says +setToolTip is the solution",1.2,True,1,6333 +2019-10-08 14:18:17.240,xmlsec1 not found on ibm-cloud deployment,"I am having hard time to install a python lib called python3-saml +To narrow down the problem I created a very simple application on ibm-cloud and I can deploy it without any problem, but when I add as a requirement the lib python3-saml +I got an exception saying: +pkgconfig.pkgconfig.PackageNotFoundError: xmlsec1 not found +The above was a deployment on ibm-cloud, but I did try to install the same python lib locally and I got the same error message, locally I can see that I have the xmlsec1 installed. +Any help on how to successfully deploy it on ibm-cloud using python3-saml? +Thanks in advance","I had a similar issue and I had to install the ""xmlsec1-devel"" on my CentOS system before installing the python package.",0.3869120172231254,False,1,6334 +2019-10-10 09:57:25.667,Using a function from a built-in module in your own module - Python,"I'm new with Python and new on Stackoverflow, so please let me know if this question should be posted somewhere else or you need any other info :). But I hope someone can help me out with what seems to be a rather simple mistake... +I'm working with Python in Jupyter Notebook and am trying to create my own module with some selfmade functions/loops that I often use. However, when I try to some of the functions from my module, I get an error related to the import of the built-in module that is used in my own module. +The way I created my own module was by: + +creating different blocks of code in a notebook and downloading it +as 'Functions.py' file. +saving this Functions.py file in the folder that i'm currently working in (with another notebook file) +in my current notebook file (where i'm doing my analysis), I import my module with 'import Functions'. + +So far, the import of my own module seems to work. However, some of my self-made functions use functions from built-in modules. E.g. my plot_lines() function uses math.ceil() somewhere in the code. Therefore, I imported 'math' in my analysis notebook as well. But when I try to run the function plot_lines() in my notebook, I get the error ""NameError: name 'math' is not defined"". +I tried to solve this error by adding the code 'import math' to the function in my module as well, but this did not resolve the issue. +So my question is: how can I use functions from built-in Python modules in my own modules? +Thanks so much in advance for any help!","If anyone encounters the same issue: +add 'import math' to your own module. +Make sure that you actually reload your adjusted module, e.g. by restarting your kernell!",0.0,False,1,6335 +2019-10-10 14:40:43.443,how to post-process raw images using rawpy to have the same effect with default output like ISP in camera?,"I use rawpy module in python to post-process raw images, however, no matter how I set the Params, the output is different from the default RGB in camera ISP, so anyone know how to operate on this please? +I have tried the following ways: +Default: +output = raw.postprocess() +Use Camera White balance: +output = raw.postprocess(use_camera_wb=True) +No auto bright: +output = raw.postprocess(use_camera_wb=True, no_auto_bright=True) +None of these could recover the RGB image as the camera ISP output.","The dcraw/libraw/rawpy stack is based on publicly available (reverse-engineered) documentation of the various raw formats, i.e., it's not using any proprietary libraries provided by the camera vendors. As such, it can only make an educated guess at what the original camera ISP would do with any given image. Even if you have a supposedly vendor-neutral DNG file, chances are the camera is not exporting everything there in full detail. +So, in general, you won't be able to get the same output.",0.0,False,1,6336 +2019-10-11 00:23:12.790,How does TF know what object you are finetuning for,"I am trying to improve mobilenet_v2's detection of boats with about 400 images I have annotated myself, but keep on getting an underfitted model when I freeze the graphs, (detections are random does not actually seem to be detecting rather just randomly placing an inference). I performed 20,000 steps and had a loss of 2.3. +I was wondering how TF knows that what I am training it on with my custom label map +ID:1 +Name: 'boat' +Is the same as what it regards as a boat ( with an ID of 9) in the mscoco label map. +Or whether, by using an ID of 1, I am training the models' idea of what a person looks like to be a boat? +Thank you in advance for any advice.","The model works with the category labels (numbers) you give it. The string ""boat"" is only a translation for human convenience in reading the output. +If you have a model that has learned to identify a set of 40 images as class 9, then giving it a very similar image that you insist is class 1 will confuse it. Doing so prompts the model to elevate the importance of differences between the 9 boats and the new 1 boats. If there are no significant differences, then the change in weights will find unintended features that you don't care about. +The result is a model that is much less effective.",0.0,False,2,6337 +2019-10-11 00:23:12.790,How does TF know what object you are finetuning for,"I am trying to improve mobilenet_v2's detection of boats with about 400 images I have annotated myself, but keep on getting an underfitted model when I freeze the graphs, (detections are random does not actually seem to be detecting rather just randomly placing an inference). I performed 20,000 steps and had a loss of 2.3. +I was wondering how TF knows that what I am training it on with my custom label map +ID:1 +Name: 'boat' +Is the same as what it regards as a boat ( with an ID of 9) in the mscoco label map. +Or whether, by using an ID of 1, I am training the models' idea of what a person looks like to be a boat? +Thank you in advance for any advice.","so I managed to figure out the issue. +We created the annotation tool from scratch and the issue that was causing underfitting whenever we trained regardless of the number of steps or various fixes I tried to implement was that When creating bounding boxes there was no check to identify whether the xmin and ymin coordinates were less than the xmax and ymax I did not realize this would be such a large issue but after creating a very simple check to ensure the coordinates are correct training ran smoothly.",0.0,False,2,6337 +2019-10-11 00:57:45.870,Warehouse routes between each started workorder in production order,"I'm working with odoo11 community version and currently I have some problem. +This is my exmplanation of problem: +In company I have many workcenters, and for each workcenter: +1) I want to create separate warehouse for each workcenter +or +2) Just 1 warehouse but different storage areas for each workcenter +(currently I made second option) and each workcenter have their own operation type: Production +Now my problem started, There are manufacturing orders and each manufacturing order have few workorders, And I want to do something that when some workorder is started then products are moved to this workcenter's warehouse/storage area and they are there untill next workorders using different workcenter starting then product are moved to next workcenter warehouse/storage area. +I can only set that after creating new sale order production order is sent to first Workcenter storage area and he is ther untill all workorders in production order are finished, I don't know how to trigger move routes between workcenters storage areas. for products that are still in production stage +Can I do this from odoo GUI, or maybe I need to do this somewhere in code?","Ok, I found my answer, which is that to accomplish what I wanted I need to use Manufacturing with Multi levell Bill of material, it working in way that theoretically 3 steps manufacturing order is divided into 3 single manufacture orders with 1 step each, and for example 2 and 3 prodcution order which before were 2 and 3 step are using as components to produce product that are finished in previous step which now is individual order.",1.2,True,1,6338 +2019-10-11 03:40:50.427,How to Connect Django with Python based Crawler machine?,"Good day folks +Recently, I made a python based web crawler machine that scrapes_ some news ariticles and django web page that collects search title and url from users. +But I do not know how to connect the python based crawler machine and django web page together, so I am looking for the any good resources that I can reference. +If anyone knows the resource that I can reference, +Could you guys share those? +Thanks","There are numerous ways you could do this. +You could directly integrate them together. Both use Python, so the scraper would just be written as part of Django. +You could have the scraper feed the data to a database and have Django read from that database. +You could build an API from the scraper to your Django implementation. +There are quite a few options for you depending on what you need.",1.2,True,1,6339 +2019-10-11 08:52:05.923,Is it possible to make a mobile app in Django?,"I was wondering if it is possible for me to use Django code I have for my website and somehow use that in a mobile app, in a framework such as, for example, Flutter. +So is it possible to use the Django backend I have right now and use it in a mobile app? +So like the models, views etc...","Yes. There are a couple ways you could do it + +Use the Django Rest Framework to serve as the backend for something like React Native. +Build a traditional website for mobile and then run it through a tool like PhoneGap. +Use the standard Android app tools and use Django to serve and process data through API requests.",1.2,True,1,6340 +2019-10-11 09:16:29.590,how to simulate mouse hover in robot framework on a desktop application,"Can anyone please let me know how to simulate mouse hover event using robot framework on a desktop application. I.e if I mouse hover on a specific item or an object, the sub menus are listed and i need to select one of the submenu item.","It depends on the automation library that you are using to interact with the Desktop application. +The normal approach is the following: + +Find the element that you want to hover on (By ID or some other unique locator) +Get the attribute position of the element (X,Y) +Move your mouse to that position. + +In this way you don´t ""hardcode"" the x,y position what will make your test case flaky.",0.0,False,1,6341 +2019-10-11 13:46:11.070,I have a network with 3 features and 4 vector outputs. How is MSE and accuracy metric calculated?,I understand how it works when you have one column output but could not understand how it is done for 4 column outputs.,"It’s not advised to calculate accuracy for continuous values. For such values you would want to calculate a measure of how close the predicted values are to the true values. This task of prediction of continuous values is known as regression. And generally R-squared value is used to measure the performance of the model. +If the predicted output is of continuous values then mean square error is the right option +For example: +Predicted o/p vector1-----> [2,4,8] and +Actual o/p vector1 -------> [2,3.5,6] +1.Mean square error is sqrt((2-2)^2+(4-3.5)^2+(8-6)^2 ) +2.Mean absolute error..etc. +(2)if the output is of classes then accuracy is the right metric to decide on model performance +Predicted o/p vector1-----> [0,1,1] +Actual o/p vector1 -------> [1,0,1] +Then accuracy calculation can be done with following: +1.Classification Accuracy +2.Logarithmic Loss +3.Confusion Matrix +4.Area under Curve +5.F1 Score",0.3869120172231254,False,1,6342 +2019-10-11 13:57:41.357,What are the types of Python operators?,"I tried type(+) hoping to know more about how is this operator represented in python but i got SyntaxError: invalid syntax. +My main problem is to cast as string representing an operation :""3+4"" into the real operation to be computed in Python (so to have an int as a return: 7). +I am also trying to avoid easy solutions requiring the os library if possible.","Operators don't really have types, as they aren't values. They are just syntax whose implementation is often defined by a magic method (e.g., + is defined by the appropriate type's __add__ method). +You have to parse your string: + +First, break it down into tokens: ['3', '+', '4'] +Then, parse the token string into an abstract syntax tree (i.e., something at stores the idea of + having 3 and 4 as its operands). +Finally, evaluate the AST by applying functions stored at a node to the values stored in its children.",1.2,True,1,6343 +2019-10-12 16:46:51.550,How to rotate a object trail in vpython?,I want to write a program to simulate 5-axis cnc gcode with vpython and I need to rotate trail of the object that's moving. Any idea how that can be done?,"It's difficult to know exactly what you need, but if instead of using ""make_trail=True"" simply create a curve object to which you append points. A curve object named ""c"" can be rotated using the usual way to rotate an object: c.rotate(.....).",0.0,False,1,6344 +2019-10-13 10:37:11.607,How to extract/cut out parts of images classified by the model?,"I am new to deep learning, I was wondering if there is a way to extract parts of images containing the different label and then feed those parts to different model for further processing? +For example,consider the dog vs cat classification. +Suppose the image contains both cat and dog. +We successfully classify that the image contains both, but how can we classify the breed of the dog and cat present? +The approach I thought of was,extracting/cutting out the parts of the image containing dog and cat.And then feed those parts to the respective dog breed classification model and cat breed classification model separately. +But I have no clue on how to do this.","Your thinking is correct, you can have multiple pipelines based on the number of classes. + +Training: +Main model will be an object detection and localization model like Faster RCNN, YOLO, SSD etc trained to classify at a high level like cat and dog. This pipeline provides you bounding box details (left, bottom, right, top) along with the labels. +Sub models will be multiple models trained on a lover level. For example a model that is trained to classify breed. This can be done by using models like vgg, resnet, inception etc. You can utilize transfer learning here. +Inference: Pass the image through Main model, crop out the detection objects using bounding box details (left, bottom, right, top) and based on the label information, feed it appropriate sub model and extract the results.",1.2,True,1,6345 +2019-10-13 14:56:02.397,Creating dask_jobqueue schedulers to launch on a custom HPC,"I'm new to dask and trying to use it in our cluster which uses NC job scheduler (from Runtime Design Automation, similar to LSF). I'm trying to create an NCCluster class similar to LSFCluster to keep things simple. +What are the steps involved in creating a job scheduler for custom clusters? +Is there any other way to interface dask to custom clusters without using JobQueueCluster? +I could find info on how to use the LSFCluster/PBSCluster/..., but couldn't find much information on creating one for a different HPC. +Any links to material/examples/docs will help +Thanks","Got it working after going through the source code. +Tips for anyone trying: + +Create a customCluster & customJob class similar to LSFCluster & LSFJob. +Override the following + + +submit_command +cancel_command +config_name (you'll have to define it in the jobqueue.yaml) +Depending on the cluster, you may need to override the _submit_job, _job_id_from_submit_ouput and other functions. + + +Hope this helps.",1.2,True,1,6346 +2019-10-13 23:43:47.973,How to run a python script using an anaconda virtual environment on mac,"I am trying to get some code working on mac and to do that I have been using an anaconda virtual environment. I have all of the dependencies loaded as well as my script, but I don't know how to execute my file in the virtual environment on mac. The python file is on my desktop so please let me know how to configure the path if I need to. Any help?",If you have a terminal open and are in your virtual environment then simply invoking the script should run it in your environment.,1.2,True,1,6347 +2019-10-14 15:59:45.917,Dynamically Injecting User Input Values into Python code on AWS?,"I am trying to deploy a Python webapp on AWS that takes a USERNAME and PASSWORD as input from a user, inputs them into a template Python file, and logs into their Instagram account to manage it automatically. +In Depth Explanation: +I am relatively new to AWS and am really trying to create an elaborate project so I can learn. I was thinking of somehow receiving the user input on a simple web page with two text boxes to input their Instagram account info (username & pass). Upon receiving this info, my instinct tells me that I could somehow use Lambda to quickly inject it into specific parts of an already existing template.py file, which will then be taken and combined with the rest of the source files to run the code. These source files could be stored somewhere else on AWS (S3?). I was thinking of running this using Elastic Beanstalk. +I know this is awfully involved, but my main issue is this whole dynamic injection thing. Any ideas would be so greatly appreciated. In the meantime, I will be working on it.","One way in which you could approach this would be have a hosted website on a static s3 bucket. Then, when submitting a request, goes to an API Gateway POST endpoint, This could then trigger a lambda (in any language of choice) passing in the two values. +This would then be passed into the event object of the lambda, you could store these inside secrets manager using the username as the Key name so you can reference it later on. Storing it inside a file inside a lambda is not a good approach to take. +Using this way you'd learn some key services: + +S3 + Static website Hosting +API Gateway +Lambdas +Secrets Manager + +You could also add alias's/versions to the lambda such as dev or production and same concept to API Gateways with stages to emulate doing a deployment. +However there are hundreds of different ways to also design it. And this is only one of them!",0.0,False,1,6348 +2019-10-14 18:35:11.307,how do I locate the btn by class name?,"I have this html code: + +I am trying to locate all the elements that meet this class with phyton, and selenium webdriver library: +likeBtn = driver.find_elements_by_class_name('_2ic5v') +but when I print +likeBtn +it prints +[] +I want to locate all of the buttons that much this div/span class, or aria-label +how do I do that successfully? Thanks in advance +update - when I do copy Xpath from page the print stays the same","Is it button class name dynamic or static? +How if you try choose By.CssSelector? +You can find element by copy selector in element",0.0,False,1,6349 +2019-10-15 06:25:59.843,Trying to find text in an article that may contain quotation marks,"I'm using python's findall function with a reg expression that should work but can't get the function to output results with quotation marks in them ('""). +This is what I tried: +Description = findall('

([A-Za-z ,\.\—'"":;0-9]+).

\n', text) +The quotation marks inside the reg expression are creating the hassle and I have no idea how to get around it.",Placing the backslash before the single quote like Sachith Rukshan suggested makes it work,1.2,True,1,6350 +2019-10-16 08:45:58.897,How to design realtime deeplearnig application for robotics using python?,"I have created a machine learning software that detects objects(duh!), processes the objects based on some computer vision parameters and then triggers some hardware that puts the object in the respective bin. The objects are placed on a conveyer belt and a camera is mounted at a point to snap pictures of objects(one object at a time) when they pass beneath the camera. I don't have control over the speed of the belt. +Now, the challenge is that I have to configure a ton of things to make the machine work properly. +The first problem is the time model takes to create segmentation masks, it varies from one object to another. +Another issue is how do I maintain signals that are generated after computer vision processing, send them to actuators in a manner that it won't get misaligned with the computer vision-based inferencing. +My initial design includes creating processes responsible for a specific task and then make them communicate with one other as per the necessity. However, the problem of synchronization still persists. +As of now, I am thinking of treating the software stack as a group of services as we usually do in backend and make them communicate using something like celery and Redis queue. +I am a kind of noob in system design, come from a background of data science. I have explored python's multithreading module and found it unusable for my purpose(all threads run on single core). I am concerned if I used multiprocessing, there could be additional delays in individual processes due to messaging and thus, that would add another uncertainty to the program. +Additional Details: + +Programming Frameworks and Library: Tensorflow, OpenCV and python +Camera Resolution: 1920P +Maximum Accutuation Speed: 3 triggers/second +Deep Learning Models: MaskRCNN/UNet + +P.S: You can also comment on the technologies or the keywords I should search for because a vanilla search yields nothing good.","Let me summarize everything first. + +What you want to do + +The ""object"" is on the conveyer belt +The camera will take pictures of the object +MaskRCNN will run to do the analyzing + +Here are some problems you're facing + +""The first problem is the time model takes to create segmentation masks, it varies from one object to another."" + +-> if you want to reduce the processing time for each image, then an accelerator (FPGA, Chip, etc) or some acceleration technique is needed. Intel OpenVino and Intel DL stick is a good start. +-> if there are too many pictures to process then you'll have 2 choices: 1) put a lot of machines so all the job can be done or 2) select only the important job and discard others. The fact that you set the ""Maximum Accutuation"" to a fixed number (3/sec) made me think that this is the problem you're facing. A background subtractor is a good start for creating images capture triggers. + +""Another issue is how do I maintain signals that are generated after computer vision processing, send them to actuators in a manner that it won't get misaligned with the computer vision-based inferencing."" + +-> a ""job distributor"" like Celery is good choice here. If the message is stacked inside the broker (Redis), then some tasks will have to wait. But this can easily by scaling up your computer. + +Just a few advice here: + +a vision system also includes the hardware parts, so a hardware specification is a must. +Clarify the requirements +Impossible things do exist, so sometimes you could reduce some factors (reliable, cost) of your project.",1.2,True,1,6351 +2019-10-16 13:41:40.667,Is there another way to plot a graph in python without matplotlib?,"As the title says, that's basically it. I have tried to install matplotlib already but: + +I am on Windows and ""sudo"" doesn't work +Every solution and answers on Stack Overflow regarding matplotlib (or some other package) not being able to be installed doesn't work for me... +I get ""Error Code 1"" + +So! Is there any other way to plot a graph in python without matplotlib? If not, can I have help with how to install matplotlib, successfully?",in cmd (coammand prompt) type pip install matplotlib,-0.3869120172231254,False,1,6352 +2019-10-17 06:41:12.867,File related operations python subprocess vs. native python,"I have a simple task I want to perform over ssh: return all files from a given file list that do not exist. +The way I would go about doing this would be to wrap the following in an ssh session: +for f in $(files); do stat $f > /dev/null ;done +The stdout redirect will ignore all good files and then reading the stderr will give me a list of all non found files. +I first thought of using this bash code with the ssh part inside a subprocess.run(..., shell=True) but was discouraged to do so. Instead,paramikowas suggested. +I try to understand why and when native python is better than subprocessing bash + +Computability with different OS (not an issue for me as the code is pretty tightly tied to Ubuntu) +Error and exception handling - this one I do get and think it's important, though catching an exception or exit code from subprocess is kinda easy too + +The con in my eyes with native python is the need to involve somewhat complicated modules such as paramiko when bash's ssh and stat seem to me as more plain and easy to use +Are there any guidelines for when and how to choose bash over python? +This question is mainly about using a command over ssh, but is relevant for any other command that bash is doing in a short and easy way and python wraps","There are really three choices here: doing something in-process (like paramiko), running ssh directly (with subprocess), and running ssh with the shell (also with subprocess). As a general rule, avoid running the shell programmatically (as opposed to, say, upon interactive user request). +The reason is that it’s a human-oriented interface (thus the easy separation of words with spaces and shortcuts for $HOME and globbing) that is vastly underpowered as an API. Consider, for example, how your code would detect that ssh was missing: the situation doesn’t arise with paramiko (so long as it is installed), is obvious with subprocess, and is just an (ambiguous) exit code and stderr message from the shell. Also consider how you supply the command to run: it already must be a command suitable for the shell (due to limitations in the SSH protocol), but if you invoke ssh with the shell it must be encoded (sometimes called “doubly escaped”) so as to have the local shell’s interpretation be the desired multi-word command for the remote shell. +So far, paramiko and subprocess are pretty much equivalent. As a more difficult case, consider how a key verification failure would manifest: paramiko would describe the failure as data, whereas the others would attempt to interact with the user (which might or might not be present). paramiko also supports opening multiple channels over one authenticated connection; ssh does so as well but only via a complicated ControlMaster configuration involving Unix socket files (which might not have any good place to exist in some deployments). Speaking of configuration, you may need to pass -F to avoid complications from the user’s .ssh/config if it is not designed with this automated use case in mind. +In summary, libraries are designed for use cases like yours, and so it should be no surprise that they work better, especially for edge cases, than assembling your own interface from human-oriented commands (although it is very useful that such manual compositions are possible!). If installing a non-standard dependency like paramiko is a burden, at least use subprocess directly; cutting out the second shell is already a great improvement.",1.2,True,1,6353 +2019-10-17 13:02:33.333,Auto activate virtual environment in Visual Studio Code,"I want VS Code to turn venv on run, but I can't find how to do that. +I already tried to add to settings.json this line: + +""terminal.integrated.shellArgs.windows"": [""source${workspaceFolder}\env\Scripts\activate""] + +But, it throws me an 127 error code. I found what 127 code means. It means, Not found. But how it can be not found, if I see my venv folder in my eyes right now? +I think it's terminal fault. I'm using Win 10 with Git Bash terminal, that comes when you install Git to your machine.","This is how I did it in 2021: + +Enter Ctrl+Shift+P in your vs code. + +Locate your Virtual Environment: +Python: select interpreter > Enter interpreter path > Find + +Once you locate your virtual env select your python version: +your-virtual-env > bin > python3. + +Now in your project you will see .vscode directory created open settings.json inside of it and add: +""python.terminal.activateEnvironment"": true +don't forget to add comma before to separate it with already present key value pair. + +Now restart the terminal. + + +You should see your virtual environment activated automatically.",1.2,True,2,6354 +2019-10-17 13:02:33.333,Auto activate virtual environment in Visual Studio Code,"I want VS Code to turn venv on run, but I can't find how to do that. +I already tried to add to settings.json this line: + +""terminal.integrated.shellArgs.windows"": [""source${workspaceFolder}\env\Scripts\activate""] + +But, it throws me an 127 error code. I found what 127 code means. It means, Not found. But how it can be not found, if I see my venv folder in my eyes right now? +I think it's terminal fault. I'm using Win 10 with Git Bash terminal, that comes when you install Git to your machine.","There is a new flag that one can use: ""python.terminal.activateEnvironment"": true",0.573727155831378,False,2,6354 +2019-10-17 14:15:46.367,"Implement 1-ply, 2-ply or 3-ply search td-gammon","I've read some articles and most of them say that 3-ply improves the performance of the self-player train. +But what is this in practice? and how is that implemented?","There is stochasticity in the game because of the dice rolls, so one approach would be evaluate state positions by self play RL, and then while playing do a 2-ply search over all the possible dice combinations. That would be 36 + 6 i.e. 42 possible rolls, and then you have to make different moves that are available which increases the breath of the tree to an insane degree. I tried this and it failed because my Mac could not handle such computation. Instead what we could do is just randomize a few dice rolls and perform a MiniMax tree search with Alpha Beta pruning ( using the AfterState value function). +For a 1 ply search we just use the rolled dice, or if we want to predict the value before we roll the dice then we can simply loop over all the possible combinations. Then we just argmax over the afterstates.",0.0,False,1,6355 +2019-10-17 17:03:00.937,Most efficient way to execute 20+ SQL Files?,"I am currently overhauling a project here at work and need some advice. We currently have a morning checklist that runs daily and executes roughly 30 SQL files with 1 select statement each. This is being done in an excel macro which is very unreliable. These statements will be executed against an oracle database. +Basically, if you were re-implementing this project, how would you do it? I have been researching concurrency in python, but have not had any luck. We will need to capture the results and display them, so please keep that in mind.If more information is needed, please feel free to ask. +Thank you.","There are lots of ways depending on how long the queries run, how much data is output, are there input parameters and what is done to the data output. +Consider: +1. Don't worry about concurrency up front +2. Write a small python app to read in every *.sql file in a directory and execute each one. +3. Modify the python app to summarize the data output in the format that it is needed +4. Modify the python app to save the summary back into the database into a daily check table with the date / time the SQL queries were run. Delete all rows from the daily check table before inserting new rows +5. Have the Excel spreadsheet load it's data from that daily check table including the date / time the data was put in the table +6. If run time is slows, optimize the PL/SQL for the longer running queries +7. If it's still slow, split the SQL files into 2 directories and run 2 copies of the python app, one against each directory. +8. Schedule the python app to run at 6 AM in the Windows task manager.",0.6730655149877884,False,1,6356 +2019-10-18 20:56:03.203,How to write in discord with discord.py without receiving a message?,"I need to write some messages in discord with my bot, but I don't know how to do it. It seems that discord.py can't send messages autonomously. +Does anyone know how to do it?","I solved putting a while loop inside the function on_message. +So I need to send only a message and then my bot can write as many messages as he wants",0.0,False,1,6357 +2019-10-20 03:58:47.513,How can I cancel an active boto3 s3 file_download?,"I'm using boto3 to download files from an s3 bucket & I need to support canceling an active file transfer in my client UI - but I can't find how to do it. +There is a progress callback that I can use for transfer status, but I can not cancel the transfer from there. +I did find that boto3's s3transfer.TransferManager object has a .shutdown() member, but it is buggy (.shutdown() passes the wrong params to ._shutdown() a few lines below it) & crashes. +Is there another way to safely cancel an active file_download?","Can you kill the process associated with the file? +kill $(ps -ef | grep 'process-name' | awk '{print $2}')",0.2012947653214861,False,1,6358 +2019-10-20 13:24:41.453,How do I limit the number of times a character appears in a string in python?,"I'm a beginner, its been ~2 months since i started learning python. +I've written a code about a function that takes two strings, and outputs the common characters between those 2 strings. The issue with my code is that it returns all common characters that the two inputs have. For example: +input: common, moron +the output is ""oommoon"" when ideally it should be ""omn"". +i've tried using the count() function, and then the replace function, but it ended up completely replacing the letters that were appearing more than once in the output, as it should. +how should i go about this? i mean it's probably an easy solution for most of the ppl here, but what will the simplest approach be such that i, a beginner with okay-ish knowledge of the basics, understand it?","You can try this: +''.join(set(s1).intersection(set(s2)))",0.0,False,1,6359 +2019-10-20 20:53:03.697,How to iterate over a dictionary with tuples?,"So,I need to iterate over a dictionary in python where the keys are a tuple and the values are integers. +I only need to print out the keys and values. +I tried this: +for key,value in dict: +but didn't work because it assigned the first element of the tuple to the key and value and the second to the value. +So how should I do it?","Just use +for key in dict +and then access the value with dict[key]",0.1016881243684853,False,1,6360 +2019-10-21 08:36:05.530,how to use 1D-convolutional neural network for non-image data,"I have a dataset that I have loaded as a data frame in Python. It consists of 21392 rows (the data instances, each row is one sample) and 79 columns (the features). The last column i.e. column 79 has string type labels. I would like to use a CNN to classify the data in this case and predict the target labels using the available features. This is a somewhat unconventional approach though it seems possible. However, I am very confused on how the methodology should be as I could not find any sample code/ pseudo code guiding on using CNN for Classifying non-image data, either in Tensorflow or Keras. Any help in this regard will be highly appreciated. Cheers!","You first have to know, if it is sensible to use CNN for your dataset. You could use sliding 1D-CNN if the features are sequential eg) ECG, DNA, AUDIO. However I doubt that this is not the case for you. Using a Fully Connected Neural Net would be a better choice.",0.3869120172231254,False,1,6361 +2019-10-21 09:25:49.003,Training in Python and Deploying in Spark,"Is it possible to train an XGboost model in python and use the saved model to predict in spark environment ? That is, I want to be able to train the XGboost model using sklearn, save the model. Load the saved model in spark and predict in spark. Is this possible ? +edit: +Thanks all for the answer , but my question is really this. I see the below issues when I train and predict different bindings of XGBoost. + +During training I would be using XGBoost in python, and when  predicting I would be using XGBoost in mllib. +I have to load the saved model from XGBoost python (Eg: XGBoost.model file) to be predicted in spark, would this model be compatible to be used with the predict function in the mllib +The data input formats of both XGBoost in python and XGBoost in spark mllib are different. Spark takes vector assembled format but with python, we can feed the dataframe as such. So, how do I feed the data when I am trying to predict in spark with a model trained in python. Can I feed the data without vector assembler ? Would XGboost predict function in spark mllib take non-vector assembled data as input ?","you can + +load data/ munge data using pyspark sql, +then bring data to local driver using collect/topandas(performance bottleneck) +then train xgboost on local driver +then prepare test data as RDD, +broadcast the xgboost model to each RDD partition, then predict data in parallel + +This all can be in one script, you spark-submit, but to make the things more concise, i will recommend split train/test in two script. +Because step2,3 are happening at driver level, not using any cluster resource, your worker are not doing anything",0.0,False,2,6362 +2019-10-21 09:25:49.003,Training in Python and Deploying in Spark,"Is it possible to train an XGboost model in python and use the saved model to predict in spark environment ? That is, I want to be able to train the XGboost model using sklearn, save the model. Load the saved model in spark and predict in spark. Is this possible ? +edit: +Thanks all for the answer , but my question is really this. I see the below issues when I train and predict different bindings of XGBoost. + +During training I would be using XGBoost in python, and when  predicting I would be using XGBoost in mllib. +I have to load the saved model from XGBoost python (Eg: XGBoost.model file) to be predicted in spark, would this model be compatible to be used with the predict function in the mllib +The data input formats of both XGBoost in python and XGBoost in spark mllib are different. Spark takes vector assembled format but with python, we can feed the dataframe as such. So, how do I feed the data when I am trying to predict in spark with a model trained in python. Can I feed the data without vector assembler ? Would XGboost predict function in spark mllib take non-vector assembled data as input ?",You can run your python script on spark using spark-submit command so that can compile your python code on spark and then you can predict the value in spark.,0.0,False,2,6362 +2019-10-22 07:03:31.320,Converting the endianness type of an already existing binary file,"I have a binary file on my PC that contains data in big-endian. The file contains around 121 MB. +The problem is I would like to convert the data into little-endian with a python script. +What is currently giving me headaches is the fact that I don't know how to convert an entire file. If I would have a short hex string I could simply use struct.pack to convert it into little-endian but if I see this correctly I can't give struct.pack a binary file as input. +Is there an other function/utility that I can use to do that or how should my approach look like?","We need a document or knowledge of the file's exact structure. +Suppose that there is a 4 byte file. If this file has just a int, we need to flip that. But if it is a combination of 4 char, we should leave it as it be. +Above all, you should find the structure. Then we can talk about the translation. I think there is no translation tools to support general data, but you need to parse that binary file following the structure.",0.0,False,1,6363 +2019-10-24 17:06:41.350,"How to solve problem related to BigQueryError ""reason"": ""invalid"", ""location"": ""test"", ""debugInfo"": """", ""message"": ""no such field.""","Someone worked before with streaming data into (google) BigQuery using Google Cloud Functions (insert_rows_from_dataframe())? +My problem is it seems like sometimes the table schema is not updated immediately and when you try to load some data into table immediately after creation of a new field in the schema it returns an error: + +BigQueryError: [{""reason"": ""invalid"", ""location"": ""test"", ""debugInfo"": """", ""message"": ""no such field.""}]"" + +However, if I try to load again after few seconds it all works fine, so my question if someone knows the maximum period of time in seconds for this updating (from BigQuery side) and if is possible somehow to avoid this situation?","Because the API operation on BigQuery side is not atomic, you can't avoid this case. +You can only mitigate the impact of this behavior and perform a sleep, a retries, or set a Try-catch to replay the insert_rows_from_dataframe() several times (not infinite, in case of real problem, but 5 times for example) until it pass. +Nothing is magic, if the consistency is not managed on a side, the other side has to handle it!",0.3869120172231254,False,1,6364 +2019-10-24 18:04:12.393,Kivy_deps.glew.whl is not a supported wheel on this version,"I was trying to install kivy_deps.glew(version).whl with + +pip install absolute/path/to/file/kivy_deps.glew + +And I get this error: + +kivy_deps.glew(version).whl is not a supported wheel on this version + +I searched in the web and saw that some people said that the problem is because you shoud have python 2.7 and I have python 3.7. The version is of glew is cp27. So if this is the problem how to install python 2.7 and 3.7 in the same time and how to use both of them with pip.(i.e maybe you can use + +pip2.7 install + +For python 2.7 and + +pip install + +For python 3.7 +P.S: My PC doesn't have an internet connection that's why i'm installing it with a wheel file. I have installed all dependecies except glew and sdl2. If there is any unofficial file for these two files for python 3.7 please link them. +I know this question has been asked before in stackoverflow but I didn't get any solution from it(it had only 1 anwser tho) +Update: I uninstalled python 3.7 and installed python 2.7, but pip and python weren't commands in cmd because python 2.7 hadn't pip. So I reinstalled python 3.7",I fixed it. Just changed in the name of the file cp27 to cp37,1.2,True,1,6365 +2019-10-24 18:19:04.017,How to connect ML model which is made in python to react native app,"i made a one ML model in python now i want to use this model in react native app means that frontend will be based on react native and model is made on python,how can i connect both thing with each other",create a REST Api in flask/django to deploy your model on server.create end points for separate functions.Then call those end points in your react native app.Thats how it works.,0.1352210990936997,False,2,6366 +2019-10-24 18:19:04.017,How to connect ML model which is made in python to react native app,"i made a one ML model in python now i want to use this model in react native app means that frontend will be based on react native and model is made on python,how can i connect both thing with each other",You can look into the CoreMl library for react native application if you are developing for IOS platform else creating a restAPI is a good option. (Though some developers say that latency is an issue but it also depends on what kind of model and dataset you are using ).,0.0,False,2,6366 +2019-10-25 15:15:17.720,can pandas autocorr handle irregularly sample timeseries data?,"I have a dataframe with datetime index, where the data was sampled irregularly (the datetime index has gaps, and even where there aren't gaps the spacing between samples varies). +If I do: +df['my column'].autocorr(my_lag) +will this work? Does autocorr know how to handle irregularly sampled datetime data?","This is not quite a programming question. +Ideally, your measure of autocorrelation would use data measured at the same frequency/same time interval between observations. Any autocorr function in any programming package will simply measure the correlation between the series and whatever lag you want. It will not correct for irregular frequencies. +You would have to fix this yourself but 1) setting up a series with a regular frequency, 2) mapping the actual values you have to the date structure, 3) interpolating values where you have gaps/NaN, and then 4) running your autocorr. +Long story short, autocorr would not do all this work for you. +If I have misunderstood the problem you are worried about, let me know. It would be helpful to know a little more about the sampling frequencies. I have had to deal with things like this a lot.",0.0,False,1,6367 +2019-10-25 16:46:06.047,Should modules always contain a class?,"I'm writing a module which only contains functions. Is it good practice to put these inside a class, even if there are no class arguments and the __init__ function is pointless? And if so how should I write it?","It is good to build modules that contain a class for better organization and manipulation depending on how big the code is and how it will be used, but yes it is good to get use to building classes with methods in them. Can you post your code?",0.0,False,1,6368 +2019-10-26 03:37:29.547,Internet checksum -- Adding hex numbers together for checksum,"I came across the following example of creating an Internet Checksum: + +Take the example IP header 45 00 00 54 41 e0 40 00 40 01 00 00 0a 00 00 04 0a 00 00 05: + +Adding the fields together yields the two’s complement sum 01 1b 3e. +Then, to convert it to one’s complement, the carry-over bits are added to the first 16-bits: 1b 3e + 01 = 1b 3f. +Finally, the one’s complement of the sum is taken, resulting to the checksum value e4c0. + + +I was wondering how the IP header is added together to get 01 1b 3e?","The IP header is added together with carry in hexadecimal numbers of 4 digits. +i.e. the first 3 numbers that are added are 0x4500 + 0x0054 + 0x41e0 +...",0.2012947653214861,False,1,6369 +2019-10-27 18:36:01.290,Access to data in external hdd from jupyter notebook,"I am a python3 beginner, and I've been stuck on how to utilize my data at my scripts. +My data is stored in an external hdd and I am seeking for the way to retrieve the data to use on a program in jupyter notebook somehow. +Does anyone know how to make an access to external hdd?","Hard to say what the issue is without seeing any code. In general make sure your external hard drive is connected to your machine, and when loading your data (depends on what kind of data you want to use) specify the full path to your data.",1.2,True,1,6370 +2019-10-28 17:00:37.963,Scheduling Emails with Django?,"I want to schedule emails using Django. Example ---> I want to send registered users their shopping cart information everyday at 5:00 P.M. +How would I do this using Django? I have read a lot of articles on this problem but none of them have a clear and definite solution. I don't want to implement a workaround. +Whats the proper way of implementing this? Can this be done within my Django project or do I have to use some third-party service? +If possible, please share some code. Otherwise, details on how I can implement this will do.","There's no built-in way to do what you're asking. What you could do, though, is write a management command that sends the emails off and then have a crontab entry that calls that command at 5PM (this assumes your users are in the same timezone as your server). +Another alternative is using celery and celery-beat to create scheduled tasks, but that would require more work to set up.",0.3869120172231254,False,1,6371 +2019-10-28 17:46:00.680,Storing multiple values in one column,"I am designing a web application that has users becoming friends with other users. I am storing the users info in a database using sqlite3. +I am brainstorming on how I can keep track on who is friends with whom. +What I am thinking so far is; to make a column in my database called Friendships where I store the various user_ids( integers) from the user's friends. +I would have to store multiple integers in one column...how would I do that? +Is it possible to store a python list in a column? +I am also open to other ideas on how to store the friendship network information in my database.... +The application runs through FLASK","It is possible to store a list as a string into an sql column. +However, you should instead be looking at creating a Friendships table with primary keys being the user and the friend. +So that you can call the friendships table to pull up the list of friends. +Otherwise, I would suggest looking into a Graph Database, which handles this kind of things well too.",0.1352210990936997,False,2,6372 +2019-10-28 17:46:00.680,Storing multiple values in one column,"I am designing a web application that has users becoming friends with other users. I am storing the users info in a database using sqlite3. +I am brainstorming on how I can keep track on who is friends with whom. +What I am thinking so far is; to make a column in my database called Friendships where I store the various user_ids( integers) from the user's friends. +I would have to store multiple integers in one column...how would I do that? +Is it possible to store a python list in a column? +I am also open to other ideas on how to store the friendship network information in my database.... +The application runs through FLASK","What you are trying to do here is called a ""many-to-many"" relationship. Rather than making a ""Friendships"" column, you can make a ""Friendship"" table with two columns: user1 and user2. Entries in this table indicate that user1 has friended user2.",0.1352210990936997,False,2,6372 +2019-10-30 12:29:29.603,Display two animations at the same time with Manim,"Manim noobie here. +I am trying to run two animations at the same time, notably, I'm trying to display a dot transitioning from above ending up between two letters. Those two letters should create some space in between in the meantime. +Any advice on how to do so? Warm thanks in advance.","To apply two transformations at the same time, you can do self.play(Transformation1, Transformation2). This way, since the two Transformations are in the same play statement, they will run simultaneously.",1.2,True,1,6373 +2019-10-31 10:58:42.647,Bloomberg API how to get only the latest quote to a given time specified by the user in Python?,"I need to query from the BBG API the nearest quote to 14:00 o'clock for a number of FX currency pairs. I read the developers guide and I can see that reference data request provides you with the latest quote available for a currency however if I run the request at 14.15 it will give me the nearest quote to that time not 14.00. Historical and intraday data output too many values as I need only the latest quote to a given time. +Would you be able to advise me if there is a type of request which will give me what I am looking for.","Further to previous suggestions, you can start subscription to //blp/mktdata service before 14:00 for each instrument to receive stream of real-time ticks. Cache the last tick, when hitting 14:00 mark the cache as pre-14:00, then mark the first tick after as post:14, select the nearest to 14:00 from both.",0.0,False,1,6374 +2019-11-01 03:45:32.480,"In a Python bot, how to run a function only once a day?","I have a Python bot running PRAW for Reddit. It is open source and thus users could schedule this bot to run at any frequency (e.g. using cron). It could run every 10 minutes, or every 6 hours. +I have a specific function (let's call it check_logs) in this bot that should not run every execution of this bot, but rather only once a day. The bot does not have a database. +Is there a way to accomplish this in Python without external databases/files?","Generally speaking, it's better (and easier) to use the external database or file. But, if you absolutely need it you could also: + +Modify the script itself, e.g. store the date of the last run in commented out last line of the script. +Store the date of the last update on the web, for example, in your case it could be a Reddit post or google doc or draft email or a site like Pastebin, etc. +Change the ""modified date"" of the script itself and use it as a reference.",0.0,False,1,6375 +2019-11-01 12:00:44.503,how to solve fbs error 'Can not find path ./libshiboken2.abi3.5.13.dylib'?,"I have been able to freeze a Python/PySide2 script with fbs on macOS, and the app seems to work. +However, I got some errors from the freeze process stating: + +Can not find path ./libshiboken2.abi3.5.13.dylib. + +Does anyone know how to fix that?","Try to use the --runtime-tmpdir because while running the generated exe file it needs this file libshiboken2.abi3.5.13.dylib and unable hook that file. +Solution: use --add-data & --runtime-tmpdir to pyinstaller command line. +pyinstaller -F --add-data ""path/libshiboken2.abi3.5.13.dylib"":""**PATH"" +--runtime-tmpdir temp_dir_name your_program.py +here PATH = the directory name of that file looking for.-F = one file",0.0,False,1,6376 +2019-11-02 21:15:06.757,How to get to the first 4 numbers of an int number ? and also the 5th and 6th numbers for example,"I have a function that checks if a date ( int number ) that is written in this format: ""YYYYMMDD"" is valid or not. +My question is how do i get to the first 4 numbers for example ( the year )? +the month ( the 5th and 6th number ) and the days. +Thanks","Probably the easiest way would be to convert it to a string and use substrings or regular expressions. If you need performance, use a combination of modulo and division by powers of 10 to extract the desired parts.",0.2012947653214861,False,1,6377 +2019-11-02 21:21:16.990,Can aubio be used to detect rhythm-only segments?,"Does aubio have a way to detect sections of a piece of audio that lack tonal elements -- rhythm only? I tested a piece of music that has 16 seconds of rhythm at the start, but all the aubiopitch and aubionotes algorithms seemed to detect tonality during the rhythmic section. Could it be tuned somehow to distinguish tonal from non-tonal onsets? Or is there a related library that can do this?","Use a spectrum analyser to detect sections with high amplitude. If you program - you could take each section and make an average of the freqencies (and amplitudes) present to give you an idea of the instrument(s) involved in creating that amplitude peak. +Hope that helps - if you're using python I could give you some pointers how to program this!? +Regards +Tony",0.0,False,1,6378 +2019-11-03 23:03:00.293,Project organization with Tensorflow.keras. Should one subclass tf.keras.Model?,"I'm using Tensorflow 1.14 and the tf.keras API to build a number (>10) of differnet neural networks. (I'm also interested in the answers to this question using Tensorflow 2). I'm wondering how I should organize my project. +I convert the keras models into estimators using tf.keras.estimator.model_to_estimator and Tensorboard for visualization. I'm also sometimes using model.summary(). Each of my models has a number (>20) of hyperparameters and takes as input one of three types of input data. I sometimes use hyperparameter optimization, such that I often manually delete models and use tf.keras.backend.clear_session() before trying the next set of hyperparameters. +Currently I'm using functions that take hyperparameters as arguments and return the respective compiled keras model to be turned into an estimator. I use three different ""Main_Datatype.py"" scripts to train models for the three different input data types. All data is loaded from .tfrecord files and there is an input function for each data type, which is used by all estimators taking that type of data as input. I switch between models (i.e. functions returning a model) in the Main scripts. I also have some building blocks that are part of more than one model, for which I use helper functions returning them, piecing together the final result using the Keras functional API. +The slight incompatibilities of the different models are begining to confuse me and I've decided to organise the project using classes. I'm planing to make a class for each model that keeps track of hyperparameters and correct naming of each model and its model directory. However, I'm wondering if there are established or recomended ways to do this in Tensorflow. +Question: Should I be subclassing tf.keras.Model instead of using functions to build models or python classes that encapsulate them? Would subclassing keras.Model break (or require much work to enable) any of the functionality that I use with keras estimators and tensorboard? I've seen many issues people have with using custom Model classes and am somewhat reluctant to put in the work only to find that it doesn't work for me. Do you have other suggestions how to better organize my project? +Thank you very much in advance.","Subclass only if you absolutely need to. I personally prefer following the following order of implementation. If the complexity of the model you are designing, can not be achieved using the first two options, then of course subclassing is the only option left. + +tf.keras Sequential API +tf.keras Functional API +Subclass tf.keras.Model",1.2,True,1,6379 +2019-11-04 08:48:35.323,How to automate any application variable directly without GUI with Python?,"I need to automate some workflows to control some Mac applications, I have got a way to do this with Pyautogui module,but I don't want to simulate keyboard or mouse actions anymore, I think if I can get the variables under any GUI elements and program with them directly it would be better, how can I do this?","This is not possible unless the application has some kind of api. +For Web GUIs you can use Selenium and directly select the DOM elements.",0.3869120172231254,False,1,6380 +2019-11-04 20:54:43.360,Is it possible to use socketCAN protocol on MacOS,I am looking to connect to a car wirelessly using socketCAN protocol on MacOS using the module python-can on python3. I don't know how to install the socketCAN protocol on MacOS. Pls help.,"SocketCAN is implemented only for the Linux kernel. So it is not available on other operating systems. But as long as your CAN adapter is supported by python-can, you don't need SocketCAN.",0.0,False,1,6381 +2019-11-05 07:32:04.260,Is there any built-in functionality in django to call a method on a specific day of the month?,"Brief intro of the app: + +I'm working on MLM Webapp and want to make payment on every 15th and last day of every month. +Calculation effect for every user when a new user comes into the system. + +What I did [ research ] + +using django crontab extension +celery + +Question is: +-- Concern about the database insertion/update query: + +on the 15th-day hundreds of row generating with income calculation for users. so is there any better option to do that? +how to observe missed and failed query transaction? + +Please guide me, how to do this with django, Thanks to everyone!","For your 1st question, i don't think there will be any issue if you're using celery and celery beat for scheduling this task. Assuming your production server has 2 cores (so 4 threads hopefully), you can configure your celery worker (not the beat scheduler) to run using 1 worker with 1/2 thread. At the 15th of a month, beat will see that a task is due and will call your celery worker to accomplish this task. While doing this your worker will be using 1 thread and the other threads will be open (so your server won't go down). There are different ways to configure your celery worker depending on your use case (e.g. using gevent rather than regular thread), but the basic config should be fine. +Well I think you should keep a column in your table to track which ones were successfully handled by your code, and which failed. Celery dashboards will only show if total work succeeded or not, and won't give any further insights. +Hope this helps!",1.2,True,1,6382 +2019-11-05 12:45:32.743,Cluster identification with NN,"I have a dataframe containing the coordinates of millions of particles which I want to use to train a Neural network. These particles build individual clusters which are already identified and labeled; meaning that every particle is already assigned to its correct cluster (this assignment is done by a density estimation but for my purpose not that relevant). +the challenge is now to build a network which does this clustering after learning from the huge data. there are also a few more features in the dataframe like clustersize, amount of particles in a cluster etc. +since this is not a classification problem but more a identification of clusters-challenge what kind of neural network should i use? I have also problems to build this network: for example a CNN which classifies wheather there is a dog or cat in the picture, the output is obviously binary. so also the last layer just consists of two outputs which represent the probability for being 1 or 0. But how can I implement the last layer when I want to identify clusters? +during my research I heard about self organizing maps. would these networks do the job? +thank you","These particles build individual clusters which are already identified + and labeled; meaning that every particle is already assigned to its + correct cluster (this assignment is done by a density estimation but + for my purpose not that relevant). + the challenge is now to build a network which does this clustering + after learning from the huge data. + +Sounds pretty much like a classification problem to me. Images themselves can build clusters in their image space (e.g. a vector space of dimension width * height * RGB). + +since this is not a classification problem but more a identification + of clusters-challenge what kind of neural network should i use? + +You have data of coordinates, you have labels. Start with a simple fully connected single/multi-layer-perceptron i.e. vanilla NN, with as many outputs as number of clusters and softmax-activation function. +There are tons of blogs and tutorials for Deep Learning libraries like keras out there in the internet.",0.0,False,2,6383 +2019-11-05 12:45:32.743,Cluster identification with NN,"I have a dataframe containing the coordinates of millions of particles which I want to use to train a Neural network. These particles build individual clusters which are already identified and labeled; meaning that every particle is already assigned to its correct cluster (this assignment is done by a density estimation but for my purpose not that relevant). +the challenge is now to build a network which does this clustering after learning from the huge data. there are also a few more features in the dataframe like clustersize, amount of particles in a cluster etc. +since this is not a classification problem but more a identification of clusters-challenge what kind of neural network should i use? I have also problems to build this network: for example a CNN which classifies wheather there is a dog or cat in the picture, the output is obviously binary. so also the last layer just consists of two outputs which represent the probability for being 1 or 0. But how can I implement the last layer when I want to identify clusters? +during my research I heard about self organizing maps. would these networks do the job? +thank you","If you want to treat clustering as a classification problem, then you can try to train the network to predict whether two points belong to the same clusters or to different clusters. +This does not ultimately solve your problems, though - to cluster the data, this labeling needs to be transitive (which it likely will not be) and you have to label n² pairs, which is expensive. +Furthermore, because your clustering is density-based, your network may need to know about further data points to judge which ones should be connected...",0.2012947653214861,False,2,6383 +2019-11-05 20:27:30.517,Implementing a built in GUI with pymunk and pygame in Python?,"I am looking to make a python program in which I can have a sidebar GUI along with an interactive 2d pymunk workspace to the right of it, which is to be docked within the same frame. +Does anyone know how I might implement this?","My recommendation is to use pygame as your display. If an object is chosen, you can add it to the pymunk space at the same time as using pymunk to get each body's space and draw it onto the display. This is how I've written my games.",0.0,False,1,6384 +2019-11-06 17:07:27.240,Set PYTHONPATH for local Jupyter Notebook in VS Code,"I'm using Visual Studio 1.39.2 on Windows 10. I'm very happy that you can run Jupyter Notebook natively through VS Code as of October this year (2019), but one thing I don't get right is how to set my PYTHONPATH prior to booting up a local Jupyter server. +What I want is to be able to import a certain module which is located in another folder (because the module is compiled from C++ code). When I run a normal Python debugging session, I found out that I can set environment variables of the integrated terminal, via the setting terminal.integrated.env.linux. Thus, I set my PYTHNPATH through this option when debugging as normal. But when running a Jupyter Notebook, the local Jupyter server doesn't seem to run in the integrated terminal (at least not from what I can see), so it doesn't have the PYTHONPATH set. +My question is then, how can I automatically have the PYTHONPATH set for my local Jupyter Notebook servers in VS Code?","I'm a developer on this extension. If you have a specific path for module resolution we provide a setting for the Jupyter features called: +Python->Data Science: Run Startup Commands +That setting will run a series of python instructions in any Jupyter session context when starting up. In that setting you could just append that path that you need to sys.path directly and then it will run and add that path every time you start up a notebook or an Interactive Window session.",0.5457054096481145,False,1,6385 +2019-11-07 02:14:50.033,Script that opens cmd from spyder,I am working on a text adventure with python and the issue i am having is getting spyder to open a interactive cmd window. so far i have tried os.systems('cmd / k') to try and open this which it did but i could not get any code to run and kept getting an app could not run this file error. my current code runs off a import module that pulls the actual adventure from another source code file. how can i make it to where only one file runs and opens the cmd window to play the text adventure?,"(Spyder maintainer here) Cmd windows are hidden by default because there are some packages that open lot of them while running code (e.g. pyomo). +To change this behavior, you need to go to +Tools > Preferences > IPython console > Advanced settings > Windows adjustments +and deactivate the option called Hide command line output windows generated by the subprocess module.",0.2012947653214861,False,1,6386 +2019-11-07 08:11:10.283,Retrieving information from a POST without forms in Django,"I'm developing something like an API (more like a communications server? Idk what to call it!) to receive data from a POST message from an external app. Basically this other app will encounter an error, then it sends an error ID in a post message to my API, then I send off an email to the affected account. +My question is how do I handle this in Django without any form of UI or forms? I want this to pretty much be done quietly in the background. At most a confirmation screen that the email is sent. +I'm using a LAMP stack with Python/Django instead of PHP.","A Django view doesn't have to use a form. Everything that was POSTed is there in request.POST which you may access directly. (I commonly do this to see which of multiple submit buttons was clicked). +Forms are a good framework for validating the data that was POSTed, but you don't have to use their abilities to generate content for rendering. If the data is validated in the front-end, you can use the form validation framework to check against front-end coding errors and malicious POSTs not from your web page, and simply process the cleaned_data if form.is_valid() and do ""Something went wrong"" if it didn't (which you believe to be impossible, modulo front-end bugs or malice).",1.2,True,1,6387 +2019-11-07 08:18:43.410,PyFPDF can't add page while specifying the size,"on pyfpdf documentation it is said that it is possible to specify a format while adding a page (fpdf.add_page(orientation = '', format = '', same = False)) but it gives me an error when specifying a format. +error: + +pdf.add_page(format = (1000,100)) TypeError: add_page() got an + unexpected keyword argument 'format' + +i've installed pyfpdf via pip install and setup.py install but it doesnt work in both ways +how can i solve this?","Your problem is that two packages of pypdf exist, fpdf and fpdf2. They both use from fpdf import FPDF, but only fpdf2 has also a format= keyword in the add_page() method. +So you need to install the fpdf2 package.",0.2012947653214861,False,1,6388 +2019-11-07 11:18:08.470,Sharing variables between Python subprocesses,"I have a Python program named read.py which reads data from serial communication every second, and another python program called calculate.py which has to take the real time values from read.py. +Using subprocess.popen('read.py',shell=True) I am able to run read.py from calculate.py +May I know how to read or use the value from read.py in calculate.py? +Since the value changes every second I am confused how to proceed like, saving value in registers or producer consumer type, etc. +for example : from import datetime +when ever strftime %s is used, the second value is given +how to use the same technique to use variable from another script?",I can suggest writing values to a .txt file for later reading,0.3869120172231254,False,1,6389 +2019-11-07 18:11:15.747,Redeploying a Flask app in Google App Engine,"How do I redeploy an updated version of the Flask web app in Google App Engine. +For example, I have running web app and now there are new features added into it and needs redeployment. How can I do that? +Also how to remove the previous version.",Add --no-promote if you want to deploy without routing service to the latest version deployed.,0.0,False,1,6390 +2019-11-08 13:21:30.283,"Select a ""mature"" curve that best matches the slope of a new ""immature"" curve","I have a multitude of mature curves (days are plotted on X axis and data is >= 90 days old so the curve is well developed). +Once a week I get a new set of data that is anywhere between 0 and 14 days old. +All of the data (old and new), when plotted, follows a log curve (in shape) but with different slopes. So some weeks have a higher slope, curve goes higher, some smaller slope, curve is lower. At 90 days all curves flatten. +From the set of ""mature curves"" I need to select the one whose slope matches the best the slope of my newly received date. Also, from the mature curve I then select the Y-value at 90 days and associate it with my ""immature""/new curve. +Any suggestions how to do this? I can seem to find any info. +Thanks much!","This seems more like a mathematical problem than a coding problem, but I do have a solution. +If you want to find how similar two curves are, you can use box-differences or just differences. +You calculate or take the y-values of the two curves for each x value shared by both the curves (or, if they share no x-values because, say, one has even and the other odd values, you can interpolate those values). +Then you take the difference of the two y-values for every x-value. +Then you sum up those differences for all x-values. +The resulting number represents how different the two curves are. +Optionally, you can square all the values before summing up, but that depends on what definition of ""likeness"" you are using.",0.0,False,1,6391 +2019-11-09 22:53:51.393,Get N random non-overlapping substrings of length K,"Let's say we have a string R of length 20000 (or another arbitrary length). I want to get 8 random non-overlapping sub strings of length k from string R. +I tried to partition string R into 8 equal length partitions and get the [:k] of each partition but that's not random enough to be used in my application, and the condition of the method to work can not easily be met. +I wonder if I could use the built-in random package to accomplish the job, but I can't think of a way to do it, how can I do it?","You could simply run a loop, and inside the loop use the random package to pick a starting index, and extract the substring starting at that index. Keep track of the starting indices that you have used so that you can check that each substring is non-overlapping. As long as k isn't too large, this should work quickly and easily. +The reason I mention the size of k is because if it is large enough, then it could be possible to select substrings that don't allow you to find 8 non-overlapping ones. But that only needs to be considered if k is quite large with respect to the length of the original string.",0.0,False,1,6392 +2019-11-10 10:49:15.520,How to run previously created Django Project,"I am new to Django. I am using Python 3.7 with Django 2.2.6. +My Django development environment is as the below. + +I am using Microsoft Visual Studio Code on a Windows 8.1 computer +To give the commands I am using 'DOS Command Prompt' & 'Terminal window' in +VS Code. +Created a virtual environment named myDjango +Created a project in the virtual environment named firstProject +Created an app named firstApp. + +At the first time I could run the project using >python manage.py runserver +Then I had to restart my computer. + +I was able to go inside the previously created virtual environment using +workon myDjango command. + +But my problem is I don't know how to go inside the previously created project 'firstProject' and app 'firstApp' using the 'Command prompt' or using the 'VSCode Terminal window' +Thanks and regards, +Chiranthaka","Simply navigate to the folder containing the app you want to manage using the command prompt. +The first cd should contain your parent folder. +The second cd should contain the folder that has your current project. +The third cd should be the specific app you want to work on. +After that, you can use the python manage.py to keep working on your app.",1.2,True,1,6393 +2019-11-10 15:41:49.253,python baserequesthandler client address is real established ip?,"i have a question for you +I'm using the udp socket server using baserequesthandler on python +I want to protect the server against spoofing - source address changes. +Does client_address is the actual ip address of established to server ? +If not, how do I get the actual address?","Authenticate the packets so that you know that every message in session X from source address Y is from the same client. +By establishing a shared session key which is then used along with a sequence number to produce a hash of the packet keyed by the (sequence, session_key) pair. Which is then included in every packet. This can be done in both directions protecting both the client and server. +When you receive a packet you use its source address and the session number to look up the session, then you compute HMAC((sequence, session_key), packet) and check if the MAC field in the message matches. If it doesn't discard the message. +This might not be a correct protocol but it is close enough to demonstrate the principle.",0.0,False,1,6394 +2019-11-10 19:22:04.930,How to use PostgreSQL in Python Pyramid without ORM,"Do I need SQLAlchemy if I want to use PostgreSQL with Python Pyramid, but I do not want to use the ORM? Or can I just use the psycopg2 directly? And how to do that?","Even if you do not want to use ORM, you can still use SQLAlchemy's query +language. +If you do not want to use SQLAlchemy, you can certainly use psycopg2 directly. Look into Pyramid cookbook - MongoDB and Pyramid or CouchDB and Pyramid for inspiration.",0.0,False,1,6395 +2019-11-10 23:16:41.710,Python 3.7.3 Inadvertently Installed on Mac OS 10.15.1 - Included in Xcode Developer Tools 11.2 Now?,"I decided yesterday to do a clean install of Mac OS (as in, erase my entire disk and reinstall the OS). +I am on a Macbook Air 2018. I did a clean install of Mac OS 10.15.1. +I did this clean install due my previous Python environment being very messy. +It was my hope that I could get everything reigned in and installed properly. +I've started reinstalling my old applications, and took care to make sure nothing was installed in a weird location. +However, when I started setting up VS Code, I noticed that my options for Python interpreters showed 4 options. They are as follows: + +Python 2.7.16 64-bit, located in /usr/bin/python +Python 2.7.16 64-bit, located in /System/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python +Python 3.7.3 64-bit, located in /user/bin/python +Python 3.7.3 64-bit, located in /Library/Developer/CommandLineTools/usr/bin/python3 + +In terminal, if I enter where python python3 +it returns +/usr/bin/python /usr/bin/python3. +How in the world did python3 get there? +My only idea is that it now is included in the Xcode Developer Tools 11.2 package, as I did install that. I cannot find any documentation of this inclusion. +Any ideas how this got here? More importantly, how do I remove it? I want to use Homebrew for all of my installation needs. Also, why does VS Code show 4 options? +Thanks!","The command line tool to run the python 2.7 environment is at /usr/bin/python, but the framework and dependencies for it are in /System. This includes the Python.app bundle, which is just a wrapper for scripts that need to run using the Mac's UI environment. +Although these files are separate executables, it's likely that they point to the same environment. +Every MacOS has these. +Catalina does indeed also include /usr/bin/python3 by default. The first time you run it, the OS will want to download Xcode or the Command line tools to install the 'complete' python3. So these pair are also the same environment. +I don't think you can easily remove these, due to the security restrictions on system files in Catalina. +Interestingly, Big Sur still comes with python2 !",1.2,True,1,6396 +2019-11-11 00:39:28.400,"How to access MySQL database that is on another machine, located in a different locations (NOT LOCAL) with python","I am finished with my project and now I want to put it on my website where people could download it and use it. My project is connected to my MySQL and it works on my machine. On my machine, I can read, and modify my database with python. It obviously, will not work if a person from another country tries to access it. How can I make it so a person from another town, city, or country could access my database and be able to read it? +I tried using SSH but I feel like it only works on a local network. +I have not written a single line of code on this matter because I have no clue how to get started. +I probably know how to read my database on a local network but I have no clue how to access it from anywhere else. +Any help, tips, or solutions would be great and appreciated. +Thank you!","If I'm understanding correctly, you want to run a MySQL server from your home PC and allow others to connect and access data? Well, you would need to make sure the correct port is forwarded in your router and firewall, default is TCP 3306. Then simply provide the user with your current IP address (could change). + +Determine the correct MySQL Server port being listened on. +Allow port forwarding on the TCP protocol and the port you determined, default is 3306. +Allow incoming connections on this port from software firewall if any. +Provide the user with your current IP Address, Port, and Database name. +If you set login credentials, make sure the user has this as well. +That's it. The user should be able to connect with the IP Address, Port, Database Name, Username, and Password.",0.0,False,1,6397 +2019-11-12 04:54:01.377,Is there a dynamic scheduling system for better implementation of a subscription based payment system?,"I was making a subscription payment system from scratch in python in Django. I am using celery-beat for a scheduled task with RabbitMQ as a queue broker. django_celery_beat uses DatabaseScheduler which is causing problems. + +Takes a long time to dispatch simple-task to the broker. I was using it to expire users. For some expiration tasks, it took around 60 secs - 150secs. But normally it used to take 100ms to 500ms. +Another problem is that, while I re-schedule some task, while it is being written into the database it blocks the scheduler for some bizarre reason and multiple tasks are missed because of that. + +I have been looking into Apache Airflow because it is marketed as an industry-standard scheduling solution. +But I don't think, it is applicable and feasible for my small project. +If you have worked and played with a subscription payment system, can you advise me how to go forward with this?","I have a long winding solution that I implemented for a similar project. + +First I save the schedule as a model in the database +Next I have a cron job that gets the entries that need to be run for that day +Then schedule those jobs as normal Celery jobs by setting the ETA based on the time set in the schedule model. + +This way Celery just runs off the messages from Redis in my case. Try it if don't get a direct answer.",0.0,False,1,6398 +2019-11-12 12:52:29.447,How do I customise the flask-user registration and login functions?,"I want to customise the functions that process the results of completing the flask-user registration and login forms. I know how to customise the html forms themselves, but I want to change how flask-user performs the registration process. For example, I want to prevent the flask-user login and registration process from creating flash messages and I want registration to process a referral code. +I understand how to add an _after_registration_hook to perform actions after the registration function has completed, but, this doesn't allow me to remove the flash messages that are created in the login and registration processes. +My custom login and registration processes would build on the existing flask-user login and registration functions with functionality added or removed.","You seem to be asking about the flask-user package - however you tagged this with flask-security (which is a different package but offers similar functionality). I can answer for flask-security-too (my fork of the original flask-security) - if you are/want to use flask-user - it might be useful to change your tags. +In a nutshell - for flask-security - you can turn off ALL flashes with a config variable. +For registration - you can easily override the form and add a referral code - and validate/process that as part of form validation.",0.0,False,1,6399 +2019-11-12 13:47:52.050,How I can debug two-language program?,"I use Python as a high-level wrapper and a loaded C++ kernel in the form of a binary library to perform calculations. I debug high level Python code in IDE Eclipse in the usual way, but how do I debug C++ code? +Thank you in advance for your help.","Try using gdb's ""attach "" command (or ""gdb -p "" command-line option) to attach to the python process that has the C++ kernel library loaded.",0.3869120172231254,False,1,6400 +2019-11-13 08:29:13.933,Why my Python command doesn't work in Windows 10 CMD?,I have added the C:\Users\Admin\Anaconda3\python.exe path to my system environment variables PATH but still when I run python command it opens Windows app store! Why bthis happens and how to fix it?,"the PATH variable should contain +C:\Users\Admin\Anaconda3 +not +C:\Users\Admin\Anaconda3\python.exe",1.2,True,1,6401 +2019-11-13 11:59:54.057,Automate downloading of certain csv files from a website,"I am trying to automate downloading of certain csv files from a website. +This is how I manually do it: + +I log in to the website. +Click on the button export as csv. +The file gets downloaded. + +The problem is the button does not have any link to it so I was not able to automate it using wget or requests.","You can use selenium in python. There is an option to click using ""link text"" or ""partial link text"". It is quite easy and efficient. +driver.findElement(By.linkText(""click here"")).click() +It kind of looks like this.",0.0,False,1,6402 +2019-11-13 12:45:22.860,Python does not work after installing fastai and boto3. Permission denied // Python was not found,"Last thing I did was pip install boto3 and fastai through git bash yesterday. I can't imagine if anything else could have had any influence. +I have been using python for a few months now, but today it stopped running. I opened my +Sublime Text - and after running some simple code I got: +""Python was not found but can be installed from the Microsoft Store"". +GIT bash: + +$ python --version bash: + /c/Users/.../AppData/Local/Microsoft/WindowsApps/python: Permission + denied + +But if I open up a file of python 3 in this link: + +C:\Users...\AppData\Roaming\Microsoft\Windows\Start + Menu\Programs\Python 3.7 + +My Python works. +I think I have to redirect my main python file from the first link directory to the second and have no clue how to do this, that my Git and Sublime would be able to pick on this.","So, I gave up and just installed the recommended link from Microsoft store. So now I possibly have 4 pythons with 2 different versions in 3 locations, but hey.... it works :) +Regarding a comment below my first questions: +When I run $ ls -l which python in GITbash, it gives: +-rwxr-xr-x 1 ... 197121 97296 Mar 25 2019 /c/Users/.../AppData/Local/Programs/Python/Python37-32/python* + +/.../ is just my user name + +Yesterday I tried that as well, the start was identical, although I can't really remember the link, if it was the same.",0.0,False,1,6403 +2019-11-13 13:05:07.793,Is there a way to change TCP settings for Django project?,"I have been working on a project built with Django. When I run profiler due to slowness of a page in project, this was a line of the result: + +10 0.503 0.050 0.503 0.050 {method 'recv_into' of '_socket.socket' objects} + +Which says almost 99% of passed time was for the method recv_into(). After some research, I learned the reason is Nagel's algorithm which targets to send packets only when the buffer is full or there are no more packets to transmit. I know I have to disable this algorithm and use TCP_NODELAY but I don't know how, also it should only affect this Django project. +Any help would be much appreciated.","Are you using cache settings in the settings.py file? Please check that maybe you have tcp_nodelay enable there, if so then remove it or try to clear browser cache.",-0.1016881243684853,False,1,6404 +2019-11-13 14:01:57.823,How does this Fibonacci Lambda function work?,"Am a beginner on Python (self studying) and got introduced to Lambda (nameless) function but I am unable to deduce the below expression for Fibonacci series (got from Google) but no explanation available online (Google) as to how this is evaluated (step by step). Having a lot of brain power here, I thought somebody can help me with that. Can you help evaluate this step by step and explain ? +lambda n: reduce(lambda x, _: x+[x[-1]+x[-2]],range(n-2), [0, 1]) +Thanks in advance. +(Thanks xnkr, for the suggestion on a reduce function explained and yes, am able to understand that and it was part of the self training I did but what I do not understand is how this works for lambda x, _ : x+[x[-1]+x[-2]],range(n-2), [0, 1]. It is not a question just about reduce but about the whole construct - there are two lambdas, one reduce and I do not know how the expression evaluates to. What does underscore stand for, how does it work, etc) +Can somebody take the 2 minutes that can explain the whole construct here ?","Break it down piece by piece: +lambda n: - defines a function that takes 1 argument (n); equivalent to an anonymous version of: def somefunc(n): +reduce() - we'll come back to what it does later; as per docs, this is a function that operates on another function, an iterable, and optionally some initial value, in that order. These are: + +A) lambda x, _: - again, defines a function. This time, it's a function of two arguments, and the underscore as the identifier is just a convention to signal we're not gonna use it. +B) X + [ ] - prepend some list of stuff with the value of the first arg. We already know from the fact we're using reduce that the arg is some list. +C) The is x[-1] + x[-2] - meaning the list we're prepending our X to is, in this case, the sum of the last two items already in X, before we do anything to X in this iteration. +range(n-2) is the iterable we're working on; so, a list of numbers from 1 to N-2. The -2 is here because the initial value (in 3) already has the first two numbers covered. +Speaking of which, [0, 1] is our predefined first two starting values for X[-2], X[-1]. +And now we're executing. reduce() takes the function from (1) and keeps applying it to each argument supplied by the range() in (2) and appending the values to a list initialized as [0, 1] in (3). So, we call I1: [0, 1] + lambda 0, [0, 1], then I2: I1 + lambda 1, I1, then I3: I2 + lambda 2, I2 and so on.",1.2,True,1,6405 +2019-11-13 16:38:11.820,Printing top few lines of a large JSON file in Python,"I have a JSON file whose size is about 5GB. I neither know how the JSON file is structured nor the name of roots in the file. I'm not able to load the file in the local machine because of its size So, I'll be working on high computational servers. +I need to load the file in Python and print the first 'N' lines to understand the structure and Proceed further in data extraction. Is there a way in which we can load and print the first few lines of JSON in python?","You can use the command head to display the N first line of the file. To get a sample of the json to know how is it structured. +And use this sample to work on your data extraction. +Best regards",-0.2012947653214861,False,1,6406 +2019-11-14 00:50:56.010,"get json data from host that requires headers={'user-agent', 'cookie', x-xsrf-token'}","There is a server that contains a json dataset that I need +I can manually use chrome to login +to the url and use chrome developer tool to read the request header for said json data +I determined that the minimum required headers that should be sent to the json endpoint are ['cookie', 'x-xsrf-token', 'user-agent'] +I don't know how I can get these values so that I can automate fetching this data. I would like to use request module to get the data +I tried using selenium, to navigate to the webpage that exposes these header values, but cannot get said headers values (not sure if selenium supports this) +Is there a way for me to use request module to inch towards getting these header values...by following the request header ""bread crumbs"" so to speak? +Is there an alternative module that excels at this? +To note, I have used selenium to get the required datapoints successfully, but selenium is resource heavy and prone to crash; +By using the request module with header values greatly simplifies the workflow and makes my script reliable","Based on pguardiario's comment +Sessions cookies and csrf-token are provided by the host when a request is made against the Origin url. These values are needed to make subsequent requests against the endpoint with the JSON payload. By using request.session() against the Origin url, and then updating the header when using request.get(url, header). I was able to access the json data",1.2,True,1,6407 +2019-11-15 04:01:44.763,Regex Match for Non Hyphenated Words - Python,"I am trying to create a regex expression in Python for non-hyphenated words but I am unable to figure out the right syntax. +The requirements for the regex are: + +It should not contain hyphens AND +It should contain atleast 1 number + +The expressions that I tried are:= + +^(?!.*-) + + +This matches all non-hyphenated words but I am not able to figure out how to additionally add the second condition. + + +^(?!.*-(?=/d{1,})) + + +I tried using double lookahead but I am not sure about the syntax to use for it. This matches ID101 but also matches STACKOVERFLOW + +Sample Words Which Should Match: +1DRIVE , ID100 , W1RELESS +Sample Words Which Should Not Match: +Basically any non-numeric string (like STACK , OVERFLOW) or any hyphenated words (Test-11 , 24-hours) +Additional Info: +I am using library re and compiling the regex patterns and using re.search for matching. +Any assistance would be very helpful as I am new to regex matching and am stuck on this for quite a few hours.","I came up with - +^[^-]*\d[^-]*$ + +so we need at LEAST one digit (\d) +We need the rest of the string to contain anything BUT a - ([^-]) +We can have unlimited number of those characters, so [^-]* +but putting them together like [^-]*\d would fail on aaa3- because the - comes after a valid match- lets make sure no dashes can sneak in before or after our match ^[-]*\d$ +Unfortunately that means that aaa555D fails. So we actually need to add the first group again- ^[^-]*\d[^-]$ --- which says start - any number of chars that aren't dashes - a digit - any number of chars that aren't dashes - end +Depending on style, we could also do ^([^-]*\d)+$ since the order of the digits/numbers dont matter, we can have as many of those as we want. + +However, finally... this is how I would ACTUALLY solve this particular problem, since regexes may be powerful, but they tend to make the code harder to understand... +if (""-"" not in text) and re.search(""\d"", text):",0.3869120172231254,False,1,6408 +2019-11-15 07:07:23.633,How do I link to a specific page of a PDF document inside a cell in Excel?,"I am writing a python code which writes a hyperlink into a excel file.This hyperlink should open in a specific page in a pdf document. +I am trying something like +Worksheet.write_url('A1',""C:/Users/...../mypdf#page=3"") but this doesn't work.Please let me know how this can be done.","Are you able to open the pdf file directly to a specific page even without xlsxwriter? I can not. +From Adobe's official site: + +To target an HTML link to a specific page in a PDF file, add + #page=[page number] to the end of the link's URL. +For example, this HTML tag opens page 4 of a PDF file named + myfile.pdf: + +Note: If you use UNC server locations (\servername\folder) in a link, + set the link to open to a set destination using the procedure in the + following section. +If you use URLs containing local hard drive addresses (c:\folder), you cannot link to page numbers or set destinations.",0.3869120172231254,False,1,6409 +2019-11-16 04:57:26.760,Using import in Python,"So I’m a new programmer and starting to use Python 3, and I see some videos of people teaching the language and use “import”. My question is how they know what to import and where you can see all the things you can import. I used import math in one example that I followed along with, but I see other videos of people using import JSON or import random, and I’m curious how they find what they can import and how they know what it will do.","In all programming languages, whenever you actually need a library, you should import it. For example, if you need to generate a random number, search for this function in your chosen programming language, find the appropriate library, and import it into your code.",0.1352210990936997,False,1,6410 +2019-11-16 05:22:32.853,Spyder Editor - How to Disable Auto-Closing Brackets,"Does anyone know how to make Spyder stop automatically inserting closing brackets? +It often results in complete mess when you have multiple levels of different brackets. I had a look around and could only find posts about auto-closing quotes, but I'm not really interested in these. But those brackets are making me slightly miserable. +I had a look in Preferences but the closest I could find is 'Automatic code completion'. But I certainly don't want all of it off especially when working with classes.","In Spyder 4 and Spyder 5 go to: + +Tools - Preferences - Editor - Source code + +and deselect the following items: + +Automatic insertion of parentheses, braces and brackets + +Automatic insertion of closing quotes (since it's the same nuisance than with brackets)",1.2,True,1,6411 +2019-11-17 00:01:23.980,Get all keys in a hash-table that satisfy certain arithmetic property,"Let's say I have a Hash-table, each key is defined as a tuple with 4 integers (A, B, C, D). where are integers represent a quantity of a certain attribute, and its corresponding value is a tuple of gears that satisfy (A, B, C, D). +I wanted to write a program that do the following: with any given attribute tuple (x, y, z, w), I want to find all the keys satisfying (|A - x| + |B - y| + |C - z| + |D - w|) / 4 <= i where i is a user defined threshold; return the value of these keys if exist and do some further calculation. (|A - x| means the absolute value of A - x) +To my experience, this kind of thing can be better done with Answer set programming, Haskell, Prolog and all this kind of logical programming languages, but I'm forced to use python for this is a python project... +I can hard code for a particular ""i"" but I really have no idea how to do this for arbitrary integers. please tell me how I can do this in pure python, Thank you very much!!!!",Just write a function that loops over all values in the table and checks them one by one. The function will take the table and i as arguments.,1.2,True,1,6412 +2019-11-18 00:40:56.233,How to create a different workflow depending on result of last run?,"I am trying to accomplish the following task using Airflow. I have an address and I want to run 3 different tasks taskA, taskB, taskC. Each task returns True if the address was detected. Store the times when each of the functions detected the address. +I want to accomplish the below logic. + +Run all three tasks to start off with. +If any of them return True, store the current time. +Wait for 1 minute and rerun only the tasks that did not return True. +If all have returned True end the job. + +I am not sure how I can accomplish selectively running only those tasks that returned False from the last run. +I have so far looked at the BranchPythonOperator but I still haven't been able to accomplish the desired result.",You can get last run status value from airflow db.,0.0,False,1,6413 +2019-11-18 18:32:02.663,How to allow my computer to download .py files from an email,"I am unable to download a .py file from an email. I get the error ""file not supported."" The file was saved from a Jupyter-notebook script. +I have Python 3.6.6 and Jupyter downloaded on my Windows 10 laptop and tried to access the file through Chrome and through my computer's email app, but this didn't resolve the problem. +Any ideas on how to make the file compatible with my computer? +EDIT: I had to have the .ipynb file sent rather than the .py file.","Generally email providers block any thing which can possibly execute on clients machine. +Best option to share will be transfer via email will be .py.txt +or any cloud drives.",0.0,False,1,6414 +2019-11-19 12:15:40.287,Use of views in jam.py framework,"for an academic project, I am currently using the python framework jam.py 5.4.83 to develop a back office for a new company. +I would like to use views instead of tables for reporting but I don't find how to do it, I can only import data from tables. +So if someone already used this framework, I would be very thankful. +Regards, +Yoan","the use of database views are not supported in Jam.py +However, you can import tables as read only if used for reporting. +Than you can build Reports as you would. +Good luck.",0.0,False,1,6415 +2019-11-19 15:26:28.493,How to find the intersecting area of two sub images using OpenCv?,Let's say there are two sub images of a large image. I am trying to detect the overlapping area of two sub images. I know that template matching can help to find the templates. But i'm not sure how to find the intersected area and remove them in either one of the sub images. Please help me out.,"MatchTemplate returns the most probable position of a template inside a picture. You could do the following steps: + +Find the (x,y) origin, width and height of each picture inside the larger one +Save them as rectangles with that data(cv::Rect r1, cv::Rect r2) +Using the & operator, find the overlap area between both rectangles (r1&r2)",0.2012947653214861,False,1,6416 +2019-11-19 19:57:43.280,How to scale numpy matrix in Python?,"I have this numpy matrix: +x = np.random.randn(700,2) +What I wanna do is scale the values of the first column between that range: 1.5 and 11 and the values of the second column between `-0.5 and 5.0. Does anyone have an idea how I could achieve this? Thanks in advance","subtract each column's minimum from itself +for each column of the result divide by its maximum +for column 0 of that result multiply by 11-1.5 +for column 1 of that result multiply by 5--0.5 +add 1.5 to column zero of that result +add -0.5 to column one of that result + +You could probably combine some of those steps.",0.3869120172231254,False,1,6417 +2019-11-20 13:02:15.587,zsh: command not found: import,"I'm using MAC OS Catalina Version 10.15.1 and I'm working on a python project. Every time I use the command ""import OS"" on the command line Version 2.10 (433), I get this message: zsh: command not found: import. I looked up and followed many of the solutions listed for this problem but none of them have worked. The command worked prior to upgrading my MAC OS. Any suggestion on how to fix it?","Don't capitalize it. +import os",0.0,False,2,6418 +2019-11-20 13:02:15.587,zsh: command not found: import,"I'm using MAC OS Catalina Version 10.15.1 and I'm working on a python project. Every time I use the command ""import OS"" on the command line Version 2.10 (433), I get this message: zsh: command not found: import. I looked up and followed many of the solutions listed for this problem but none of them have worked. The command worked prior to upgrading my MAC OS. Any suggestion on how to fix it?","The file is being interpreted as zsh, not a python. I suggest you to add this to the first line: +#!/usr/bin/env python",0.2012947653214861,False,2,6418 +2019-11-20 16:21:07.560,Starting conda pompt from cmd,"I want to start the conda Prompt from cmd, because I want to use the promt as a terminal in Atom.io. +There is no Conda.exe and the path to conda uses cmd to jump into the prompt. But how do I start it inside of cmd?","I guess what you want is to change to Anaconda shell using cmd, you can find the address for your Anaconda and run the following in your cmd: +%windir%\System32\cmd.exe ""/K"" ""Address""\anaconda3 +Or, you can find your Anaconda prompt shortcut, right click on that, and open its properties window. In the properties window, find Target. Then, copy the whole thing in Target and paste it into your cmd.",0.2012947653214861,False,1,6419 +2019-11-20 19:03:29.667,Prevent internal POST methods to be called by third parties,"I'm worried about the security of my web app, I'm using Django and sometimes I use AJAX to call a Django url that will execute code and then return an HttpResponse with a message according the result, the user never notice this as it's happening in background. +However, if the url I'm calling with AJAX is, for example, ""runcode/"", and the user somehow track this and try to send a request to my domain with that url (something like ""www.example.com/runcode/""), it will not run the code as Django expects the csrf token to be send too, so here goes the question. +It is possible that the user can obtain the csrf token and send the POST?, I feel the answer for that will be ""yes"", so anyone can help me with a hint on how to deny these calls if they are made without the intended objective?","Not only django but this behavior is common in all others, +You can only apply 2 solution, + +Apply CORS and just allow your domain, to block other domain to access data from your API response, but this will not effective if a user direct call your API end-point. +As lain said in comment, If data is sensitive or user's personal, add authentication in API. + +Thanks",0.0,False,1,6420 +2019-11-21 15:43:05.370,Looping through webelements with selenium Python,"I am currently trying to automate a process using Selenium with python, but I have hit a roadblock with it. The list is part of a list which is under a tree. I have identified the base of the tree with the following xpath +item = driver.find_element_by_xpath(""//*[@id='filter']/ul/li[1]//ul//li"") +items = item.find_elements_by_tag_name(""li"") +I am trying to Loop through the ""items"" section but need and click on anything with an ""input"" tag +for k in items: + WebDriverWait(driver, 10).until(EC.element_to_be_clickable((k.find_element(By.TAG_NAME, ""input"")))).click() +When execute the above I get the following error: +""TypeError: find_element() argument after * must be an iterable, not WebElement"" +For some reason .click() will not work if I use something like the below. +k.find_element_by_tag_name(""input"").click() +it only works if i use the webdriverwait. I have had to use the web driver wait method anytime i needed to click something on the page. +My question is: +What is the syntax to replicate items = item.find_elements_by_tag_name(""li"") +for WebDriverWait(driver, 10).until(EC.element_to_be_clickable((k.find_element(By.TAG_NAME, ""input"")))).click() +i.e how do I use a base path and append to the using the private methods find_elements(By.TAG_NAME) +Thanks in advance","I have managed to find a work around and get Selenium to do what i need. +I had to call the javascript execution, so instead of trying to get +WebDriverWait(driver, 10).until(EC.element_to_be_clickable((k.find_element(By.TAG_NAME, ""input"")))).click() to work, i just used +driver.execute_script(""arguments[0].click();"", k.find_element_by_tag_name(""input"")) +Its doing exactly what I needed it to do.",1.2,True,1,6421 +2019-11-23 19:16:37.407,How can I update the version of SQLite in my Flask/SQLAlchemy App?,"I wish to use the latest version of SQLite3 (3.30.1) because of its new capability to handle SQL 'ORDER BY ... ASC NULLS LAST' syntax as generated by the SQLAlchemy nullslast() function. +My application folder env\Scripts contains the existing (old) version of sqlite3.dll (3.24), however when I replace it, there is no effect. In fact, if I rename that DLL, the application still works fine with DB accesses. +So, how do I update the SQLite version for an application? +My environment: +Windows 10, 64-bit (I downloaded a 64-bit SQlite3 DLL version). I am running with pyCharm, using a virtual env.","I have found that the applicable sqlite3.dll is determined first by a Windows OS defined lookup. It first goes through the PATH variable, finding and choosing the first version it finds in any of those paths. +In this case, probably true for all pyCharm/VirtualEnv setups, a version found in my user AppData\Local\Programs\Python\Python37\DLLs folder was selected. +When I moved that out of the way, it was able to find the version in my env\Scripts folder, so that the upgraded DLL was used, and the sQLAlchemy nullslast() function did its work.",1.2,True,1,6422 +2019-11-25 12:59:29.660,Python and Telethon: how to handle sw distribution,"I developed a program to interact between Telegram and other 3rd party Software. It's written in Python and I used the Telethon library. +Everything works fine, but since it uses my personal configuration including API ID, API hash, phone number and username, I would like to know how to handle all of this if I wanted to distribute the software to other people. +Of course they can't use my data, so should they login into Telegram development page and get all the info? Or, is there a more user-friendly way to do it?","Since the API ID and the API Hash in Telegram are supposed to be distributed with your client all you need to do is prompt the user for their Phone Number. +You could do this using a GUI Library (like PySide2 using QInputDialog) or if it is a command line application using input(). Keep in mind that the user will also need a way to enter the code they receive from Telegram and their 2FA Password if set.",1.2,True,1,6423 +2019-11-25 18:14:02.303,Pyarmor Pack Python File Check Restrict Mode Failed,"So i am trying to Pack my python script with pyarmor pack however, when i pack the script it does not work, it throws check restrict mode failed. If i Obfuscate the script normally with pyarmor obfuscate instead of pack the script it works fine, and is obfuscated fine. This version runs no problem. Wondering how i can get pack to work as i want my python file in an exe +I have tried to compile the obfuscated script with pyinstaller however this does not work either +Wondering what else i can try?","I had this problem, fixed by adding --restrict=0 +For example: pyarmor obfuscate --restrict=0 app.py",0.3869120172231254,False,1,6424 +2019-11-26 14:11:58.723,how to find cosine similarity in a pre-computed matrix with a new vector?,"I have a dataframe with 5000 items(rows) and 2048 features(columns). +Shape of my dataframe is (5000, 2048). +when I calculate cosine matrix using pairwise distance in sklearn, I get (5000,5000) matrix. +Here I can compare each other. +But now If I have a new vector shape of (1,2048), how can find cosine similarity of this item with early dataframe which I had, using (5000,5000) cosine matrix which I have already calculated? +EDIT +PS: I can append this new vector to my dataframe and calculate again cosine similarity. But for large amount of data it gets slow. Or is there any other fast and accurate distance metrics?","Since cosine similarity is symmetric. You can compute the similarity meassure with the old data matrix, that is similarity between the new sample (1,2048) and old matrix (5000,2048) this will give you a vector of (5000,1) you can append this vector into the column dimension of the pre-computed cosine matrix making it (5000,5001) now since you know the cosine similarity of the new sample to itself. you can append this similarity to itself, back into the previously computed vector making it of size (5001,1), this vector you can append in the row dimension of the new cosine matrix that will make it (5001,5001)",0.0,False,2,6425 +2019-11-26 14:11:58.723,how to find cosine similarity in a pre-computed matrix with a new vector?,"I have a dataframe with 5000 items(rows) and 2048 features(columns). +Shape of my dataframe is (5000, 2048). +when I calculate cosine matrix using pairwise distance in sklearn, I get (5000,5000) matrix. +Here I can compare each other. +But now If I have a new vector shape of (1,2048), how can find cosine similarity of this item with early dataframe which I had, using (5000,5000) cosine matrix which I have already calculated? +EDIT +PS: I can append this new vector to my dataframe and calculate again cosine similarity. But for large amount of data it gets slow. Or is there any other fast and accurate distance metrics?","The initial (5000,5000) matrix encodes the similarity values of all your 5000 items in pairs (i.e. symmetric matrix). +To have the similarities in case of a new item, concatenate and make a (5001, 2048) matrix and then estimate similarity again to get (5001,5001) +In other words, you can not directly use the (5000,5000) precomputed matrix to get the similarity with the new (1,2048) vector.",0.0,False,2,6425 +2019-11-27 09:52:59.383,SQLITE3 / Python - Database disk image malformed but integrity_check ok,"My actual problem is that python sqlite3 module throws database disk image malformed. +Now there must be a million possible reasons for that. However, I can provide a number of clues: + +I am using python multiprocessing to spawn a number of workers that all read (not write) from this DB +The problem definitely has to do with multiple processes accessing the DB, which fails on the remote setup but not on the local one. If I use only one worker on the remote setup, it works +The same 6GB database works perfectly well on my local machine. I copied it with git and later again with scp to remote. There the same script with the copy of the original DB gives the error +Now if I do PRAGMA integrity_check on the remote, it returns ok after a while - even after the problem occurred +Here are the versions (OS are both Ubuntu): + +local: sqlite3.version >>> 2.6.0, sqlite3.sqlite_version >>> 3.22.0 +remote: sqlite3.version >>> 2.6.0, sqlite3.sqlite_version >>> 3.28.0 + + +Do you have some ideas how to allow for save ""parallel"" SELECT?","The problem was for the following reason (and it had happened to me before): +Using multiprocessing with sqlite3, make sure to create a separate connection for each worker! +Apparently this causes problems with some setups and sometimes doesn't.",0.0,False,1,6426 +2019-11-28 11:25:12.167,Fail build if coverage lowers,"I have GitHub Actions that build and test my Python application. I am also using pytest-cov to generate a code coverage report. This report is being uploaded to codecov.io. +I know that codecov.io can't fail your build if the coverage lowers, so how do I go about with GitHub Actions to fail the build if the coverage drops? Do I have to check the previous values and compare with the new ""manually"" (having to write a script)? Or is there an existing solution for this?","There is nothing built-in, instead you should use one of the many integrations like sonarqube, if I don’t want to write a custom script.",0.0,False,1,6427 +2019-12-01 04:16:36.060,what's command to list all the virtual environments in venv?,"I know in conda I can use conda env list to get a list of all conda virtual environments, what's the corresponding command in python venv that can list all the virtual environments in a given venv? also, is there any way I can print/check the directory of current venv? somehow I have many projects that have same name .venv for their virtual environment and I'd like to find a way to verify which venv I'm in. Thanks","Virtual environments are simple a set of files in a directory on your system. You can find them the same way you would find images or documents with a certain name. For example, if you are using Linux or macOS, you could run find / | grep bin/activate in terminal. Not too sure about Windows but I suspect you can search for something similar in Windows Explorer.",0.0,False,2,6428 +2019-12-01 04:16:36.060,what's command to list all the virtual environments in venv?,"I know in conda I can use conda env list to get a list of all conda virtual environments, what's the corresponding command in python venv that can list all the virtual environments in a given venv? also, is there any way I can print/check the directory of current venv? somehow I have many projects that have same name .venv for their virtual environment and I'd like to find a way to verify which venv I'm in. Thanks","I'm relatively new to python venv as well. I have found that if you created your virtual environment with python -m venv with in a project folder. +I'm using windows, using cmd, for example, you have a Dash folder located in C:\Dash, when you created a venv called testenv by +python -m venv testenv, +you can activate the virtual environment by just input +C:\Dash\testenv\Scripts\activate, +then you can deactivate it by just type in deactivate. +If you want to list the venv that you have, you go to the C:\Dash folder. type +dir +in cmd, it will list the list of the virtual env you have, similar to conda env list. if you want to delete that virtual env, simply do +rm -rf testenv +you can list the packages installed within that venv by doing +pip freeze. +I hope this helps. please correct me if I'm wrong.",0.2012947653214861,False,2,6428 +2019-12-02 14:13:17.757,Localization with RPLider (Python),"we are currently messing around with an Slamtec RPLidar A1. We have a robot with the lidar mounted on it. +Our aim is to retrieve a x and y position in the room. (it's a closed room, could have more than 4 corners but the whole room should be recognized once (it does not matter where the RPlidar stands). +Anyway the floormap is not given. +We got so far a x and y position with BreezySLAM but we recognized, wherever the RPlidar stands, it always sees itself as center, so we do not really know how to retrieve correct x and y from this information. +We are new to this topic and maybe someone can give us a good hint or link to find a simple solution. +PS: We are not intending to track the movement of the robot.","Any sensor sees itself in the center of the environment. The idea of recording map is good one, if not. You can presume that any of the corners can be your zero points, you your room is not square, you can measure length of the wall and and you down to 2 points. Unfortunately if you don't have any additional markers in the environment or you can't create map before actual use, I'm afraid there is no chance for robot to correctly understand where is desired (0,0) point is.",0.0,False,1,6429 +2019-12-02 17:35:56.597,A function possible inputs in PYTHON,"How can I quickly check what are the possible inputs to a specific function? For example, I want to plot a histogram for a data frame: df.hist(). I know I can change the bin size, so I know probably there is a way to give the desired bin size as an input to the hist() function. If instead of bins = 10 I use df.hist(bin = 10), Python obviously gives me an error and says hist does not have property bin. +I wonder how I can quickly check what are the possible inputs to a function.",Since your question tag contains jupyter notebook I am assuming you are trying on it. So in jupyter notebook 2.0 Shift+Tab would give you function arguments.,0.296905446847765,False,1,6430 +2019-12-03 02:24:09.220,How to send data from Python script to JavaScript and vice-versa?,"I am trying to make a calculator (with matrix calculation also). I want to make interface in JavaScript and calculation stuff in Python. But I don't know how to send parameters from python to JavaScript and from JavaScript to python. +Edit: I want to send data via JSON (if possible).","You would have to essentially set both of them up as API's and access them via endpoints. +For Javascript, you can use node to set up your API endpoint, and for Python use Flask.",0.2012947653214861,False,1,6431 +2019-12-03 05:29:29.123,Is there any operator in Python to check and compare the type and value?,"I know that other languages like Javascript have +a == and === operator also they have a != and !== operator does Python also has a === and !== (ie. a single operator that checks the type and compares the value at the same time like === operator) and if not how can we implement it.","No, and you can't really implement it yourself either. +You can check the type of an object with type, but if you just write a function that checks type(x) is type(y) and x == y, then you get results like [1] and [1.0] showing up as equivalent. While that may fulfill the requirements you stated, I've never seen a case where this wasn't an oversight in the requirements. +You can try to implement your own deep type-checking comparison, but that requires you to know how to dig into every type you might have to deal with to perform the comparison. That can be done for the built-in container types, but there's no way to make it general. +As an aside, is looks vaguely like what you want if you don't know what is does, but it's actually something entirely different. is checks object identity, not type and value, leading to results like x = 1000; x + 1 is not 1001.",0.0814518047658113,False,1,6432 +2019-12-04 11:32:33.307,Using python and spacy text summarization,"Basically i am trying to do text summarize using spacy and nltk in python. Now i want to summarize the normal 6-7 lines text and show the summarized text on the localhost:xxxx so whenever i run that python file it will show on the localhost. +Can anyone tell is it possible or not and if it is possible how to do this. Since there would be no databse involved.",You have to create a RESTFUL Api using FLASK or DJAngo with some UI elements and call your model. Also you can use displacy( Spacy UI Bro) Directly on your system.,1.2,True,1,6433 +2019-12-05 06:08:12.167,Find the maximum result after collapsing an array with subtractions,"Given an array of integers, I need to reduce it to a single number by repeatedly replacing any two numbers with their difference, to produce the maximum possible result. +Example1 - If I have array of [0,-1,-1,-1] then performing (0-(-1)) then (1-(-1)) and then (2-(-1)) will give 3 as maximum possible output +Example2- [3,2,1,1] we can get maximum output as 5 { first (1-1) then (0-2) then (3-(-2)} +Can someone tell me how to solve this question?","The other answers are fine, but here's another way to think about it: +If you expand the result into individual terms, you want all the positive numbers to end up as additive terms, and all the negative numbers to end up as subtractive terms. +If you have both signs available, then this is easy: + +Subtract all but one of the positive numbers from a negative number +Subtract all of the negative numbers from the remaining positive number + +If all your numbers have the same sign, then pick the one with the smallest absolute value at treat it as having the opposite sign in the above procedure. That works out to: + +If you have only negative numbers, then subtract them all from the least negative one; or +If you have only positive numbers, then subtract all but one from the smallest, and then subtract the result from the remaining one.",0.0,False,1,6434 +2019-12-05 17:41:59.977,Combining logistic and continuous regression with scikit-learn,"In my dataset X I have two continuous variables a, b and two boolean variables c, d, making a total of 4 columns. +I have a multidimensional target y consisting of two continuous variables A, B and one boolean variable C. +I would like to train a model on the columns of X to predict the columns of y. However, having tried LinearRegression on X it didn't perform so well (my variables vary several orders of magnitude and I have to apply suitable transforms to get the logarithms, I won't go into too much detail here). +I think I need to use LogisticRegression on the boolean columns. +What I'd really like to do is combine both LinearRegression on the continuous variables and LogisticRegression on the boolean variables into a single pipeline. Note that all the columns of y depend on all the columns of X, so I can't simply train the continuous and boolean variables independently. +Is this even possible, and if so how do I do it?","If your target data Y has multiple columns you need to use multi-task learning approach. Scikit-learn contains some multi-task learning algorithms for regression like multi-task elastic-net but you cannot combine logistic regression with linear regression because these algorithms use different loss functions to optimize. Also, you may try neural networks for your problem.",0.0,False,2,6435 +2019-12-05 17:41:59.977,Combining logistic and continuous regression with scikit-learn,"In my dataset X I have two continuous variables a, b and two boolean variables c, d, making a total of 4 columns. +I have a multidimensional target y consisting of two continuous variables A, B and one boolean variable C. +I would like to train a model on the columns of X to predict the columns of y. However, having tried LinearRegression on X it didn't perform so well (my variables vary several orders of magnitude and I have to apply suitable transforms to get the logarithms, I won't go into too much detail here). +I think I need to use LogisticRegression on the boolean columns. +What I'd really like to do is combine both LinearRegression on the continuous variables and LogisticRegression on the boolean variables into a single pipeline. Note that all the columns of y depend on all the columns of X, so I can't simply train the continuous and boolean variables independently. +Is this even possible, and if so how do I do it?","What i understand you want to do is to is to train a single model that both predicts a continuous variable and a class. You would need to combine both loses into one single loss to be able to do that which I don't think is possible in scikit-learn. However I suggest you use a deep learning framework (tensorflow, pytorch, etc) to implement your own model with the required properties you need which would be more flexible. In addition you can also tinker with solving the above problem using neural networks which would improve your results.",0.0,False,2,6435 +2019-12-06 14:08:01.030,How to build whl package for pandas?,"Hi I have a built up Python 2.7 environment with Ubuntu 19.10. +I would like to build a whl package for pandas. +I pip installed the pandas but do not know how to pack it into whl package. +May I ask what I should do to pack it. +Thanks",You cannot pack back an installed wheel. Either you download a ready-made wheel with pip download or build from sources: python setup.py bdist_wheel (need to download the sources first).,1.2,True,1,6436 +2019-12-07 11:29:54.817,Walls logic in Pygame,"I'm making a game with Pygame, and now I stuck on how to process collision between player and wall. This is 2D RPG with cells, where some of them are walls. You look on world from top, like in Pacman. +So, I know that i can get list of collisions by pygame.spritecollide() and it will return me list of objects that player collides. I can get ""collide rectangle"" by player.rect.clip(wall.rect), but how I can get player back from the wall? +So, I had many ideas. The first was push player back in opposite direction, but if player goes, as example, both right and bottom directions and collide with vertical wall right of itself, player stucks, because it is needed to push only left, but not up. +The second idea was implement diagonally moving like one left and one bottom. But in this way we don't now, how move first: left or bottom, and order becomes the most important factor. +So, I don't know what algorithm I should use.","If you know the location of the centre of the cell and the location of the player you can calculate the x distance and the y distance from the wall at that point in time. Would it be possible at that point to take the absolute value of each distance and then take the largest value as the direction to push the player in. +e.g. The player collides with the right of the wall so the distance from the centre of the wall in the y direction should be less than the distance in x. +Therefore you know that the player collided with the left or the right of the wall and not the top, this means the push should be to the right or the left. +If the player's movement is stored as in the form [x, y] then knowing whether to push left or right isn't important since flipping the direction of movement in the x axis gives the correct result. +The push should therefore be in the x direction in this example +e.g. player.vel_x = -player.vel_x. +This would leave the movement in the y axis unchanged so hopefully wouldn't result in the problem you mentioned. +Does that help?",1.2,True,1,6437 +2019-12-07 17:17:25.127,How to load values related to selected multiple options in Django,"Thank you all for always willing to help. +I have a Django app with countries and state choices fields. However, I have no idea whatsoever on how to load the related states for each country. What I mean here is, if I choose ""Nigeria"" in the list of countries, how can I make all Nigerian states to automatically load in the state choice field?","You have to create many to many field state table, then you can multiple select state as per country. +this feature available on django- country package or django- cities package.",0.0,False,1,6438 +2019-12-08 17:44:54.277,Find how similar a text is - One Class Classifier (NLP),"I have a big dataset containing almost 0.5 billions of tweets. I'm doing some research about how firms are engaged in activism and so far, I have labelled tweets which can be clustered in an activism category according to the presence of certain hashtags within the tweets. +Now, let's suppose firms are tweeting about an activism topic without inserting any hashtag in the tweet. My code won't categorized it and my idea was to run a SVM classifier with only one class. +This lead to the following question: + +Is this solution data-scientifically feasible? +Does exists any other one-class classifier? +(Most important of all) Are there any other ways to find if a tweet is similar to the ensable of tweets containing activism hashtags? + +Thanks in advance for your help!","Sam H has a great answer about using your dataset as-is, but I would strongly recommend annotating data so you have a few hundred negative examples, which should take less than an hour. Depending on how broad your definition of ""activism"" is that should be plenty to make a good classifier using standard methods.",0.2012947653214861,False,1,6439 +2019-12-09 10:34:14.533,Existing Tensorflow model to use GPU,"I made a TensorFlow model without using CUDA, but it is very slow. Fortunately, I gained access to a Linux server (Ubuntu 18.04.3 LTS), which has a Geforce 1060, also the necessary components are installed - I could test it, the CUDA acceleration is working. +The tensorflow-gpu package is installed (only 1.14.0 is working due to my code) in my virtual environment. +My code does not contain any CUDA-related snippets. I was assuming that if I run it in a pc with CUDA-enabled environment, it will automatically use it. +I tried the with tf.device('/GPU:0'): then reorganizing my code below it, didn't work. I got a strange error, which said only XLA_CPU, CPU and XLA_GPU is there. I tried it with XLA_GPU but didn't work. +Is there any guide about how to change existing code to take advantage of CUDA?","Not enough to give exact answer. +Have you installed tensorflow-gpu separately? Check using pip list. +Cause, initially, you were using tensorflow (default for CPU). +Once you use want to use Nvidia, make sure to install tensorflow-gpu. +Sometimes, I had problem having both installed at the same time. It would always go for the CPU. But, once I deleted the tensorflow using ""pip uninstall tensorflow"" and I kept only the GPU version, it worked for me.",0.0,False,1,6440 +2019-12-09 12:23:35.760,how to select the metric to optimize in sklearn's fit function?,"When using tensorflow to train a neural network I can set the loss function arbitrarily. Is there a way to do the same in sklearn when training a SVM? Let's say I want my classifier to only optimize sensitivity (regardless of the sense of it), how would I do that?","This is not possible with Support Vector Machines, as far as I know. With other models you might either change the loss that is optimized, or change the classification threshold on the predicted probability. +SVMs however minimize the hinge loss, and they do not model the probability of classes but rather their separating hyperplane, so there is not much room for manual adjustements. +If you need to focus on Sensitivity or Specificity, use a different model that allows maximizing that function directly, or that allows predicting the class probabilities (thinking Logistic Regressions, Tree based methods, for example)",1.2,True,1,6441 +2019-12-09 16:29:01.433,conda environment: does each new conda environment needs a new kernel to work? How can I have specific libraries for all my environments?,"I use ubuntu (through Windows Subsystem For Linux) and I created a new conda environment, I activated it and I installed a library in it (opencv). However, I couldn't import opencv in Jupyter lab till I created a new kernel that it uses the path of my new conda environment. So, my questions are: + +Do I need to create a new kernel every time I create a new conda environment in order for it to work? I read that in general we should use kernels for using different versions of python, but if this is the case, then how can I use a specific conda environment in jupyter lab? Note that browsing from Jupyter lab to my new env folder or using os.chdir to set up the directory didn't work. +Using the new kernel that it's connected to the path of my new environment, I couldn't import matplotlib and I had to activate the new env and install there again the matplotlib. However, matplotlib could be imported when I was using the default kernel Python3. +Is it possible to have some standard libraries to use them with all my conda environments (i.e. install some libraries out of my conda environments, like matplotlib and use them in all my enviroments) and then have specific libraries in each of my environments? I have installed some libraries through the base environment in ubuntu but I can't import these in my new conda environment. + +Thanks in advance!","To my best understanding: +You need ipykernel in each of the environments so that jupyter can import the other library. +In my case, I have a new environment called TensorFlow, then I activate it and install the ipykernel, and then add it to jupyter kernelspec. Finally I can access it in jupyter no matter the environment is activated or not.",0.2012947653214861,False,1,6442 +2019-12-11 15:38:28.387,JupyterLab - how to find out which python venv is my session running on?,"I am running venv based kernel and I am getting trouble in returning a proper answer from which python statement from my JupyterLab notebook. When running this command from terminal where I have my venv activated it works (it returns a proper venv path ~/venvs/my_venv/bin/python), but it does not work in the notebook. +!which python +returns the host path: +/usr/bin/python +I have already tried with os.system() and subprocess, but with no luck. +Does anyone know how to execute this command from the Jupyter notebook?","It sounds like you are starting the virtual environment inside the notebook, so that process's PATH doesn't reflect the modifications made by the venv. Instead, you want the path of the kernel that's actually running: that's sys.executable.",1.2,True,2,6443 +2019-12-11 15:38:28.387,JupyterLab - how to find out which python venv is my session running on?,"I am running venv based kernel and I am getting trouble in returning a proper answer from which python statement from my JupyterLab notebook. When running this command from terminal where I have my venv activated it works (it returns a proper venv path ~/venvs/my_venv/bin/python), but it does not work in the notebook. +!which python +returns the host path: +/usr/bin/python +I have already tried with os.system() and subprocess, but with no luck. +Does anyone know how to execute this command from the Jupyter notebook?","maybe it's because you are trying to run the command outside venv +try source /path/to/venv/bin/active first and then try which python",-0.2012947653214861,False,2,6443 +2019-12-12 05:29:34.497,Can a db handle be passed from a perl script to a python script?,I've been trying to look for ways to call my python script from my perl script and pass the database handle from there while calling it. I don't want to establish another connection in my python script and just use the db handle which is being used by the perl script. Is it even possible and if yes then how?,"There answer is that almost all databases (Oracle, MySQL, Postgresql) will NOT allow you to pass open DB connections between processes (even parent/child). This is a limit on the databases connection, which will usually be associated with lot of state information. +If it was possible to 'share' such a connection, it will be a challenge for the system to know where to ship the results for queries sent to the database (will the result go to the parent, or to the child ?). +Even if it is possible somehow to forward connection between processes, trying to pass a complex object (database connection is much more the socket) between Perl (usually DBI), and Python is close to impossible. +The 'proper' solution is to pass the database connection string, username, and password to the Python process, so that it can establish it's own connection.",1.2,True,1,6444 +2019-12-12 10:03:34.553,Error when installing Tensorflow - Python 3.8,"I'm new to programming and following a course where I must install Tensorflow. The issue is that I'm using Python 3.8 which I understand isn't supported by Tensorflow. +I've downloaded Python 3.6 but I don't know how to switch this as my default version of python. +Would it be best to set up a venv using python 3.6 for my program and install Tensorflow in this venv? +Also, I using Windows and Powershell.","If you don't want to use Anaconda or virtualenv, then actually multiple Python versions can live side by side. I use Python38 as my default and Python35 for TensorFlow until they release it for Python38. If you wish to use the ""non-default"" Python, just invoke with the full path of the python.exe (or create a shortcut/batch file for it). Python then will take care of using the correct Python libs for that version.",0.0,False,2,6445 +2019-12-12 10:03:34.553,Error when installing Tensorflow - Python 3.8,"I'm new to programming and following a course where I must install Tensorflow. The issue is that I'm using Python 3.8 which I understand isn't supported by Tensorflow. +I've downloaded Python 3.6 but I don't know how to switch this as my default version of python. +Would it be best to set up a venv using python 3.6 for my program and install Tensorflow in this venv? +Also, I using Windows and Powershell.","it would have been nice if you would have the share the error screenshot +though as per i got the case +tensorflow work in both 3.8 and 3.6 just you have to check that you have 64bit version not 32 bit +you can acess both version from thier respective folder no need to install a venv",0.0,False,2,6445 +2019-12-12 14:51:24.720,How to search pattern in big binary files efficiently,"I have several binary files, which are mostly bigger than 10GB. +In this files, I want to find patterns with Python, i.e. data between the pattern 0x01 0x02 0x03 and 0xF1 0xF2 0xF3. +My problem: I know how to handle binary data or how I use search algorithms, but due to the size of the files it is very inefficient to read the file completely first. That's why I thought it would be smart to read the file blockwise and search for the pattern inside a block. +My goal: I would like to have Python determine the positions (start and stop) of a found pattern. Is there a special algorithm or maybe even a Python library that I could use to solve the problem?","The common way when searching a pattern in a large file is to read the file by chunks into a buffer that has the size of the read buffer + the size of the pattern - 1. +On first read, you only search the pattern in the read buffer, then you repeatedly copy size_of_pattern-1 chars from the end of the buffer to the beginning, read a new chunk after that and search in the whole buffer. That way, you are sure to find any occurence of the pattern, even if it starts in one chunk and ends in next.",0.9950547536867304,False,1,6446 +2019-12-13 09:54:52.117,Add manually packages to PyCharm in Windows,"I'm using PyCharm. I try to install Selenium but I have a problem with proxy. I try to add packages manually to my project/environment but I don't know how. +I downloaded files with Selenium. Could you tell me how to add this package to Project without using pip?","open pycharm +click on settings (if u use mac click on preference ) +click project +then click projecti nterpreter +click the + button on the bottom of the window you can see a new window search Selenium package and install",0.0,False,1,6447 +2019-12-13 14:48:25.083,Implementing trained-model on camera,I just trained my model successfully and I have some checkpoints from the training process. Can you explain to me how to use this data to recognize the objects live with the help of a webcam?,"Congratulations :) +First of all, you use the model to recognize the objects, the model learned from the data, minor detail. +It really depends on what you are aiming for, as the comment suggest, you should probably provide a bit more information. +The simplest setup would probably be to take an image with your webcam, read the file, pass it to the model and get the predictions. If you want to do it live, you are gonna have the stream from the webcam and then pass the images to the model.",0.0,False,1,6448 +2019-12-15 02:32:28.747,8Puzzle game with A* : What structure for the open set?,"I'm developing a 8 Puzzle game solver in python lately and I need a bit of help +So far I finished coding the A* algorithm using Manhattan distance as a heuristic function. +The solver runs and find ~60% of the solutions in less than 2 seconds +However, for the other ~40%, my solver can take up to 20-30 minutes, like it was running without heuristic. +I started troubleshooting, and it seems that the openset I use is causing some problems : + +My open set is an array +Each iteration, I loop through the openset to find the lowest f(n) (complexity : O(n) ) + +I have the feeling that O(n) is way too much to run a decent A* algorithm with such memory used so I wanted to know how should I manage to make the openset less ""time eater"" +Thank you for your help ! Have a good day +EDIT: FIXED +I solved my problem which was in fact a double problem. +I tried to use a dictionary instead of an array, in which I stored the nodes by their f(n) value and that allowed me to run the solver and the ~181000 possibilities of the game in a few seconds +The second problem (I didn't know about it because of the first), is that I didn't know about the solvability of a puzzle game and as I randomised the initial node, 50% of the puzzles couldn't be solved. That's why it took so long with the openset as the array.","The open set should be a priority queue. Typically these are implemented using a binary heap, though other implementations exist. +Neither an array-list nor a dictionary would be efficient. + +The closed set should be an efficient set, so usually a hash table or binary search tree, depending on what your language's standard library defaults to. +A dictionary (aka ""map"") would technically work, but it's conceptually the wrong data-structure because you're not mapping to anything. An array-list would not be efficient.",1.2,True,1,6449 +2019-12-15 14:24:50.807,My python scripts using selenium don't work anymore. Chrome driver version problem,"My scripts don't work anymore and I can't figure it out. +It is a chrome version problem apparently... But I don't know how to switch to another version (not the latest?) Does exist another way? +My terminal indicates : +Traceback (most recent call last): +File ""/Users/.../Documents/SCRIPTS/PYTHON/Scripts/# -- coding: utf-8 --.py"", line 21, in + driver = webdriver.Chrome() +File ""/opt/anaconda3/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py"", line 81, in init + desired_capabilities=desired_capabilities) +File ""/opt/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py"", line 157, in init + self.start_session(capabilities, browser_profile) +File ""/opt/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py"", line 252, in start_session + response = self.execute(Command.NEW_SESSION, parameters) +File ""/opt/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py"", line 321, in execute + self.error_handler.check_response(response) +File ""/opt/anaconda3/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py"", line 242, in check_response + raise exception_class(message, screen, stacktrace) +selenium.common.exceptions.SessionNotCreatedException: Message: session not created: Chrome version must be between 71 and 75 +(Driver info: chromedriver=2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e),platform=Mac OS X 10.14.5 x86_64) +Any idea?","This possibly happens, as your Chrome Browser or Chromium may be updated to newer versions automatically. But you still run your selenium scripts using the old version of the chromedriver. +Check the current version of your Google chrome or Chromium, then download the chromedriver for that specific version. +Then your scripts may work fine!",0.0,False,1,6450 +2019-12-15 19:29:16.370,Add new data to model sklearn: SGD,"I made models with sklearn, something like this: +clf = SGDClassifier(loss=""log"") +clf.fit(X, Y) +And then now I would like to add data to learn for this model, but with more important weight. I tried to use partial_fit with sample_weight bigger but not working. Maybe I don't use fit and partial_fit as good, sorry I'm beginner... +If someone know how to add new data I could be happy to know it :) +Thanks for help.","Do you think it has other way to do a first learning and then add new data more important for the model? Keras? +Thanks guys",0.0,False,1,6451 +2019-12-16 16:28:11.120,RPA : How to do back-end automation using RPA tools?,"I would like to know how back-end automation is possible through RPA. +I'd be interested in solving this scenario relative to an Incident Management Application, in which authentication is required. The app provide: + +An option useful to download/export the report to a csv file +Sort the csv as per the requirement +Send an email with the updated csv to the team + +Please let me know how this possible through RPA and what are those tools +available in RPA to automate this kind of scenario?","There are several ways to do it. It is especially useful when your backed are 3rd party applications where you do not have lot of control. Many RPA products like Softomotive WinAutomation, Automation Anywhere, UiPath etc. provide file utilities, excel utilities, db utilities, ability to call apis, OCR capabilities etc., which you can use for backed automation.",1.2,True,2,6452 +2019-12-16 16:28:11.120,RPA : How to do back-end automation using RPA tools?,"I would like to know how back-end automation is possible through RPA. +I'd be interested in solving this scenario relative to an Incident Management Application, in which authentication is required. The app provide: + +An option useful to download/export the report to a csv file +Sort the csv as per the requirement +Send an email with the updated csv to the team + +Please let me know how this possible through RPA and what are those tools +available in RPA to automate this kind of scenario?","RPA tools are designed to automate mainly front-end activities by mimicing human actions. It can be done easily using any RPA tool. +However, if you are interested in back-end automation the first question would be, if specific application has an option to interact in the way you want through the back-end/API? +If yes, in theory you could develop RPA robot to run pre-developed back-end script. However, if all you need would be to run this script, creating robot for this case may be redundant.",0.3869120172231254,False,2,6452 +2019-12-16 22:57:12.960,google colab /bin/bash: 'gdrive/My Drive/path/myfile : Permission denied,"I'm trying to run a file (an executable) in google colab I mounted the drive and everything is ok however whenever i try to run it using : +! 'gdrive/My Drive/path/myfile' +I get this output of the cell: +/bin/bash: 'gdrive/My Drive/path/myfile : Permission denied +any ideas how to overcome the permissions?","you first need to permit that file/folder as: + chmod 755 file_name",1.2,True,1,6453 +2019-12-17 00:12:24.427,Accessing SAS(9.04) from Anaconda,"We are doing a POC to see how to access SAS data sets from Anaconda +All documentation i find says only SASpy works with SAS 9.4 or higher +Our SAS version is 9.04.01M3P062415 +Can this be done? If yes any documentation in this regard will be highly appreciated +Many thanks in Advance!","SAS datasets are ODBC compliant. SasPy is for running SAS code. If the goal is to read SAS datasets, only, use ODBC or OleDb. I do not have Python code but SAS has a lot of documentation on doing this using C#. Install the free SAS ODBC drivers and read the sas7bdat. The drivers are on the SAS website. +Writing it is different but reading should be fine. You will lose some aspects of the dataset but data will come through.",0.0,False,1,6454 +2019-12-17 09:45:19.723,How do you write to a file without changing its ctime?,"I was hoping that just using something like +with open(file_name, ""w"") as f: +would not change ctime if the file already existed. Unfortunately it does. +Is there a version which will leave the ctime intact? +Motivation: +I have a file that contains a list of events. I would like to know how old the oldest event is. It seems this should be the files ctime.","Because fopen works that way when using 'w' as an option. From the manual: + +""w"" write: Create an empty file for output operations. + If a file with the same name already exists, its contents are discarded and the file is treated as a new empty file. + +If you don't want to create a new file use a+ to append to the file. This leaves the create date intact.",0.1016881243684853,False,2,6455 +2019-12-17 09:45:19.723,How do you write to a file without changing its ctime?,"I was hoping that just using something like +with open(file_name, ""w"") as f: +would not change ctime if the file already existed. Unfortunately it does. +Is there a version which will leave the ctime intact? +Motivation: +I have a file that contains a list of events. I would like to know how old the oldest event is. It seems this should be the files ctime.","Beware, ctime is not the creation time but the inode change time. It is updated each time you write to the file, or change its meta-data, for example rename it. So we have: + +atime : access time - each time the file is read +mtime : modification time - each time file data is change (file is written to) +ctime : change time - each time something is changed in the file, either data or meta-data like name or (hard) links + +I know no way to reset the ctime field because even utimes and its variant can only set the atime and mtime (and birthtime for file systems that support it like BSD UFS2) - except of course changing the system time with all the involved caveats...",1.2,True,2,6455 +2019-12-17 10:48:24.980,"Can you change the precision globally of a piece of code in Python, as a way of debugging it?","I am solving a system of non-linear equations using the Newton Raphson Method in Python. This involves using the solve(Ax,b) function (spsolve in my case, which is for sparse matrices) iteratively until the error or update reduces below a certain threshold. My specific problem involves calculating functions such as x/(e^x - 1) , which are badly calculated for small x by Python, even using np.expm1(). +Despite these difficulties, it seems like my solution converges, because the error becomes of the order of 10^-16. However, the dependent quantities, do not behave physically, and I suspect this is due to the precision of these calculations. For example, I am trying to calculate the current due to a small potential difference. When this potential difference becomes really small, this current begins to oscillate, which is wrong, because currents must be conserved. +I would like to globally increase the precision of my code, but I'm not sure if that's a useful thing to do since I am not sure whether this increased precision would be reflected in functions such as spsolve. I feel the same about using the Decimal library, which would also be quite cumbersome. Can someone give me some general advice on how to go about this or point me towards a relevant post? +Thank you!","You can try using mpmath, but YMMV. generally scipy uses double precision. For a vast majority of cases, analyzing the sources of numerical errors is more productive than just trying to reimplement everything with higher widths floats.",1.2,True,1,6456 +2019-12-17 20:15:22.827,BigQuery - Update Tables With Changed/Deleted Records,"Presently, we send entire files to the Cloud (Google Cloud Storage) to be imported into BigQuery and do a simple drop/replace. However, as the file sizes have grown, our network team doesn't particularly like the bandwidth we are taking while other ETLs are also trying to run. As a result, we are looking into sending up changed/deleted rows only. +Trying to find the path/help docs on how to do this. Scope - I will start with a simple example. We have a large table with 300 million records. Rather than sending 300 million records every night, send over X million that have changed/deleted. I then need to incorporate the change/deleted records into the BigQuery tables. +We presently use Node JS to move from Storage to BigQuery and Python via Composer to schedule native table updates in BigQuery. +Hope to get pointed in the right direction for how to start down this path.","Stream the full row on every update to BigQuery. +Let the table accommodate multiple rows for the same primary entity. +Write a view eg table_last that picks the most recent row. +This way you have all your queries near-realtime on real data. +You can deduplicate occasionally the table by running a query that rewrites self table with latest row only. +Another approach is if you have 1 final table, and 1 table which you stream into, and have a MERGE statement that runs scheduled every X minutes to write the updates from streamed table to final table.",0.3869120172231254,False,1,6457 +2019-12-21 00:05:12.757,"In Databricks python notebook, how to import a file1 objects resides in different directory than the file2?","Note: I did research on this over web but all of them are pointing to the solution which works on prem/desktops. This case is on databricks notebook, I referred databricks help guide but could not find the solution. +Dear all, +In my local desktop i used to import the objects from other python files by referring their absolute path such as +""from dir.dira.dir0.file1 import *"" +But in Databricks python notebook i'm finding it difficult to crack this step since 2 hours. Any help is appreciated. +Below is how my command shows, +from dbfs.Shared.ABC.models.NJ_WrkDir.test_schdl import * +also tried below ways, none of them worked +from dbfs/Shared/ABC/models/NJ_WrkDir/test_schdl import * +from \Shared\ABC\models\NJ_WrkDir\test_schdl import * +from Shared/ABC/models/NJ_WrkDir/test_schdl import * +from Shared.ABC.models.NJ_WrkDir.test_schdl import * +The error messages shows: +ModuleNotFoundError: No module named 'Shared +ModuleNotFoundError: No module named 'dbfs +SyntaxError: unexpected character after line continuation character + File """", line 2 + from \Shared\ABC\models\NJ_WrkDir\test_schdl import * + ^ +Thank you!","The solution is, include the command in child databricks python notebook as +""%run /path/parentfile"" +(from where we want to import the objects from)",0.0,False,1,6458 +2019-12-21 11:10:31.507,Calculate mean across one specific dimension of a 4D tensor in Pytorch,"I have a PyTorch video feature tensor of shape [66,7,7,1024] and I need to convert it to [1024,66,7,7]. How to rearrange a tensor shape? Also, how to perform mean across dimension=1? i.e., after performing mean of the dimension with size 66, I need the tensor to be [1024,1,7,7]. +I have tried to calculate the mean of dimension=1 but I failed to replace it with the mean value. And I could not imagine a 4D tensor in which one dimension is replaced by its mean. +Edit: + I tried torch.mean(my_tensor, dim=1). But this returns me a tensor of shape [1024,7,7]. The 4D tensor is being converted to 3D. But I want it to remain 4D with shape [1024,1,7,7]. +Thank you very much.","The first part of the question has been answered in the comments section. So we can use tensor.transpose([3,0,1,2]) to convert the tensor to the shape [1024,66,7,7]. +Now mean over the temporal dimension can be taken by +torch.mean(my_tensor, dim=1) +This will give a 3D tensor of shape [1024,7,7]. +To obtain a tensor of shape [1024,1,7,7], I had to unsqueeze in dimension=1: +tensor = tensor.unsqueeze(1)",1.2,True,1,6459 +2019-12-21 17:16:30.333,False Positive Rate in Confusion Matrix,"I was trying to manually calculate TPR and FPR for the given data. But unfortunately I dont have any false positive cases in my dataset and even no true positive cases. +So I am getting divided by zero error in pandas. So I have an intuition that fpr=1-tpr. Please let me know my intuition is correct if not let know how to fix this issue. +Thank you","It is possible to have FPR = 1 with TPR = 1 if your prediction is always positive no matter what your inputs are. +TPR = 1 means we predict correctly all the positives. FPR = 1 is equivalent to predicting always positively when the condition is negative. +As a reminder: + +FPR = 1 - TNR = [False Positives] / [Negatives] +TPR = 1 - FNR = [True Positives] / [Positives]",0.0,False,1,6460 +2019-12-22 01:56:37.603,Import python modules in a completely different directory,"I am writing a script that automates the use of other scripts. I've set it up to automatically import other modules from .py files stored in a directory called dependencies using importlib.import_modules() +Originally, I had dependencies as a subdirectory of the root of my application, and this worked fine. However, it's my goal to have the dependencies folder stored potentially anywhere a user would like. In my personal example, it's located in my dropbox folder while my script is run from a different directory entirely. +I cannot for the life of me seem to get the modules to be detected and imported anymore and I'm out of ideas. +Would someone have a better idea of how to achieve this? +This is an example of the path structure: + +E: +|_ Scripts: +| |_ Mokha.py +| +|_ Dropbox: +| |_ Dependencies: +| |_ utils.py + +Here's my code for importing: (I'm reading in a JSON file for the dependency names and looping over every item in the list) + +def importPythonModules(pythonDependencies): + chdir(baseConfig[""dependencies-path]) + for dependency in pythonDependencies: + try: + moduleImport = dependency + module = importlib.import_module(moduleImport) + modules[dependency] = module + print(""Loaded module: %s"" % (dependency)) + except ModuleNotFoundError as e: + print(e) + raise Exception(""Error importing python dependecies."") + chdir(application_path) + +The error I get is No module named 'utils' +I've tried putting an init.py in both the dependencies folder, the root of my dropbox, and both at the same time to no avail. +This has got to be possible, right?","UPDATE: I solved it. +sys.path.append(baseConfig['dependencies-path']) +Not super happy with the solution but it'll work for now.",0.0,False,1,6461 +2019-12-22 06:06:18.430,How to put images in a linked list in python,"I have created a class Node having two data members: data and next. +I have created another class LinkedList to having a data member: head +Now I want to store an image in the node but I have no idea how to do it. The syntax for performing this operation would be very much helpful.","PIL is the Python Imaging Library which provides the python interpreter with image editing capabilities. +USE from PIL import Image after installing. +Windows: Download the appropriate Pillow package according to your python version. Make sure to download according to the python version you have. +pip install Pillow for Linux users. +Then u can easily add image to your linked list by assigning it to a variable",0.0,False,1,6462 +2019-12-22 23:43:11.057,What cause pip did not work after reinstall python?,"I had Python 3.7.4 in D:\python3.7.4 before but for some reason, I uninstalled it today, then I changed the folder name to D:\python3.7.5 and installed python 3.7.5 in it, then, when I try to use pip in cmd I got a fatal error saying + +Unable to create processing using '""Unable to create process using '""d:\python3.7.4\python.exe"" ""D:\Python3.7.5\Scripts\pip.exe""' + +I tried to change all things contain python3.7.4 in environment variable to python3.7.5 but the same error still exists, does anyone know how to fix this? +Thanks","Try to create a new folder and run the installation there. +This should work, as I did the same myself to go install 2 different versions before",0.0,False,1,6463 +2019-12-23 08:37:50.350,"How to create a registration form in Django that is divided into two parts, such that one call fill up the second part only after email verification?","I have the logic for email verification, but I am not sure how to make it such that only after clicking the link on the verification email, the user is taken to the second page of the form, and only after filling the second part the user is saved.","I would say that much better idea is to save user to database anyway, but mark him as inactive (simple boolean field in model will be enough). Upon registration, before confirming email mark him as inactive and as soon as he confirms email and fills second part of your registration form that you mentioned change that boolean value to true. If you don't want to keep inactive users data in your database, you can set up for example cron, that will clean users that haven't confirmed their email for few days.",1.2,True,1,6464 +2019-12-23 10:03:28.647,python multiprocess read data from disk,"it confused me long time. +my program has two process, both read data from disk, disk max read speed 10M/s +1. if two process both read 10M data, is two process spend time same with one process read twice? +2. if two process both read 5M data, two process read data spend 1s, one process read twice spend 1s, i know multi process can save time from IO, but the spend same time in IO, multi process how to save time?","It's not possible to increase disk read speed by adding more threads. With 2 threads reading you will get at best 1/2 the speed per thread (in practice even less), with 3 threads - 1/3 the speed, etc. +With disk I/O it is the difference between sequential and random access speed that is really important. For example, sequential read speed can be 10 MB/s, and random read just 10 KB/s. This is the case even with the latest SSD drives (although the ratio may be less pronounced). +For that reason you should prefer to read from disk sequentially from only one thread at a time. Reading the file in 2 threads in parallel will not only reduce the speed of each read by half, but will further reduce because of non-sequential (interleaved) disk access. + +Note however, that 10 MB is really not much; modern OSes will prefetch the entire file into the cache, and any subsequent reads will appear instantaneous.",0.0,False,1,6465 +2019-12-23 20:07:26.647,How to move Python virtualenv to different system (computer) and use packages present in Site-packages,"I am making a python 3 application (flask based) and for that I created a virtualenv in my development system, installed all packages via pip and my app worked fine. +But when I moved that virtualenv to a different system (python3 installed) and ran my application with the absolute path of my virtualenv python (c:/......./myenv/Scripts/python.exe main.py) then it threw the errors that packages are not installed, +I activated the virtualenv and used pip freeze and there were no packages were installed. +But under virtualenv there is 'Site-Packages' (myenv -> lib -> site-packages) , all my installed packages were persent there. +My Question is how to use the packages that are inside 'site-packages' even after moving the virtualenv to different system in Python 3.","You Must not copy & paste venv, even in the same system. +If you install new package in venv-copied, then it would installed in venv-original. Becaus settings are bound to specific directory.",0.0,False,2,6466 +2019-12-23 20:07:26.647,How to move Python virtualenv to different system (computer) and use packages present in Site-packages,"I am making a python 3 application (flask based) and for that I created a virtualenv in my development system, installed all packages via pip and my app worked fine. +But when I moved that virtualenv to a different system (python3 installed) and ran my application with the absolute path of my virtualenv python (c:/......./myenv/Scripts/python.exe main.py) then it threw the errors that packages are not installed, +I activated the virtualenv and used pip freeze and there were no packages were installed. +But under virtualenv there is 'Site-Packages' (myenv -> lib -> site-packages) , all my installed packages were persent there. +My Question is how to use the packages that are inside 'site-packages' even after moving the virtualenv to different system in Python 3.",Maybe you can consider using pipenv to control the virtualenvs on different computer or environment.,0.0,False,2,6466 +2019-12-24 00:29:06.477,How do I allow a file to be accessible from all directories?,"I have a python program which is an interpreter, for a language that I have made. It is called cbc.py, and it is in a certain directory. Now, I want to know how I can call it, along with sys.argv arguments (like python3 cbc.py _FILENAME_TO_RUN_) in any directory. I have done research on the .bashrc file and on the PATH variable, but I can't find anything that really helps me with my problem. Could someone please show me how to resolve my problem?","You need to make your script executable first and then add it to your PATH. +If you have your python script at ~/path/to/your/script/YOUR_SCRIPT_NAME: + +add #!/usr/bin/python3 at the top of you script, +give executable permision to your script using sudo chmod a+x YOUR_SCRIPT_NAME, +edit ~/.bashrc to add your script path, e.g. echo PATH=""$HOME/path/to/your/script:$PATH"" >> ~/.bashrc, +restart or re-login or run source ~/.bashrc, +now you can access your script via YOUR_SCRIPT_NAME anywhere.",0.0,False,1,6467 +2019-12-24 14:27:11.827,Blueprism-like spying and bot development,"Blueprism gives the possibility to spy elements (like buttons and textboxes) in both web-browsers and windows applications. How can I spy (windows-based only) applications using Python, R, Java, C++, C# or other, anything but not Blueprism, preferrably opensource. + +For web-browsers, I know how to do this, without being an expert. Using Python or R, for example, I can use Selenium or RSelenium, to spy elements of a website using different ways such as CSS selector, xpath, ID, Class Name, Tag, Text etc. +But for Applications, I have no clue. BluePrism has mainly two different App spying modes which are WIN32 and Active Accessibility. How can I do this type of spying and interacting with an application outside of Blueprism, preferrably using an opensource language? + +(only interested in windows-based apps for now) +The aim is of course to create robots able to navigate the apps as a human would do.","There is a free version of Blue Prism now :) Also Blue Prism uses win32, active accessibility and UI Automation which is a newer for of the older active accessibility. +To do this yourself without looking into Blue Prism you would need to know how to use UIA with C#/VB.new or C++. There are libraries however given that Blue Prism now has a free version I would recommend using that. Anything specific can be developed withing a code stage within Blue Prism.",0.0,False,1,6468 +2019-12-25 06:36:41.020,how to use SVM to classify if the shape of features for each sample is matrix? Is it simply to reshape the matrix to long vector?,I have 120 samples and the shape of features for each sample is matrix of 15*17. how to use SVM to classify? Is it simply to reshape the matrix to long vector?,"Yes, that would be the approach I would recommend. It is essentially the same procedure that is used when utilizing images in image classification tasks, since each image can be seen as a matrix. +So what people do is to write the matrix as a long vector, consisting of every column concatenated to one another. +So you can do the same here.",0.0,False,1,6469 +2019-12-25 14:11:55.277,How can I fetch data from a website to my local Django Website?,"I am rather new to Django and I need to fetch some data from a website. For example I want the top ten posts of the day from Reddit. I know of a ""request"" module for the same.But I am not sure where and how should I implement it and will it be important to store the data in a model or not.","You can create a helper class named like network.py and implement functions to fetch the data. +If you want to store them in the database you can create appropriate models otherwise you can directly import and call the function and use the data returned from network.py in your view.",0.0,False,1,6470 +2019-12-25 14:33:59.377,How to upload a file to pythonanywhere using react native?,"I am trying to build an app through react-native wherein I need to upload a JSON file to my account folder hosted on pythonanywhere. +Can you please tell me how can I upload a JSON file to the pythonanywhere folder through react-native?",The web framework that you're using will have documentation about how to create a view that can accept filee uploads. Then you can use the fetch API in your javascript to send the file to it.,0.6730655149877884,False,1,6471 +2019-12-26 16:59:19.517,Pycharm can't find python.exe,"No Python at 'C:\Users\Mr_Le\AppData\Local\Programs\Python\Python38-32\python.exe' +Any time I try to run my code it keeps prompting me this ^^^ but I had recently deleted Python 3.8 to downgrade to Python 3.6 and just installed Python 3.6 to run pytorch. +Does anyone know how to fix this?","1.In your windows search bar find python 3.9.8. +[Searching for Windows][1] +[1]: https://i.stack.imgur.com/vNMxT.png + +Right click on your the app + +Click on App Settings +[Your settings will populate][2] +[2]: https://i.stack.imgur.com/E4yM3.png + +Scroll down on this page +[][3] +[3]: https://i.stack.imgur.com/HFc1J.png + +Hit the Repair box + +Try to run your python script again after restarting all your programs",0.0,False,2,6472 +2019-12-26 16:59:19.517,Pycharm can't find python.exe,"No Python at 'C:\Users\Mr_Le\AppData\Local\Programs\Python\Python38-32\python.exe' +Any time I try to run my code it keeps prompting me this ^^^ but I had recently deleted Python 3.8 to downgrade to Python 3.6 and just installed Python 3.6 to run pytorch. +Does anyone know how to fix this?","For other users: just check the ""C:\Users<>\AppData\Local\Programs\Python"" folder on your PC and remove any folders belonging to previous installations of Python. Also check if environmental variables are correct.",0.0,False,2,6472 +2019-12-26 20:34:44.420,Access output of intermediate layers in Tensor-flow 2.0 in eager mode,"I have CNN that I have built using on Tensor-flow 2.0. I need to access outputs of the intermediate layers. I was going over other stackoverflow questions that were similar but all had solutions involving Keras sequential model. +I have tried using model.layers[index].output but I get + +Layer conv2d has no inbound nodes. + +I can post my code here (which is super long) but I am sure even without that someone can point to me how it can be done using just Tensorflow 2.0 in eager mode.","The most straightforward solution would go like this: +mid_layer = model.get_layer(""layer_name"") +you can now treat the ""mid_layer"" as a model, and for instance: +mid_layer.predict(X) +Oh, also, to get the name of a hidden layer, you can use this: +model.summary() +this will give you some insights about the layer input/output as well.",0.0,False,1,6473 +2019-12-27 02:38:58.220,"Given a midpoint, gradient and length. How do I plot a line segment of specific length?","I am trying to plot the endpoints of the line segment which is a tangent to a circle in Python. +I know the circle has center of (A, B), and a radius of r. The point at which I want to find the tangent at is (a, b). I want the tangent to be a segment of length c. How do I write a code which allows me to restrict the length of the line? +I have the equation of the tangent to be y = (-(B - b)/(A - a))(x - a) + b. So I know how to plot the two endpoints if the length of the segment did not matter. But how would I determine the x-coordinates of the point? Is there some sort of command which allows me to limit the length of a line? +Thank you!!!","I don't know thonny, and it sounds like your implementation will depend a bit on the context of this computation. +That said, it sounds like what you're looking for is the two points of intersection of your tangent line and a (new, conceptual) cicle with a given radius centered on (a,b). You should be able to put together the algebraic expression for those points, and simplify it into something tidy. Watch out for special cases though, where the slope of the tangent is undefined (or where it's zero).",0.0,False,1,6474 +2019-12-27 06:26:33.787,How to match duplicates and if match how to remove second one in list in python?,"I have the list of APIs, +Input = [WriteConsoleA, WSAStartup, RegCloseKey, RegCloseKey, RegCloseKey, NtTerminateProces, RegCloseKey] +expected output = [WriteConsoleA, WSAStartup, RegCloseKey, NtTerminateProces, RegCloseKey]",you can simply convert set(list) i.e. set(Input) to remove all the duplicates.,0.0,False,1,6475 +2019-12-27 09:10:51.553,TextBlob Naive Bayes classifier for neutral tweets,"I am doing a small project on sentiment analysis using TextBlob. I understand there are are 2 ways to check the sentiment of tweet: + +Tweet polarity: Using it I can tell whether the tweet is positive, negative or neutral +Training a classifier: I am using this method where I am training a TextBlob Naive Bayes classifier on positive and negative tweets and using the classifier to classify tweet either as 'positive' or 'negative'. + +My question is, using the Naive bayes classifier, can I also classify the tweet as 'neutral' ? In other words, can the 'sentiment polarity' defined in option 1 can somehow be used in option 2 ?","If you have only two classes, Positive and Negative, and you want to predict if a tweet is Neutral, you can do so by predicting class probabilities. +For example, a tweet predicted as 80% Positive remains Postive. However, a tweet predicting as 50% Postive could be Neutral instead.",0.0,False,1,6476 +2019-12-27 12:55:42.747,Sentiment Classification using Doc2Vec,"I am confused as to how I can use Doc2Vec(using Gensim) for IMDB sentiment classification dataset. I have got the Doc2Vec embeddings after training on my corpus and built my Logistic Regression model using it. How do I use it to make predictions for new reviews? sklearn TF-IDF has a transform method that can be used on test data after training on training data, what is its equivalent in Gensim Doc2Vec?","To get a vector for an unseen document, use vector = model.infer_vector([""new"", ""document""]) +Then feed vectorinto your classifier: preds = clf.predict([vector]).",0.2012947653214861,False,1,6477 +2019-12-28 06:27:45.017,How can I embed a python file or code in HTML?,"I am working on an assignment and am stuck with the following problem: +I have to connect to an oracle database in Python to get information about a table, and display this information for each row in an .html-file. Hence, I have created a python file with doctype HTML and many many ""print"" statements, but am unable to embed this to my main html file. In the next step, I have created a jinja2 template, however this passes the html template data (incl. ""{{ to be printed }}"") to python and not the other way round. I want to have the code, which is executed in python, to be implemented on my main .html file. +I can't display my code here since it is an active assignment. I am just interested in general opinions on how to pass my statements from python (or the python file) into an html file. I can't find any information about this, only how to escape html with jinja. +Any ideas how to achieve this? +Many thanks.","Thanks for the suggestions. What I have right now is a perfectly working python file containing jinja2 and the html output I want, but as a python file. When executing the corresponding html template, the curly expressions {{name}} are displayed like this, and not as the functions executed within the python file. Hence, I still have to somehow tell my main html file to execute this python script on my webpage, which I cannot manage so far. +Unfortunately, it seems that we are not allowed to use flask, only jinja and django.",0.0,False,2,6478 +2019-12-28 06:27:45.017,How can I embed a python file or code in HTML?,"I am working on an assignment and am stuck with the following problem: +I have to connect to an oracle database in Python to get information about a table, and display this information for each row in an .html-file. Hence, I have created a python file with doctype HTML and many many ""print"" statements, but am unable to embed this to my main html file. In the next step, I have created a jinja2 template, however this passes the html template data (incl. ""{{ to be printed }}"") to python and not the other way round. I want to have the code, which is executed in python, to be implemented on my main .html file. +I can't display my code here since it is an active assignment. I am just interested in general opinions on how to pass my statements from python (or the python file) into an html file. I can't find any information about this, only how to escape html with jinja. +Any ideas how to achieve this? +Many thanks.","You can't find information because that won't work. Browser cannot run python, meaning that they won't be able to run your code if you embed it into an html file. The setup that you need is a backend server that is running python (flask is a good framework for that) that will do some processing depending on the request that is being sent to it. It will then send some data to a template processor (jinja in this case work well with flask). This will in turn put the data right into the html page you want to generate. Then this html page will be returned to the client making the request, which is something the browser will understand and will show to the user. If you want to do some computation dynamically on the browser you will need to use javascript instead which is something a browser can run (since its in a sandbox mode). +Hope it helps!",0.0,False,2,6478 +2019-12-30 03:00:38.240,How to give an AI controls in a video game?,"So I made Pong using PyGame and I want to use genetic algorithms to have an AI learn to play the game. I want it to only know the location of its paddle and the ball and controls. I just don't know how to have the AI move the paddle on its own. I don't want to do like: ""If the ball is above you, go up."" I want it to just try random stuff until it learns what to do. +So my question is, how do I get the AI to try controls and see what works?","So you'd want as the AI input the position of the paddle, and the position of the ball. The AI output is two boolean output whether the AI should press up or down button on the next simulation step. +I'd also suggest adding another input value, the ball's velocity. Otherwise, you would've likely needed to add another input which is the location of the ball in the previous simulation step, and a much more complicated middle layer for the AI to learn the concept of velocity.",0.0,False,1,6479 +2019-12-30 07:27:06.787,How to get recent data from bigtable?,"I need to get 50 latest data (based on timestamp) from BigTable. +I get the data using read_row and filter using CellsRowLimitFilter(50). But it didn't return the latest data. It seems the data didn't sorted based on timestamp? how to get the latest data? +Thank you for your help.",Turns out the problem was on the schema. It wasn't designed for timeseries data. I should have create the rowkey with id#reverse_timestamp and the data will be sorted from the latest. Now I can use CellsRowLimitFilter(50) and get 50 latest data.,1.2,True,1,6480 +2019-12-30 11:55:40.920,Will pyqt5 connected with MySQL work on other computers without MySQL?,"I am building a GUI software using PyQt5 and want to connect it with MySQL to store the data. +In my computer, it will work fine, but what if I transfer this software to other computer who doesn't have MySQL, and if it has, then it will not have the same password as I will add in my code (using MySQL-connector)a password which I know to be used to connect my software to MySQL on my PC. +My question is, how to handle this problem???","If you want your database to be installed with your application and NOT shared by different users using your application, then using SQLite is a better choice than MySQL. SQLite by default uses a file that you can bundle with your app. That file contains all the database tables including the connection username/password.",1.2,True,1,6481 +2020-01-03 03:03:26.107,"How could I run tensorflow on windows 10? I have the gpu Geforce gtx 1650. Can I run tensorflow on it? if yes, then how?","I want to do some ML on my computer with Python, I'm facing problem with the installation of tensorflow and I found that tensorflow could work with GPU, which is CUDA enabled. I've got a GPU Geforce gtx 1650, will tensorflow work on that. +If yes, then, how could I do so?","Here are the steps for installation of tensorflow: + +Download and install the Visual Studio. +Install CUDA 10.1 +Add lib, include and extras/lib64 directory to the PATH variable. +Install cuDNN +Install tensorflow by pip install tensorflow",0.0,False,1,6482 +2020-01-06 05:04:25.633,I want my python tool to have a mechanism like whenever anyone runs the tool a pop up should come up as New version available please use the latest,"I Have created a python based tool for my teammates, Where we group all the similar JIRA tickets and hence it becomes easier to pick the priority one first. But the problem is every time I make some changes I have to ask people to get the latest one from the Perforce server. So I am looking for a mechanism where whenever anyone uses the tool a pop up should come up as ""New version available"" please install. +Can anyone help how to achieve that?","On startup, or periodically while running, you could have the tool query your Perforce server and check the latest version. If it doesn't match the version currently running, then you would show the popup, and maybe provide a download link. +I'm not personally familiar with Perforce, but in Git for example you could check the hash of the most recent commit. You could even just include a file with a version number that you manually increment every time you push changes.",0.2655860252697744,False,3,6483 +2020-01-06 05:04:25.633,I want my python tool to have a mechanism like whenever anyone runs the tool a pop up should come up as New version available please use the latest,"I Have created a python based tool for my teammates, Where we group all the similar JIRA tickets and hence it becomes easier to pick the priority one first. But the problem is every time I make some changes I have to ask people to get the latest one from the Perforce server. So I am looking for a mechanism where whenever anyone uses the tool a pop up should come up as ""New version available"" please install. +Can anyone help how to achieve that?","You could maintain the latest version code/tool on your server and have your tool check it periodically against its own version code. If the version code is higher on the server, then your tool needs to be updated and you can tell the user accordingly or raise appropriate pop-up recommending for an update.",0.1352210990936997,False,3,6483 +2020-01-06 05:04:25.633,I want my python tool to have a mechanism like whenever anyone runs the tool a pop up should come up as New version available please use the latest,"I Have created a python based tool for my teammates, Where we group all the similar JIRA tickets and hence it becomes easier to pick the priority one first. But the problem is every time I make some changes I have to ask people to get the latest one from the Perforce server. So I am looking for a mechanism where whenever anyone uses the tool a pop up should come up as ""New version available"" please install. +Can anyone help how to achieve that?","I have an idea,you can use requests module to crawl your website(put the number of version in the page) and get the newest version. +And then,get the version in the user's computer and compare to the official version.If different or lower than official version,Pop a window to remind user to update",0.2655860252697744,False,3,6483 +2020-01-06 13:14:31.660,How to get the Performance Log of another tab from Selenium using Python?,"I'm using Selenium with Python API and Chrome to do the followings: + +Collect the Performance Log; +Click some tags to get into other pages; + +For example, I click a href in Page 'A', which commands the browser opens a new window to load another URL 'B'. +But when I use driver.get_log('performance') to get the performance log, I can only get the log of Page 'A'. Even though I switch to the window of 'B' as soon as I click the href, some log entries of the page 'B' will be lost. +So how can I get the whole performance log of another page without setting the target of to '_top'?","I had the same problem and I think it is because the driver does not immediately switch to a new window. +I switched to page ""B"" and reloaded this page, then uses get_log and it worked.",0.0,False,1,6484 +2020-01-08 06:15:06.680,What is the difference between iterdescendants() and iterchildren() in lxml?,"In LXML python library, how to iterate? and what is the difference between iterdescendants() and iterchildren() in lxml python ?",when you use iterchildren() you iterate over first level childs. When you use iterdescendants() you iterate over childs and childs of childs.,0.0,False,1,6485 +2020-01-08 16:40:23.643,NS3 - python.h file can not be located compilation error,"I have included Python.h in my module header file and it was built successfully. +Somehow when I enabled-examples configuration to compile the example.cc file, which includes the module header file. It reported the Python.h file can not be found - fatal error. +I have no clue at the moment what is being wrong. +Could anyone give a hint? It is for the NS3(Network Simulator 3) framework.","thanks for writing back to me:). +I solved the issue by adding the pyembed feature in the wscript within the same folder as my.cc file. +Thanks again:). +J.",0.0,False,1,6486 +2020-01-09 15:38:35.540,Anaconda prompt launches Visual Studio 2017 when run .py Files,"Traditionally I've used Notepad ++ along with the Anaconda prompt to write and run scripts locally on my Windows PC. +I had my PC upgraded and thought I'd give Virtual Studio Code a chance to see if I liked it. +Now, every time I try to execute a .py file in the Anaconda prompt Visual Studio 2017 launches. I hate this and can't figure out how to stop it. +I've tried the following: + +Uninstalling Virtual Studio Code. +Changing environments in Anaconda. +Reinstalling Anaconda. I did not check the box for the %PATH option. +Reboots at every step. + +On my Windows 10 laptop Visual Studio 2017 doesn't appear in my Apps and Features to uninstall. I've tried Googling and am stuck. +The programs involved are: +Windows 10 Professional +Visual Studio 2017 +Anaconda version 2019.10 Build Channel py37_0 +Can someone help me figure out how to stop this?","How were you running the scripts before? python script.py or only script.py? +If it is the latter, what happened probably is that Windows has associated .py files to Visual Studio. Right click on the file, go to Open With, then select Python if you want to run them, or Notepad++ if you want to edit them.",1.2,True,1,6487 +2020-01-09 23:15:20.873,AWS Lambda - Run Lambda multiply times with different environment variables,"I have an AWS Lambda that uses 2 environment variables. I want to run this lambda up to several hundred times a day, however i need to change the environment variables between runs. +Ideally, I would like something where I could a list a set of variables pairs and run the lambdas on a schedule +The only way I see of doing this, is have separate lambdas and setting the environment variables for each manually +Any Ideas about how to achieve this","You could use an SQS queue for this. Instead of your scheduler initiating the Lambda function directly, it could simply send a message with the two data values to an SQS queue, and the SQS queue could be configured to trigger the Lambda. When triggered, the Lambda will receive the data from the message. So, the Lambda function does not need to change. +Of course, if you have complete control over the client that generates the two data values then that client could also simply invoke the Lambda function directly, passing the two data values in the payload.",1.2,True,1,6488 +2020-01-10 07:19:16.663,convert float64 to int (excel to pandas),"I have imported excel file into python pandas. but when I display customer numbers I get in float64 format i.e + +7.500505e+09 , 7.503004e+09 + how do convert the column containing these numbers","int(yourVariable) will cast your float64 to a integer number. +Is this what you are looking for?",0.0,False,1,6489 +2020-01-10 09:01:43.203,Camera Calibration basic doubts,"I am starting out with computer vision and opencv. I would like to try camera calibration for the images that I have to see how it works. I have a very basic doubt. +Should I use the same camera from which the distorted images were captured or I can use any camera to perform my camera calibration?","Camera calibration is supposed to do for the same camera. Purpose of calibrating a camera is to understand how much distortion the image has and to correct it before we use it to take actual pics. Even if you do not have the original camera, If you have the checkerboard images taken from that camera it is sufficient. Otherwise, look for a similar camera with features as similar as possible (focal length etc.) to take checker board images for calibration and this will somewhat serve your purpose.",0.3869120172231254,False,1,6490 +2020-01-11 08:50:04.607,NLP AI logic - dialogue sequences with multiple parameters per sequence architecture,"I have a dataset of dialogues with various parameters (like if it is a question, an action, what emotion it conveys etc ). I have 4 different ""informations"" per sentence. +let s say A replys to B +A has an additive parameter in a different list for its possible emotions (1.0.0.0) (angry.happy.sad.bored) - an another list for it s possible actions (1.0.0.0) (question.answer.inpulse.ending) +I know how to build a regular RNN model (from the tutorials and papers I have seen here and there), but I can t seem to find a ""parameters"" architecture. +Should I train multiple models ? (like sentence A --> emotions, then sentence B -->actions) then train the main RNN separately and predicting the result through all models ? +or is there a way to build one single model with all the information stored right at the beginning ? +I apologize for my approximate English, witch makes my search for answers even more difficult.","From the way I understand your question, you want to find emotions/actions based on a particular sentence. Sentence A has emotions as labels and Sentence B has actions as labels. Each of the labels has 4 different values with a total of 8 values. And you are confused about how to implement labels as input. +Now, you can give all these labels their separate classes. Like emotions will have labels (1.2.3.4) and actions will have labels (5.6.7.8). Then concat both the datasets and run Classification through RNN. +If you need to pass emotions/actions as input, then add them to vectorized matrix. Suppose you have Sentence A stating ""Today's environment is very good"" with happy emotion. Add the emotion with it's matrix row, like this: +Today | Environment | very | good | health +1 | 1 | 1 | 1 | 0 +Now add emotion such that: +Today | Environment | very | good | health | emotion +1 | 1 | 1 | 1 | 0 | 2(for happy) +I hope this answers your question.",1.2,True,1,6491 +2020-01-11 20:43:56.263,How to identify the message in a delivery notification?,"In pika, I have called channel.confirm_delivery(on_confirm_delivery) in order to be informed when messages are delivered successfully (or fail to be delivered). Then, I call channel.basic_publish to publish the messages. Everything is performed asynchronously. +How, when the on_confirm_delivery callback is called, do I find what the concerned message? In the parameters, The only information that changes in the object passed as a parameter to the callback is delivery_tag, which seems to be an auto-incremented number. However, basic_publish doesn't return any delivery tag. +In other words, if I call basic_publish twice, how do I know, when I receive an acknowledgement, whether it's the first or the second message which is acknowledged?","From RabbitMQ document, I find: + +Delivery tags are monotonically growing positive integers and are presented as such by client libraries. + +So you can keep a growing integer in your code per channel, set it to 0 when channel is open, increase it when you publish a message. Then this integer will be same as the delivery_tag.",1.2,True,1,6492 +2020-01-12 11:18:22.443,how to set the format for date time column in jupyter notebook,"11am – 4pm, 7:30pm – 11:30pm (Mon-Sun)------(this is opening and closing time of restaurant) + [i have this kind of format in my TIME column and this is not converting into datetime format...so how to prepare the data so that i can apply linear regression???] + +ValueError: ('Unknown string format:', '11am – 4pm, 7:30pm – 11:30pm (Mon-Sun)')","From my understanding, datetime format requires the 24h format, or - 00:00:00 +So instead of 7:30pm, it would be 19:30:00.",0.0,False,1,6493 +2020-01-12 15:18:09.343,Which data to plot to know what model suits best for the problem?,"I'm sorry, i know that this is a very basic question but since i'm still a beginner in machine learning, determining what model suits best for my problem is still confusing to me, lately i used linear regression model (causing the r2_score is so low) and a user mentioned i could use certain model according to the curve of the plot of my data and when i see another coder use random forest regressor (causing the r2_score 30% better than the linear regression model) and i do not know how the heck he/she knows better model since he/she doesn't mention about it. I mean in most sites that i read, they shoved the data to some models that they think would suit best for the problem (example: for regression problem, the models could be using linear regression or random forest regressor) but in some sites and some people said firstly we need to plot the data so we can predict what exact one of the models that suit the best. I really don't know which part of the data should i plot? I thought using seaborn pairplot would give me insight of the shape of the curve but i doubt that it is the right way, what should i actually plot? only the label itself or the features itself or both? and how can i get the insight of the curve to know the possible best model after that?","If you are using off-the-shelf packages like sklearn, then many simple models like SVM, RF, etc, are just one-liners, so in practice, we usually try several such models at the same time.",0.0,False,2,6494 +2020-01-12 15:18:09.343,Which data to plot to know what model suits best for the problem?,"I'm sorry, i know that this is a very basic question but since i'm still a beginner in machine learning, determining what model suits best for my problem is still confusing to me, lately i used linear regression model (causing the r2_score is so low) and a user mentioned i could use certain model according to the curve of the plot of my data and when i see another coder use random forest regressor (causing the r2_score 30% better than the linear regression model) and i do not know how the heck he/she knows better model since he/she doesn't mention about it. I mean in most sites that i read, they shoved the data to some models that they think would suit best for the problem (example: for regression problem, the models could be using linear regression or random forest regressor) but in some sites and some people said firstly we need to plot the data so we can predict what exact one of the models that suit the best. I really don't know which part of the data should i plot? I thought using seaborn pairplot would give me insight of the shape of the curve but i doubt that it is the right way, what should i actually plot? only the label itself or the features itself or both? and how can i get the insight of the curve to know the possible best model after that?","This question is too general, but I will try to give an overview of how to choose the model. First of all you should that there is no general rule to choose the family of models to use, it is more a choosen by experiminting different model and looking to which one gives better results. You should also now that in general you have multi-dimensional features, thus plotting the data will not give you a full insight of the dependance of your features with the target, however to check if you want to fit a linear model or not, you can start plotting the target vs each dimension of the input, and look if there is some kind of linear relation. However I would recommand that you to fit a linear model, and check if if this is relvant from a statistical point of view (student test, smirnov test, check the residuals...). Note that in real life applications, it is not likeley that linear regression will be the best model, unless you do a lot of featue engineering. So I would recommand you to use more advanced methods (RandomForests, XGboost...)",0.2012947653214861,False,2,6494 +2020-01-12 22:30:19.967,Openshift online - no longer running collectstatic,"I've got 2 Python 3.6 pods currently running. They both used to run collectstatic upon redeployment, but then one wasn't working properly, so I deleted it and made a new 3.6 pod. Everything is working perfectly with it, except it no longer is running collectstatic on redeployment (so I'm doing it manually). Any thoughts on how I can get it running again? +I checked the documentation, and for the 3.11 version of openshift still looks like it has a variable to disable collectstatic (which i haven't done), but the 4.* versions don't seem to have it. Don't know if that has anything to do with it. +Edit: +So it turns out that I had also updated the django version to 2.2.7. +As it happens, the openshift infrastructure on openshift online is happy to collectstatic w/ version 2.1.15 of Django, but not 2.2.7 (or 2.2.9). I'm not quite sure why that is yet. Still looking in to it.",Currently Openshift Online's python 3.6 module doesn't support Django 2.2.7 or 2.2.9.,1.2,True,1,6495 +2020-01-13 13:47:41.013,How to edit ELF by adding custom sections and symbols,"I want to take an elf file and then based on the content add a section with data and add symbols. Using objcopy --add-section I can add a section with the content that I would like. I cannot figure out how to add a symbol. +Regardless, I would prefer not run a series of programs in order to do what I want but rather do it natively in c or python. In pyelftools I can view an elf, but I cannot figure out how to edit and elf. +How can I add custom sections and symbols in Python or C?","ELF has nothing to do with the symbols stored in it by programs. It is just a format to encode everything. Symbols are generated normally by compilers, like the C compiler, fortran compiler or an assembler, while sections are fixed by the programming language (e.g. the C compiler only uses a limited number of sections, depending on the kind of data you are using in your programs). Some compilers have extensions to associate a variable to a section, so the linke will consider it special in some way. The compiler/assembler generates a symbol table in order for the linker to be able to use it to resolve dependencies. +If you want to add symbols to your program, the easiest way it to create an assembler module with the sections and symbols you want to add to the executable, then assemble it and link to the final executable. +Read about ld(1) program (the linker), and how it uses the link scripts (special hidden files that direct the linker on how to organize the sections in the different modules at link time) to handle the sections in an object file. ELF is just a format. If you use a link script and the help of the assembler, you'll be able to add any section you want or modify the normal memory map that programs use to have.",0.0,False,1,6496 +2020-01-13 17:24:11.667,Google Earth Engine using Python,"How should a beginner start learning Google Earth Engine coding with python using colab? I know python, but how do I come to know about the objects of images and image classification.",i use geemap package for convert shape file to earth engine variable without uploading file on assets,0.0,False,1,6497 +2020-01-13 18:30:12.277,How to predict the player using random forest ML,"I have to predict the winner of the Australian Open 2020. My dataset has these features: Location / Tournament / Date / Series / Court / Surface / Round / Winner / Loser etc. +I trained my model using just these features 'Victory','Series','Court','Surface','WinRank','LoseRank','WPts','LPts','Wsets','Lsets','Weather' and I have a 0.93 accuracy but now I have to predict the name of the winner and I don't have any idea how to do it based on the model that I trained. +Example: If I have Dimitrov G. vs Simion G using random forest the model has to give me one of them as the winner of the match. +I transformed the names of the players in dummy variables but after that, I don't know what to do? +Can anyone give me just an idea of how could I predict the winner? so I can create a Tournament, please?","To address such a problem, I would suggest creation of a custom target variable. +Firstly, the transformation of names of players into dummy variables seems reasonable (Just make sure, the unique player is identified with the same first and last name combinations thereby, avoiding duplications and thus, having the correct dummy code for the player name). +Now, to create the target variable ""wins"" - + +Use the two player names - P1, P2 of the match as input features for your model. +Define the ""wins"" as 1 if P1 wins and 0 if P2 wins. +Run your model with this set up. +When you want to create a tournament and predict the winner, the inputs will be your 2 players and other match features. If, ""wins"" is close to 1, it means your P1 wins and output that player name.",1.2,True,1,6498 +2020-01-14 14:08:12.387,Eikon API - ek.get_data for indices,"I would like to retrieve the following (historical) information while using the +ek.get_data() +function: ISIN, MSNR,MSNP, MSPI, NR, PI, NT +for some equity indices, take "".STOXX"" as an example. How do I do that? I want to specify I am using the get data function instead of the timeseries function because I need daily data and I would not respect the 3k rows limit in get.timeseries. +In general: how do I get to know the right names for the fields that I have to use inside the +ek.get_data() +function? I tried with both the codes that the Excel Eikon program uses and also the names used in the Eikon browser but they differ quite a lot from the example I saw in some sample code on the web (eg. TR.TotalReturnYTD vs TR.PCTCHG_YTD. How do I get to understand what would be the right name for the data types I need?","Considering the codes in your function (ISIN, MSNR,MSNP, MSPI, NR, PI, NT), I'd guess you are interested in the Datastream dataset. You are probably beter off using the DataStream WebServices (DSWS) API instead of the Eikon API. This will also relieve you off your 3k row limit.",0.0,False,1,6499 +2020-01-14 16:05:18.980,Installing cutadapat package in windows,"I'm trying to install a package name cutdapt in a windows server. I'm trying to do it this way: +pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org cutadapt +But every time I try to install it I get this error: Building wheel for cutadapt (PEP 517): finished with status 'error' +Any ideas on how to pass this issue?","Turns out, that I had some problems with python 3.5, so I switched to python 3.8 and managed to install the package.",1.2,True,1,6500 +2020-01-14 17:32:47.693,Can I use Node.js for the back end and Python for the AI calculations?,"I am trying to create a website in Node.js. Though, as I am taking a course on how to use Artificial Intelligence and would like to implement such into my program. Therefore, I was wondering if it was feasible to connect Python Spyder to a Node.js based web application with somewhat ease.","Yes. That is possible. There are a few ways you can do this. You can use the child_process library, as mentioned above. Or, you can have a Python API that takes care of the AI stuff, which your Node app communicates with. +The latter example is what I prefer as most my projects run on containers as micro services on Kubernates.",0.2012947653214861,False,1,6501 +2020-01-14 21:20:47.013,Python 3.X micro ORM compatible with SQL Server,"My application is database heavy (full of very complex queries and stored procedures), it would be too hard and inefficient to write these queries in a lambda way, for this reason I'll have to stick with raw SQL. +So far I found these 2 'micro' ORMs but none are compatible with MSSQL: +PonyORM +Supports: SQLite, PostgreSQL, MySQL and Oracle +Peewee +Supports: SQLite, PostgreSQL, MySQL and CockroachDB +I know SQLAlchemy supports MSSQL, however it would bee too big for what I need.",As of today - Jan 2020 - it seems that using pyodbc is still the way to go for SQL Server + Python if you are not using Django or any other big frameworks.,1.2,True,1,6502 +2020-01-15 06:45:49.180,catboost classifier for class imbalance?,"I am using catboost classifier for my binary classification model where I have a highly imbalance dataset of 0 -> 115000 & 1 -> 10000. +Can someone please guide me in how to use the following parameters in catboostclassifier: +1. class_weights +2. scale_pos_weight ? +From the documentation, I am under the impression that I can use +Ratio of sum of negative class by sum of positive class i.e. 115000/10000=11.5 as the input for scale_pos_weight but I am not sure . +Please let me know what exact values to use for these two parameters and method to derive that value? +Thanks","For scale_pos_weight you would use negative class // positive class. in your case it would be 11 (I prefer to use whole numbers). +For class weight you would provide a tuple of the class imbalance. in your case it would be: class_weights = (1, 11) +class_weights is more flexible so you could define it for multi-class targets. for example if you have 4 classes you can set it: class_weights = (0.5,1,5,25) +and you need to use only one of the parameters. for a binary classification problem I would stick with scale_pos_weight.",1.2,True,1,6503 +2020-01-16 01:15:11.980,How to write \n without making a newline,"So I'm trying to write this exact string but I don't \n to make a new line I want to actually print \n on the screen. Any thoughts on how to go about this? (using python +Languages:\npython\nc\njava","adding a backslash will interpret the succeeding backslash character literally. print(""\\n"").",0.0,False,1,6504 +2020-01-20 05:37:33.623,My Dataset is showing a string when it should be a curly bracket set/dictionary,"My dataset has a column where upon printing the dataframe each entry in the column is like so: +{""Wireless Internet"",""Air conditioning"",Kitchen} +There are multiple things wrong with this that I would like to correct + +Upon printing this in the console, python is printing this:'{""Wireless Internet"",""Air conditioning"",Kitchen}' Notice the quotations around the curly brackets, since python is printing a string. +Ideally, I would like to find a way to convert this to a list like: [""Wireless Internet"",""Air conditioning"",""Kitchen""] but I do not know how. Further, notice how some words so not have quotations, such as Kitchen. I do not know how to go about correcting this. + +Thanks","what you have is a set of words, curly brackets are for Dictionary use such as {'Alex,'19',Marry','20'} its linking it as a key and value which in my case it name and age, rather than that you can use to_list command in python maybe it suits your needs.",0.0,False,1,6505 +2020-01-20 11:17:53.697,Get whole row using database package execute function,"I am using databases package in my fastapi app. databases has execute and fetch functions, when I tried to return column values after inserting or updating using execute, it returns only the first value, how to get all the values without using fetch.. +This is my query + +INSERT INTO table (col1, col2, col3, col4) + VALUES ( val1, val2, val3, val4 ) RETURNING col1, col2;","I had trouble with this also, this was my query: + +INSERT INTO notes (text, completed) VALUES (:text, :completed) RETURNING notes.id, notes.text, notes.completed + +Using database.execute(...) will only return the first column. +But.. using database.fetch_one(...) inserts the data and returns all the columns. +Hopes this helps",0.0,False,2,6506 +2020-01-20 11:17:53.697,Get whole row using database package execute function,"I am using databases package in my fastapi app. databases has execute and fetch functions, when I tried to return column values after inserting or updating using execute, it returns only the first value, how to get all the values without using fetch.. +This is my query + +INSERT INTO table (col1, col2, col3, col4) + VALUES ( val1, val2, val3, val4 ) RETURNING col1, col2;","INSERT INTO table (col1, col2, col3, col4) VALUES ( val1, val2, val3, val4 ) RETURNING (col1, col2); + +you can use this query to get all columns",1.2,True,2,6506 +2020-01-20 12:19:47.043,"PyCharm venv issue ""pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available""","I hope someone can help me as I would like to use PyCharm to develop in Python. +I have looked around but do not seem to be able to find any solutions to my issue. +I have Python 3 installed using the Windows msi. +I am using Windows 10 . have downloaded PyCharm version 2019.3.1 (Community Edition). +I create a new project using the Pure Python option. +On trying to pip install any package, I get the error +pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available +If I try this in VSCode using the terminal it works fine. +Can anyone tell me how to resolve this issue. It would appear to be a problem with the virtual environment but I do not know enough to resolve the issue. +Thanks for your time.","Sorry guys, it appears the basic interpreter option was on Anaconda, that I had installed sometime ago , forgotten about and it defaulted to it . Changing my basic interpreter option to my Python install (Python.exe) solved the issue. +Keep on learning",0.6730655149877884,False,1,6507 +2020-01-20 14:24:55.687,Does anyone know how Tesseract - OCR postprocessing / spellchecking works?,"I was using tesseract-ocr (pytesseract) for spanish and it achieves very high accuracy when you set the language to spanish and of course, the text is in spanish. If you do not set language to spanish this does not perform that good. So, I'm assuming that tesseract is using many postprocessing models for spellchecking and improving the performance, I was wondering if anybody knows some of those models (ie edit distance, noisy channel modeling) that tesseract is applying. +Thanks in advance!","Your assumption is wrong: If you do not specify language, tesseract uses English model as default for OCR. That is why you got wrong result for Spanish input text. There is no spellchecking post processing.",0.0,False,1,6508 +2020-01-21 22:38:55.577,Erwin API with Python,I am trying to get clear concept on how to get the Erwin generated DDL objects with python ? I am aware Erwin API needs to be used. What i am looking if what Python Module and what API needs to used and how to use them ? I would be thankful for some example !,"Here is a start: +import win32com.client +ERwin = win32com.client.Dispatch(""erwin9.SCAPI"") +I haven't been able to browse the scapi dll so what I know is from trial and error. Erwin publishes VB code that works, but it is not straightforward to convert.",0.2012947653214861,False,1,6509 +2020-01-22 08:29:49.570,"Venv fails in CentOS, ensurepip missing","Im trying to install a venv in python3 (on CentOS). However i get the following error: + +Error: Command '['/home/cleared/Develop/test/venv/bin/python3', '-Im', + 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit + status 1. + +I guess there is some problem with my ensurepip... +Running python3 -m ensurepip results in + +FileNotFoundError: [Errno 2] No such file or directory: + '/usr/lib64/python3.6/ensurepip/_bundled/pip-9.0.3-py2.py3-none-any.whl' + +Looking in the /usr/lib64/python3.6/ensurepip/_bundled/ I find pip-18.1-py2.py3-none-any.whl and setuptools-40.6.2-py2.py3-none-any.whl, however no pip-9.0.3-py2.py3-none-any.whl +Running pip3 --version gives + +pip 20.0.1 from /usr/local/lib/python3.6/site-packages/pip (python + 3.6) + +Why is it looking for pip-9.0.3-py2.py3-none-any.whl when I'm running pip 20.0.1, and why to i have pip-18.1-py2.py3-none-any.whl? And how to I fix this?",I would make a clean reinstall of Python (and maybe some of its dependencies as well) with your operating system's package manager (yum?).,0.0,False,2,6510 +2020-01-22 08:29:49.570,"Venv fails in CentOS, ensurepip missing","Im trying to install a venv in python3 (on CentOS). However i get the following error: + +Error: Command '['/home/cleared/Develop/test/venv/bin/python3', '-Im', + 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit + status 1. + +I guess there is some problem with my ensurepip... +Running python3 -m ensurepip results in + +FileNotFoundError: [Errno 2] No such file or directory: + '/usr/lib64/python3.6/ensurepip/_bundled/pip-9.0.3-py2.py3-none-any.whl' + +Looking in the /usr/lib64/python3.6/ensurepip/_bundled/ I find pip-18.1-py2.py3-none-any.whl and setuptools-40.6.2-py2.py3-none-any.whl, however no pip-9.0.3-py2.py3-none-any.whl +Running pip3 --version gives + +pip 20.0.1 from /usr/local/lib/python3.6/site-packages/pip (python + 3.6) + +Why is it looking for pip-9.0.3-py2.py3-none-any.whl when I'm running pip 20.0.1, and why to i have pip-18.1-py2.py3-none-any.whl? And how to I fix this?","These versions are harcoded at the beginning of ./lib/python3.8/ensurepip/__init__.py. You can edit this file with the correct ones. +Regarding the reason of this corruption, I can only guess. I would bet on a problem during the installtion of this interpreter.",1.2,True,2,6510 +2020-01-22 11:33:05.413,How can I deploy my features in a Machine Learning algorithm?,"I’m way new to ML so I have a really rudimentary question. I would appreciate it if one clarifies it for me. +Suppose I have a set of tweets which labeled as negative and positive. I want to perform some sentiment analysis. +I extracted 3 basic features: + +Emotion icons +Exclamation marks +Intensity words(very, really etc.). + +How should I use these features with SVM or other ML algorithms? +In other words, how should I deploy the extracted features in SVM algorithm? +I'm working with python and already know how should I run SVM or other algorithms, but I don't have any idea about the relation between extracted features and role of them in each algorithm! +Based on the responses of some experts I update my question: +At first, I wanna appreciate your time and worthy explanations. I think my problem is solving… So in line with what you said, each ML algorithm may need some vectorized features and I should find a way to represent my features as vectors. I want to explain what I got from your explanation via a rudimentary example. +Say I have emoticon icons (for example 3 icons) as one feature: +1-Hence, I should represent this feature by a vector with 3 values. +2-The vectorized feature can initial in this way : [0,0,0] (each value represents an icon = :) and :( and :P ). +3-Next I should go through each tweet and check whether the tweet has an icon or not. For example [2,1,0] shows that the tweet has: :) 2 times, and :( 1 time, and :p no time. +4-After I check all the tweets I will have a big vector with the size of n*3 (n is the total number of my tweets). +5-Stages 1-4 should be done for other features. +6-Then I should merge all those features by using m models of SVM (m is the number of my features) and then classify by majority vote or some other method. +Or should create a long vector by concatenating all of the vectors, and feed it to the SVM. +Could you please correct me if there is any misunderstanding? If it is not correct I will delete it otherwise I should let it stay cause It can be practical for any beginners such as me... +Thanks a bunch…","basically, to make things very ""simple"" and ""shallow"", all algorithm takes some sort of a numeric vector represent the features +the real work is to find how to represent the features as vector which yield the best result, this depends by the feature itself and on the algorithm using +for example to use SVM which basically find a separator plane, you need to project the features on some vectors set which yield a good enough separation, so for instance you can treat your features like this: + +Emotion icons - create a vector which represent all the icons present in that tweet, define each icon to an index from 1 to n so tweet represented by [0,0,0,2,1] means the 4th and 5th icons are appearing in his body 2 and 1 times respectively +Exclamation marks - you can simply count the number of occurrences (a better approach will be to represent some more information about it like the place in a sentence and such...) +Intensity words - you can use the same approach as the Emotion icons + +basically each feature can be used alone in the SVM model to classify good and bad +you can merge all those features by using 3 models of SVM and then classify by majority vote or some other method +or +you can create a long vector by concatenating all of the vectors, and feed it to the SVM + +this is just a one approach, you might tweak it or use some other one to fit your data, model and goal better",0.999329299739067,False,1,6511 +2020-01-22 12:40:14.960,Search SVN for specific files,"I am trying to write a Python script to search a (very large) SVN repository for specific files (ending with .mat). Usually I would use os.walk() to walk through a directory and then search for the files with a RegEx. Unfortunately I can't use os.walk() for a repository, since it is not a local directory. +Does anyone know how to do that? The repository is too large to download, so I need to search for it ""online"". +Thanks in advance.","Something like +svn ls -R REPO-ROOT | grep PATTERN +will help",0.3869120172231254,False,1,6512 +2020-01-23 01:37:55.337,"How do you create a class, or function in python that allows you to make a sequence type with specific characteristics","1) My goal is to create a sequence that is a list that contains ordered dictionaries. The only problem for me will be described below. + +I want the list to represent a bunch of ""points"" which are for all intents and purposes just an ordered dictionary. However, I notice that when I use OrderedDict class, when I print the dictionary it comes up as OrderedDict([key value pair 1, key value pair 2, ... etc)] For me, I would rather it behave like an ordered dictionary, BUT not having those DOUBLE ""messy/ugly"" ""end marks"" which are the ""[( )]"". I don't mind if the points have ONE, and only one, type of ""end marks"". Also I would also like it if when I print this data type that stuff like OrderedDict() doesn't show up. However, I do not mind if it shows up in return values. Like you know how when you print a list it doesn't show up as list(index0, index1, ... etc) but instead it shows up as [index0, index1, ... etc]. That is what I mean. Inside the point, it would look like this + +point = {'height': 1, 'weight': 3, 'age': 5, etc} <- It could be brackets or braces or parentheses. Just some type of ""end mark"", but I preferably would like it to be in {} and having key value pairs indicated by key: value and have them separated by commas. +what_i_am_looking_for = [point0, point1, point2, point3, ... etc]","In Python 3.6, the ordinary dict implementation was re-written and maintains key insertion order like OrderedDict, but was considered an implementation detail. Python 3.7 made this feature an official part of the language spec, so if you use Python 3.6+ just use dict instead of OrderedDict if you don't care about backward-compatibility with Python 3.5 or earlier.",0.0,False,1,6513 +2020-01-23 04:51:14.783,Scrape and compare and Web page data,I have a web page with data in different tables. I want to extract a particular table and compare with an excel sheet and see whether there are any differences. Note the web page is in a internal domain. I tried with requests and beautifulsoup but I got 401 error. Could anyone help how I can achieve this?,"401 is an Unauthorized Error - which suggests your username and password may be getting rejected, or their format not accepted. Review your credentials and the exact format / data names expected by the page to ensure you're correctly trying to connect.",0.0,False,1,6514 +2020-01-25 09:25:18.143,USB Device/PyUSB on Windows and LInux behaving differently,"I have a device with USB interface which I can connect to both my Ubuntu 18.04 machine and my Windows 10 machine. On Windows 10 I have to install the CP210x driver and manually attach it to the device (otherwise Windows tries to find the device manufacturer's driver - it's a CP210x serial chip), and in Linux write the vendorID and productID to the cp210x driver to allow it to attach to ttyUSB0. This works fine. +The Windows driver is from SiliconLabs - the manufacturer of the UART-USB chip in the device. +So on Windows it is attached to COM5 and Linux to ttyUSB0 (Ubuntu, Raspbian) +Using Wireshark I can snoop the usb bus successfully on both operating systems. +The USB device sends data regularly over the USB bus and on Windows using Wireshark I can see this communication as ""URB_INTERRUPT in"" messages with the final few bytes actually containing the data I require. +On Linux it seems that the device connects but using Wireshark this time I can only see URB_BULK packets. Examining the endpoints using pyusb I see that there is no URB_Interrupt endpoint only the URB_Bulk. +Using the pyusb libraries on Linux it appears that the only endpoints available are URB_BULK. +Question mainly is how do I tell Linux to get the device to send via the Interrupt transfer mechanism as Windows seems to do. I don't see a method in pyusb's set_configuration to do this (as no Interrupt transfer endpoints appear) and haven't found anything in the manufacturer's specification. +Failing that, of course, I could snoop the configuration messages on Windows, but there has to be something I'm missing here?","Disregard this, the answer was simple in the end: Windows was reassigning the device address on the bus to a different device.",0.0,False,1,6515 +2020-01-25 21:41:28.487,How can I define an absolute path saved in one exe file?,"I'm writing a software in python for windows which should be connected to a database. Using py2exe i want to make an executable file so that I don't have to install python in the machines the software is running. The problem is that I want the user to define where the database is located the very first time the software starts, but I don't know how to store this information so that the user doesn't have to tell everytime where is the database. I have no idea how to deal with it. (the code cannot be changed because it's just a .exe file). How would you do that?","I can think of some solutions: + +You can assume the DB is in a fixed location - bad idea, might move or change name and then your program stop working +You can assume the DB is in the same folder as the .exe file and guide the user to run it in the same folder - better but still not perfect +Ask the user for the DB location and save the path in a configuration file. If the file doesn't exist or path doesn't lead to the file, the user should tell the program where is the DB, otherwise, read it from the config file - I think this is the best option.",0.0,False,1,6516 +2020-01-25 23:13:58.847,How to install python module local to a single project,"I've been going around but was not able to find a definitive answer... +So here's my question.. +I come from javascript background. I'm trying to pickup python now. +In javascript, the basic practice would be to npm install (or use yarn) +This would install some required module in a specific project. +Now, for python, I've figured out that pip install is the module manager. +I can't seem to figure out how to install this specific to a project (like how javascript does it) +Instead, it's all global.. I've found --user flag, but that's not really I'm looking for. +I've come to conclusion that this is just a complete different schema and I shouldn't try to approach as I have when using javascript. +However, I can't really find a good document why this method was favored. +It may be just my problem but I just can't not think about how I'm consistently bloating my pip global folder with modules that I'm only ever gonna use once for some single project. +Thanks.","A.) Anaconda (the simplest) Just download “Anaconda” that contains a lots of python modules pre installed just use them and it also has code editors. You can creat multiple module collections with the GUI. +B.) Venv = virtual environments (if you need something light and specific that contains specific packages for every project +macOS terminal commands: + +Install venv +pip install virtualenv +Setup Venve (INSIDE BASE Project folder) +python3 -m venv thenameofyourvirtualenvironment +Start Venve +source thenameofyourvirtualenvironment/bin/activate +Stop Venve +deactivate +while it is activated you can install specific packages ex.: +pip -q install bcrypt + +C.) Use “Docker” it is great if you want to go in depth and have a solide experience, but it can get complicated.",1.2,True,1,6517 +2020-01-27 10:22:09.743,How to stop Anaconda Navigator and Spyder from dropping libraries into User folder,"For reference, I'm trying to re-learn programming and python basics after years away. +I recently downloaded Anaconda as part of an online Python Course. However, every time I open Spyder or the Navigator they instantly create folders for what I assume are all the relevant libraries in C:Users/Myself. These include .conda, .anaconda, .ipython, .matplotlib, .config and .spyder-py3. +My goal is to figure out how change where these files are placed so I can clean things up and have more control. However, I am not entirely sure why this occurs. My assumption is it's due to that being the default location for the Working Directory, thought the solutions I've seen to that are currently above me. I'm hoping this is a separate issue with a simpler solution, and any light that can be shed on this would be appreciated.","Go to: +~\anaconda3\Lib\site-packages\jupyter_core\paths.py +in def get_home_dir(): +You can specify your preferred path directly. +Other anaconda applications can be mortified by this way but you have to find out in which scripts you can change the homedir, and sometimes it has different names.",0.0,False,2,6518 +2020-01-27 10:22:09.743,How to stop Anaconda Navigator and Spyder from dropping libraries into User folder,"For reference, I'm trying to re-learn programming and python basics after years away. +I recently downloaded Anaconda as part of an online Python Course. However, every time I open Spyder or the Navigator they instantly create folders for what I assume are all the relevant libraries in C:Users/Myself. These include .conda, .anaconda, .ipython, .matplotlib, .config and .spyder-py3. +My goal is to figure out how change where these files are placed so I can clean things up and have more control. However, I am not entirely sure why this occurs. My assumption is it's due to that being the default location for the Working Directory, thought the solutions I've seen to that are currently above me. I'm hoping this is a separate issue with a simpler solution, and any light that can be shed on this would be appreciated.","They are automatically created to store configuration changes for those related tools. They are created in %USERPROFILE% under Windows. +The following is NOT recommended: +You can change this either via the setx command or by opening the Start Menu search for variables. +- This opens the System Properties menu on the Advanced tab +- Click on Environmental Variables +- Under the user section, add a new variable called USERPROFILE and set the value to a location of your choice.",0.0,False,2,6518 +2020-01-28 07:32:40.877,"Is there an effective way to install 'pip', 'modules' and 'dependencies' in an offline environment?","The computer on which I want to install pip and modules is a secure offline environment. +Only Python 2.7 is installed on this computers(centos and ubuntu). +To run the source code I coded, I need another module. +But neither pip nor module is installed. +It looks like i need pip to install all of dependency files. +But I don't know how to install pip offline. +and i have no idea how to install the module offline without pip. +The only network connected is pypi from the my nexus3 repository. +Is there a good way? +Would it be better to install pip and install modules? +Would it be better to just install the module without installing pip?","using pip it is easier to install the packages as it manages certian things on its own. You can install modules manually by downloading its source code and then compiling it yourself. The choice is upto you, how you want to do things.",0.0,False,1,6519 +2020-01-29 15:00:21.157,Kubernetes log not showing output of python print method,"I've a python application in which I'm using print() method tho show text to a user. When I interact with this application manually using kubectl exec ... command I can see the output of prints. +However, when script is executed automatically on container startup with CMD python3 /src/my_app.py (last entry in Dockerfile) then, the prints are gone (not shown in kubectl logs). Ayn suggestin on how to fix it?","It turned out to be a problem of python environment. Setting, these two environment variables PYTHONUNBUFFERED=1 and PYTHONIOENCODING=UTF-8 fixed the issue.",0.5457054096481145,False,1,6520 +2020-01-30 15:17:27.757,Spotfire: Using Multiple Markings in a Data Function Without Needing Something Marked in Each,"In Spotfire I have a dashboard that uses both filtering (only one filtering scheme) and multiple markings to show the resulting data in a table. +I have created a data function which takes a column and outputs the data in the column after the active filtering scheme and markings are applied. +However, this output column is only calculated if I have something marked in every marking. +I want the output column to be calculated no matter how many of the markings are being used. Is there a way to do this? +I was thinking I could use an IronPython script to edit the data function parameters for my input column to only check the boxes for markings that are actively being used. However, I can't find how to access those parameters with IronPython. +Thanks!","I think it would be a combination of visuals being set to OR instead of AND for markings (if you have a set of markings that are being set from others). +Also are all the input parameters set to required parameter perhaps unchecking that option would still run the script. In the r script you may want to replace null values as well. +Not too sure without some example.",1.2,True,1,6521 +2020-01-30 17:22:41.407,Program to print all folder and subfolder names in specific folder,"I should do it wiht only import os +I have problem, that i don't know how to make program after checking the specific folder for folders to do the same for folders in these folders and so on.",You can use os.walk(directory),0.0,False,1,6522 +2020-01-30 21:18:10.660,Cannot import module from linux-ubuntu terminal,"I installed the keyboard module for python with pip3 and after I runned my code the terminal shows me this message: ""ImportError: You must be root to use this library on linux."" Can anybody help me how to run it well? I tried to run it by switching to ""su -"" and tried it on this place as well.","Can you please post your script? +If you are just starting the program without a shebang it probably should not run and probably throw an ImportError +Try adding a shebang (#!) at the first line of you script. +A shebang is used in unix to select the interpreter you want to run your script. +Write this in the first line: #!/usr/bin/env python3 +If this doesn't help try running it from the terminal using a precending dot like this: +python3 ./{file's_name}.py",1.2,True,1,6523 +2020-01-31 02:27:00.850,Easiest way to put python text game in html?,"I am trying to help someone put a python text game to be displayed with the inputs and output on his html website. What's the easiest way to do this, regarding the many outputs and inputs? Would it be to make it a flask app? I don't really know how else to describe the situation. Answers would be much appreciated.","I am developing a website with python3.8 and Sanic. It was pretty to use async, await and := ~",0.0,False,1,6524 +2020-02-01 21:35:48.343,is django overkill for a contact us website?,"I'm a complete beginner and a relative of mine asked me to build a simple 'contact us' website for them. It should include some information about his company and a form in which people that visit the website are able to send mails to my relative. I have been playing around with vue.js in order to build the frontend. I now want to know how to put the form to send mails and I read it has to be done with backend, so I thought I could use django as I have played with it in the past and I am confident using python. Is it too much for the work that I have to do? Should I use something simpler? I accept any suggestions please, Thanks.","Flask +You can use Flask. it is simpler than Django and easy to learn. you can build a simple website like the one you want in less than 50 line. + +Wordpress +If you want you can use Wordpress. it's easy to install and many hosting services support it already. Wordpress has so many plugins and templates to build contact us website in 10 minutes. + +Wix +wix is easy, drag-n-drop website builder with many pre-build templates that you can use, check them out and you will find what you need.",0.0,False,2,6525 +2020-02-01 21:35:48.343,is django overkill for a contact us website?,"I'm a complete beginner and a relative of mine asked me to build a simple 'contact us' website for them. It should include some information about his company and a form in which people that visit the website are able to send mails to my relative. I have been playing around with vue.js in order to build the frontend. I now want to know how to put the form to send mails and I read it has to be done with backend, so I thought I could use django as I have played with it in the past and I am confident using python. Is it too much for the work that I have to do? Should I use something simpler? I accept any suggestions please, Thanks.","You will probably should use something ready like Wix or Wordpress if want to do it fast if you prefer to learn in the process you can do it with Django and Vue, but this is indeed little bit overkill",0.0,False,2,6525 +2020-02-02 23:55:02.930,mitmproxy: shortcut for undoing edit,"new user of mitmproxy here. I've figured out how to edit a request and replay it, and I'm wondering how to undo my edit. +More specifically, I go to a request's flow, hit 'e', then '8' to edit the request headers. Then I press 'd' to delete one of the headers. What do I press to undo this change? 'u' doesn't work.","It's possible to revoke changes to a flow, but not while editing. In your case, 'e' -> '8' -> 'd' headers, now press 'q' to go back to the flow -> press 'V' to revoke changes to the flow.",0.0,False,1,6526 +2020-02-03 11:14:48.003,"Tktable module installation problem. _tkinter.TclError: invalid command name ""table""","This problem has been reported earlier but I couldn't find the exact solution for it. I installed ActiveTCL and downloaded tktable.py by ""Guilherme Polo "" to my site-packages, also added Tktable.dll, pkgindex.tcl, and tktable.tcl from ActiveTCL\lib\Tktable2.11 to my python38-32\tcl and dlls . I also tried setting the env variable for TCL_LIBRARY and TK_LIBRARY to tcl8.6 and tk8.6 respectively. But I am still getting invalid command name ""table"". +What is that I am missing? Those who made tktable work on windows 10 and python 3 , how did you do it? I am out of ideas and would be grateful for some tips on it.","Seems like there was problem running the Tktable dlls in python38-32 bit version. It worked in 64 bit version. +Thanks @Donal Fellows for your input.",0.0,False,1,6527 +2020-02-03 12:22:32.540,"Getting a ""Future Warning"" when importing for Yahoo with Pandas-Datareader","I am currently , successfully, importing stock information from Yahoo using pandas-datareader. However, before the extracted data, I always get the following message: + +FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead. + +Would anyone have an idea of what it means and how to fix it?","Cause: The cause of this warning is that, basically, the pandas_datareader is importing a module from the pandas library that will be deprecated. Specifically, it is importing pandas.util.testing whereas the new preferred module will be pandas.testing. +Solution: First off this is a warning, and not an outright error, so it won't necessarily break your program. So depending on your exact use case, you may be able to ignore it for now. +That being said, there are a few options you can consider: + +Option 1: Change the code yourself -- Go into the pandas_datareader module and modify the line of code in compat_init.py that currently says from pandas.util.testing import assert_frame_equal simply to from pandas.testing import assert_frame_equal. This will import the same function from the correct module. +Option 2: Wait for pandas-datareader to update --You can also wait for the library to be upgraded to import correctly and then run pip3 install --upgrade pandas-datareader. You can go to the Github repo for pandas-datareader and raise an issue. +Option 3: Ignore it -- Just ignore the warning for now since it doesn't break your program.",0.0,False,3,6528 +2020-02-03 12:22:32.540,"Getting a ""Future Warning"" when importing for Yahoo with Pandas-Datareader","I am currently , successfully, importing stock information from Yahoo using pandas-datareader. However, before the extracted data, I always get the following message: + +FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead. + +Would anyone have an idea of what it means and how to fix it?","For mac OS open /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pandas_datareader/compat/__init__.py +change: from pandas.util.testing import assert_frame_equal +to: from pandas.testing import assert_frame_equal",-0.1352210990936997,False,3,6528 +2020-02-03 12:22:32.540,"Getting a ""Future Warning"" when importing for Yahoo with Pandas-Datareader","I am currently , successfully, importing stock information from Yahoo using pandas-datareader. However, before the extracted data, I always get the following message: + +FutureWarning: pandas.util.testing is deprecated. Use the functions in the public API at pandas.testing instead. + +Would anyone have an idea of what it means and how to fix it?","You may find the 'util.testing' code in pandas_datareader, which is separate from pandas.",-0.0679224682270276,False,3,6528 +2020-02-04 16:27:59.627,Multiple versions of Python in PATH,"I've installed Python 3.7, and since installed python 3.8. +I've added both their folders and script folders to PATH, and made sure 3.8 is first as I'd like that to be default. +I see that the Python scripts folder has pip, pip3 and pip3.8 and the python 3.7 folder has the same (but with pip3.7 of course), so in cmd typing pip or pip3 will default to version 3.8 as I have that first in PATH. +This is great, as I can explicitly decide which pip version to run. However I don't know how to do to the same for Python. ie. run Python3.7 from cmd. +And things like Jupyter Notebooks only see a ""Python 3"" kernel and don't have an option for both. +How can I configure the PATH variables so I can specify which version of python3 to run?","What OS are you running? If you are running linux and used the system package panager to install python 3.8 you should be able to invoke python 3.8 by typing python3.8. Having multiple binaries named python3 in your PATH is problematic, and having python3 in your PATH point to python 3.8 instead of the system version (which is likely a lower version for your OS) will break your system's package manager. It is advisable to keep python3 in your PATH pointing to whatever the system defaults to, and use python3.8 to invoke python 3.8. +The python version that Jupyter sees will be the version from which you installed it. If you want to be able to use Jupyter with multiple python versions, create a virtual environment with your desired python version and install Jupyter in that environment. Once you activate that specific virtual env you will be sure that the jupyter command that you invoke will activate the currect python runtime.",0.2012947653214861,False,1,6529 +2020-02-04 21:42:07.673,How does the pymssql library fall back on the named pipe port when port 1433 is closed?,"I'm trying to remove pymssql and migrate to pyodbc on a python 3.6 project that I'm currently on. The network topology involves two machines that are both on the same LAN and same subnet. The client is an ARM debian based machine and the server is a windows box. Port 1433 is closed on the MSSQL box but port 32001 is open and pymssql is still able to remotely connect to the server as it somehow falls back to using the named pipe port (32001). +My question is how is pymssql able to fall back onto this other port and communicate with the server? pyodbc is unable to do this as if I try using port 1433 it fails and doesn't try to locate the named pipe port. I've tried digging through the pymssql source code to see how it works but all I see is a call to dbopen which ends up in freetds library land. Also just to clarify, tsql -LH returns the named pip information and open port which falls in line with what I've seen using netstat and nmap. I'm 100% sure pymssql falls back to using the named pipe port as the connection to the named pipe port is established after connecting with pymssql. +Any insight or guidance as to how pymssql can do this but pyodbc can't would be greatly appreciated.",Removing the PORT= parameter and using the SERVER=ip\instance in the connection string uses the named pipes to do the connection instead of port 1433. I'm still not sure how the driver itself knows to do this but it works and resolved my problem.,0.3869120172231254,False,1,6530 +2020-02-04 22:07:19.503,PayPal Adaptive Payments ConvertCurrency Request (deprecated API) in Python,"I can't find any example on how to make a convertcurrency request using the paypal API in python, can you give me some examples for this simple request?","Is this an existing integration for which you have an Adaptive APP ID? If not, the Adaptive Payments APIs are very old and deprecated, so you would not have permissions to use this, regardless of whether you can find ready-made code samples for Python.",0.0,False,1,6531 +2020-02-04 22:26:47.110,Python was not found but can be installed,"I have just installed python3.8 and sublime text editor. I am attempting to run the python build on sublime text but I am met with ""Python was not found but can be installed"" error. +Both python and sublime are installed on E:\ +When opening cmd prompt I can change dir and am able to run py from there without an issue. +I'm assuming that my sublime is not pointing to the correct dir but don't know how to resolve this issue.","i had the same problem, so i went to the microsoft store (windos 10) and simply installed ""python 3.9"" and problem was gone! +sorry for bad english btw",-0.3869120172231254,False,1,6532 +2020-02-05 14:18:27.763,How to use logger with one basic config across app in Python,"I want to improve my understanding of how to use logging correctly in Python. I want to use .ini file to configure it and what I want to do: + +define basic logger config through .fileConfig(...) in some .py file +import logger, call logger = logging.getLogger(__name__) across the app and be sure that it uses my config file that I was loaded recently in different .py file + +I read few resources over Internet ofc but they are describing tricks of how to configure it etc, but want I to understand is that .fileConfig works across all app or works only for file/module where it was declared. +Looks like I missed some small tip or smth like that.","It works across the whole app. Be sure to configure the correct loggers in the config. logger = logging.getLogger(__name__) works well if you know how to handle having a different logger in every module, otherwise you might be happier just calling logger = logging.getLogger(""mylogger"") which always gives you the same logger. If you only configure the root logger you might even skip that and simply use logging.info(""message"") directly.",1.2,True,1,6533 +2020-02-05 17:03:07.580,Is there any way to remove BatchToSpaceND from tf.layers.conv1d?,"As I get, tf.layers.conv1d uses pipeline like this: BatchToSpaceND -> conv1d -> SpaceToBatchND. So the question is how to remove (or disable) BatchToSpaceND and SpaceToBatchND from the pipeline?","As I've investigated it's impossible to remove BatchToSpaceND and SpaceToBatchND from tf.layers.conv1d without changing and rebuilding tensorflow source code. One of the solutions is to replace layers to tf.nn.conv1d, which is low-level representation of convolutional layers (in fact tf.layers.conv1d is a wrapper around tf.nn.conv1d). These low-level implementations doesn't include BatchToSpaceND and SpaceToBatchND.",1.2,True,1,6534 +2020-02-07 09:05:30.220,ConnectionRefusedError: [WinError 10061][WinError 10061] No connection could be made because the target machine actively refused it,"What exactly does this error mean and how can i fix it, am running server on port 8000 of local host. +ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it","Is firewall running on the server? If so, that may be blocking connections. You could disable firewall or add an exception on the server side to allow connections on port 8000.",0.0,False,1,6535 +2020-02-07 17:33:20.807,"Is there a way to get one, unified, mapping from all indices under one alias?","For example if I have 10 indices with similar names and they all alias to test-index, how would I get test-index-1 test-index-2 test-index-3 test-index-4, test-index-5, test-index-6, test-index-7, test-index-8, test-index-9, and test-index-10 to all point to the mapping in use currently when you to a GET /test-index/_mapping?",Not sure what you define as 'unified' mapping - but you can always use wildcards in mapping request. For example : /test-inde*/_mapping would give mapping of all indices in that pattern .,0.0,False,1,6536 +2020-02-08 13:56:49.837,How do I add a mobile geolocation marker into a Folium webmap that automatically updates position?,"I have a webmap which is made in python using Folium. I am adding various geojson layers from an underlying database. I would like to do spatial analysis based on the user's location and their position relative to the various map overlays. As part of this I want to display a marker on the map which indicates the user's current position, and which updates regularly as they move around. +I know how to add markers to the map from within python, using Folium. +I know how to get a constantly updating latitude / longitude of the user using JS +navigator.geolocation.watchPosition(showPosition) +which then passes a position variable to the function showPosition. +I am currently just displaying this as text on the website for now. +What I have not been able to do is to add a marker to the Folium map from inside the webpage, using JS/Leaflet (as Folium is just a wrapper for Leaflet, i think I should be able to do this). +The Folium map object seems to be assigned a new variable name every time the webpage is loaded, and I don't know how to ""get"" the map element and add a marker using the Leaflet syntax +L.marker([lat, lon]).addTo(name_of_map_variable_which_keeps_changing) +Alternatively there might be a way to ""send"" the constantly changing lat/lon variables from the webpage back to the python script so that I can just use folium to add the marker. +But I have been unable to figure this out or find the right assistance online and would appreciate any help.","OK, I have figured out a main part of the question - how to add a user location marker to the Folium map. It is actually very simple: +https://python-visualization.github.io/folium/plugins.html#folium.plugins.LocateControl +I am still unable to pass the user's lat/lon through to my python script so that I can perform spatial queries using that location. So am looking forward to anyone being able to answer that part. Though I may have to post that as a separate question perhaps...",0.0,False,1,6537 +2020-02-09 11:13:26.383,Convert String into the format that readUTF() expects,I created a Client with Java and a Server with Python. The Java client receive data using readUTF() of the class DataInputStream. My problem is that the function readUTF() expects a modified version of 'utf-8' that I don't know how to generate in the (Python) server side.,"I got it!. Using the function read() of the class DataInputStream do work. The problem was that I initialized the destination buffer like this: byte[] ans = {}, instead of allocating some bytes. Thanks for everyone!",0.0,False,1,6538 +2020-02-09 20:57:38.340,Change default version of python in ubuntu 18.04,"I just installed ubuntu 18.04 and I really don't know how does everything work yet. I use the last version of python in my windows system (3.8.1) and would like to use that version as well in ubuntu, but the ""pre-installed"" version of python is 2.7. Is there a way to uninstall that old version of python instead of changin the alias of the python command to match the version I want to use? Can you do that or does ubuntu need to have that version? If you could help me or explain this to me I would appreciate it.","Some services and application in Ubuntu use Python 2.x to run. It is not advisable to remove it. Rather, virtual environments maybe a good practice. There, you can work on Python 3.x, as per your needs, without messing up with the system's dependencies.",0.0,False,1,6539 +2020-02-10 10:36:23.260,How to convert a 3d model into an array of points,"I'm building my own 3d engine, I need to import 3d models into it, but I don't know how to do it. +I wonder if it is possible to convert a 3d model into an array of points; if it is possible, how do you do it?","This isn't something I've done before; but the premise is interesting so I thought I'd share my idea as I have worked with grids (pretty much an array) in 3D space during my time at university. +If you consider 3D space, you could represent that space as a three dimensional array quite simply with each dimension representing an axis. You could then treat each element in that array as a point in space and populate that with a value (say a Boolean of true/false, 1/0) to identify the points of your model within that three dimensional space. +All you'd need is the Height, Width and Depth of your model, with each one of these being the dimensions in your array. Populate the values with 0/false if the model does not have a point in that space, or 1/true if it does. This would then give you a representation of your model as a 3D array.",0.0,False,1,6540 +2020-02-10 11:09:57.583,Discord.py: Adding someone to a discord server with just the discord ID,"I'm trying to add someone to a specific server and then DM said person with just the discord ID. +The way it works is that someone is logging himself in using discord OAuth2 on a website and after he is logged in he should be added to a specific server and then the bot should DM saying something like Welcome to the server! +Has anyone an idea how to do that? +Thanks for any help",It is not possible to leave or join servers with OAuth2. Nor is it possible to DM a user on Discord with a bot unless they share a mutual server.,0.0,False,1,6541 +2020-02-10 21:41:21.090,Run Python Script on AWS and transfer 5GB of files to EC2,"I am an absolute beginner in AWS: I have created a key and an instance, the python script I want to run in the EC2 environment needs to loop through around 80,000 filings, tokenize the sentences in them, and use these sentences for some unsupervised learning. +This might be a duplicate; but I can't find a way to copy these filings to the EC2 environment and run the python script in EC2, I am also not very sure as to how I can use boto3. I am using Mac OS. I am just looking for any way to speed things up. Thank you so so much! I am forever grateful!!!","Here's what I tried recently: + +Create the bucket and keep the bucket accessible for public. +Create the role and add HTTP option. +Upload all the files and make sure the files are public accessible. +Get the HTTP link of the S3 file. +Connect the instance through putty. +wget copies the file into EC2 +instance. + +If your files are in zip format, one time copy enough to move all the files into instance.",1.2,True,2,6542 +2020-02-10 21:41:21.090,Run Python Script on AWS and transfer 5GB of files to EC2,"I am an absolute beginner in AWS: I have created a key and an instance, the python script I want to run in the EC2 environment needs to loop through around 80,000 filings, tokenize the sentences in them, and use these sentences for some unsupervised learning. +This might be a duplicate; but I can't find a way to copy these filings to the EC2 environment and run the python script in EC2, I am also not very sure as to how I can use boto3. I am using Mac OS. I am just looking for any way to speed things up. Thank you so so much! I am forever grateful!!!","Here's one way that might help: + +create a simple IAM role that allows S3 access to the bucket holding your files +apply that IAM role to the running EC2 instance (or launch a new instance with the IAM role) +install the awscli on the EC2 instance +SSH to the instance and sync the S3 files to the EC2 instance using aws s3 sync +run your app + +I'm assuming you've launched EC2 with enough diskspace to hold the files.",0.0,False,2,6542 +2020-02-11 04:04:16.040,pyzk how to get the result of live capture,": 1495 : 2020-02-11 11:55:00 (1, 0) +Here is my sample result but then when I'm trying to split it gives me error +Process terminate : 'Attendance' object has no attribute 'split' +In the documentation it says +print (attendance) # Attendance object +How to access it?","found the solution +i check in the github repository of pyzk and look for the attendance class and found all the object being return by the live_capture thank you :)",1.2,True,1,6543 +2020-02-11 08:29:03.657,which python vs PYTHONPATH,"If I type in which python I get: /home/USER/anaconda3/bin/python +If I type in echo $PYTHONPATH I get: /home/USER/terrain_planning/devel/lib/python2.7/dist-packages:/opt/ros/melodic/lib/python2.7/dist-packages +Should that not be the same? And is it not better to set it: usr/lib/python/ +How would I do that? Add it to the PYTHONPATH or set the PYTHONPATH to that? But how to set which python?","You're mixing 2 environment variables: + +PATH where which looks up for executables when they're accessed by name only. This variable is a list (colon/semi-colon separated depending on the platform) of directories containing executables. Not python specific. which python just looks in this variable and prints the full path +PYTHONPATH is python-specific list of directories (colon/semi-colon separated like PATH) where python looks for packages that aren't installed directly in the python distribution. The name & format is very close to system/shell PATH variable on purpose, but it's not used by the operating system at all, just by python.",1.2,True,1,6544 +2020-02-11 08:37:01.607,Add a new column to multiple .csv and populate with filename,"I am new in python and I have a folder with 15 excel files and I am trying to rename a specific column in each file to a standard name, for instance I have a columns named ""name, and server"" on different files but they entail of the same information so I need to rename them to a standard name like "" server name"" and I don't know how to start","If the position of the columns are the same across all excel file, you can iterate all the 15 excel files, locate the position of the column and replace the text directly. +Alternatively, you can iterate all the files via read_xls (or read_csv depending on your context), reading them as dataframe and replace the necessary column name, and overwrite the file. Below is a reference syntax for your reference. +df.rename(columns={ df.columns[1]: ""your value"" }, inplace = True)",1.2,True,1,6545 +2020-02-11 13:48:39.953,Setting global JsonEncoder in Python,"Basically, I'm fighting with the age-old problem that Python's default json encoder does not support datetime. However all the solutions I can find call to json.dumps and manually pass the ""proper"" encoder on each invocation. And honestly, that can't be the best way to do it. Especially if you want to use a wrapper like jsonify to set up your response object properly, where you can't even specify these parameters. +So: long story short: how to override the global default encoder in Python's JSON implementation to a custom one, that actually does support the features I want? +EDIT: ok so I figured out how to do this for my specific use case (inside Flask). You can do app.json_encoder = MyCustomJSONEncoder there. However how to do this outside of flask would still be an interesting question.","Unfortunately, I could not find a way to set default encoders or decoders for the json module. +So the best way is to do what flask do, that is wrapping the calls to dump or dumps, and provide a default in that wrapper.",0.0,False,1,6546 +2020-02-11 14:46:10.263,How can I use radish with Pycharm to have behave step autocomplete,"Note : radish is a ""Gherkin-plus"" framework—it adds Scenario Loops and Preconditions to the standard Gherkin language, which makes it more friendly to programmers. +So how i can use it or use an other method to use Gherkin step autocomplete with Pycharm. +Thank's","I have solve this problem by buying a professional version of PyCharm, autocomplete is not available for Community version :(",1.2,True,1,6547 +2020-02-11 18:40:45.797,Estimating Dataframe memory usage from file sizes,"If I have a list of files in a directory is it possible to estimate a memory use number that would be taken up by reading or concatenating the files using pd.read_csv(file) or pd.concat([df1, df2])? +I would like to break these files up into concatenation 'batches' where each batch will not exceed a certain memory usage so I do not run into local memory errors. +Using os.path.getsize() will allow me to obtain the file sizes and df.memory_usage() will tell me how much memory the dataframe will use once it's already read in but is there a way to estimate this with just the files themselves?","You could open each CSV, read first 1000 lines only into DataFrame, and then check memory usage. Then scale estimated memory usage by number of lines in the file. +Note that memory_usage() isn't accurate with default arguments, because it won't count strings' memory usage. You need memory_usage(deep=True), although that might overestimate memory usage in some cases. But better to overestimate than underestimate.",0.0,False,1,6548 +2020-02-12 07:09:03.673,How do find correlation between time events and time series data in python?,"I have two different excel files. One of them is including time series data (268943 accident time rows) as below +The other file is value of 14 workers measured daily from 8 to 17 and during 4 months(all data merged in one file) +I am trying to understand correlation between accident times and values (hourly from 8 to 17 per one hour and daily from Monday to Friday and monthly) +Which statistical method is fit(Normalized Auto or cross correlation) and how can I do that? +Generally, in the questions, the correlation analysis are performed between two time series based values, but I think this is a little bit different. Also, here times are different. +Thank your advance..","I think the accident times and the bloodsugar levels are not coming from the same source, and so I think it is not possible to draw a correlation between these two separate datasets. If you would like to assume that the blood sugar levels of all 14 workers reflect that of the workers accident dataset, that is a different story. But what if those who had accidents had a significantly different blood sugar level profile than the rest, and what if your tiny dataset of 14 workers does not comprise such examples? I think the best you may do is to graph the blood sugar level of your 14 worker dataset and also similarly analyze the accident dataset separately, and try to see visually whether there is any correlation here.",0.6730655149877884,False,1,6549 +2020-02-12 13:25:20.013,How to get full path for any (including local) function in python?,"f""{f.__module__}.{f.__name__}"" doesn't work because function f can be local, eg inside another function. We need to add some kind of marked (..) in the path to specify that this function is local. But how to determine when we need to add this marker?",Use f.__qualname__ instead of __name__.,1.2,True,1,6550 +2020-02-12 14:33:31.370,How to use R models in Python,"I have been working on an algorithm trading project where I used R to fit a random forest using historical data while the real-time trading system is in Python. +I have fitted a model I'd like to use in R and am now wondering how can I use this model for prediction purposes in the Python system. +Thanks.","There are several options: +(1) Random Forest is a well researched algorithm and is available in Python through sci-kit learn. Consider implementing it natively in Python if that is the end goal. +(2) If that is not an option, you can call R from within Python using the Rpy2 library. There is plenty of online help available for this library, so just do a google search for it. +Hope this helps.",0.3869120172231254,False,1,6551 +2020-02-12 21:27:39.690,"How many users can Sqlite can handle , Django","I have a Django application, which I hosted on pythonanywhere. For the database, I have used SQLite(default). +So I want to know how many users my applications can handle? +And what if two user register form or make post at same time, will my application will crash?","SQLite supports multiple users, however it locks the database when write operations is being executed. +In other words,concurrent writes cannot be treated with this database, so is not recommended. +You can use PostgreSQL or MySQL as an alternative.",0.0,False,1,6552 +2020-02-13 03:37:40.343,How can I cycle through items in a DynamoDB table?,"How can I cycle through items in a DynamoDB table? +That is, if I have a table containing [A,B,C], how can I efficiently get item A with my first call, item B with my second call, item C with my third call and item A again with my fourth call, repeat? +This table could in the future expand to include D, E, F etc and I would like to incorporate the new elements into the cycle. +The current way I am doing it is giving each item an attribute ""seen"". We scan the whole table, find an element that's not ""seen"" and put it back as ""seen"". When everything has been ""seen"", make all elements not ""seen"" again. This is very expensive.","The efficient way to return items that haven't been seen would be to have an attribute of seen=no included when inserted. Then you could have a global secondary index over that attribute which you could then Query(). +There isn't an efficient way to reset all the seen=yes attributes back to no. Scan() and Query() would both end up returning the entire table and you'd end up updating records one by one. That will not be fast nor cheap with a large table. +EDIT +Once all the records have seen=""yes"" and you want to reset them back to seen=""no"" A query on the GSI suggested above will work exactly like a scan...every record will have to be read and then updated. +If you have 1M records, each about 1K, and you want to reset them...you're going to need +250K reads (since you can read 4 records with a single 4KB RCU) +1M writes",0.0,False,2,6553 +2020-02-13 03:37:40.343,How can I cycle through items in a DynamoDB table?,"How can I cycle through items in a DynamoDB table? +That is, if I have a table containing [A,B,C], how can I efficiently get item A with my first call, item B with my second call, item C with my third call and item A again with my fourth call, repeat? +This table could in the future expand to include D, E, F etc and I would like to incorporate the new elements into the cycle. +The current way I am doing it is giving each item an attribute ""seen"". We scan the whole table, find an element that's not ""seen"" and put it back as ""seen"". When everything has been ""seen"", make all elements not ""seen"" again. This is very expensive.","I think the simplest option is probably: + +use scan with Limit=1 and do not supply ExclusiveStartKey, this will get the first item +if an item was returned and LastEvaluatedKey is present in the response, then re-run scan with ExclusiveStartKey set to the LastEvaluatedKey of the prior response and again Limit=1, repeat step 2 until no item returned or LastEvaluatedKey is absent +when you get zero items returned, you've hit the end of the table, goto step 1 + +This is an unusual pattern and probably not super-efficient, so if you can share any more about what you're actually trying to do here, then we might be able to propose better options.",1.2,True,2,6553 +2020-02-13 12:00:17.947,Python: os.getcwd() randomly fails in mounted network drive,"I'm on Debian using python3.7. I have a network drive that I typically mount to /media/N_drive with dir_mode=0777 and file_mode=0777. I generally have no issues with reading/writing files in this network drive. +Occasionally, especially soon after mounting the drive, if I try to run any Python script with os.getcwd() (including any imported libraries like pandas) I get the error FileNotFoundError: [Errno 2] No such file or directory. If I cd up to the local drive (cd /media/) the script runs fine. +Doing some reading, it sounds like this error indicates that the working directory has been deleted. Yet I can still navigate to the directory, create files, etc. when I'm in the shell. It only seems to be Python's os.getcwd() that has problems. +What is more strange is that this behavior is not predictable. Typically if I wait ~1 hour after mounting the drive the same script will run just fine. +I suspect this has something to do with the way the drive is mounted maybe? Any ideas how to troubleshoot it?","To me, it seems a problem with the mount, e.g. the network disk will be disconnected, and reconnected. So your cwd is not more valid. Note: cwd is pointing to a disk+inode, it is not a name (which you will see). So /media/a is different to /media/a after a reconnection. +If you are looking on how to solve the mounting, you are in the wrong place. Try Unix&Linux sister site, or Serverfault (also a sister site). +If you are looking how to solve programmatically: save cwd at beginning of the script and use os.path.join() at every path access, so that you forcing absolute paths, and not relative paths, and so you should be on the correct location. This is not save, if you happen to read a file during disconnection.",0.3869120172231254,False,1,6554 +2020-02-13 14:20:37.003,Best practice for getting data from Django view into JS to execute on page?,"I have been told it is 'bad practice' to return data from a Django view and use those returned items in Javascript that is loaded on the page. +For example: if I was writing an app that needed some extra data to load/display a javascript based graph, I was told it's wrong to pass that data directly into the javascript on the page from a template variable passed from the Django view. +My first thought: + +Just get the data the graph needs in the django view and return it in a context variable to be used in the template. Then just reference that context variable directly in the javascript in the template. + +It should load the data fine - but I was told that is the wrong way. +So how is it best achieved? +My second thought: + +Spin up Django Rest Framework and create an endpoint where you pass any required data to and make an AJAX request when the page loads - then load the data and do the JS stuff needed. + +This works, except for one thing, how do I get the variables required for the AJAX request into the AJAX request itself? +I'd have to get them either from the context (which is the 'wrong way') or get the parameters from the URL. Is there any easy way to parse the data out of the URL in JS? It seems like a pain in the neck just to get around not utilizing the view for the data needed and accessing those variables directly in the JS. +So, is it really 'bad practice' to pass data from the Django view and use it directly in the Javascript? +Are both methods acceptable? +What is the Django appropriate way to get data like that into the Javascript on a given page/template?","Passing data directly is not always the wrong way to go. JS is there so you can execute code when everything else is ready. So when they tell you it's the wrong way to pass data directly, it's because there is no point in making the page and data heavier than it should be before JS kicks in. +BUT it's okay to pass the essential data so your JS codes knows what it has to do. To make it more clear, let's look into your case: +You want to render a graph. And graphs are sometimes heavy to render and it can make the first render slow. And most of the time, graphs are not so useful without the extra context that your page provides. So in order to make your web page load faster, you let JS load your graph after your webpage has been rendered. And if you're going to wait, then there is no point in passing the extra data needed because it makes the page heavier and slows down the initial render and it takes time to parse and convert those data to JSON objects. +By removing the data and letting JS load them in the background, you make your page smaller and faster to render. So while a user is reading the context needed for your graph, JS will fetch the data needed and renders the graph. This will cause your web page to have a faster initial render. +So in general: +When to pass data directly: + +When the initial data is necessary for JS to do what it has to (configs, defaults, etc). +When the time difference matters a lot and you can't wait too much for an extra request to complete the render. +When data is very small. + +When not to pass data directly: + +When rendering the extra data takes time anyway, so why not get the data latter too? +When the data size is big. +When you need to render something as fast as possible. +When there are some heavy processes needed for those data. +When JS can make your data size smaller (Decide what kind of data should be passed exactly using options that are only accessible by JS.)",1.2,True,1,6555 +2020-02-13 23:49:41.500,Interpreter won't show in Python 3.8.1,I recently downloaded python for the first time and when I load into pycharm to create a new project and it asks to select an interpreter python doesn't show up even when I click the plus sign and search through all my files it doesn't show even though I have the latest python version installed and I have windows 10 I tried deleting both programs and redownloading them but that doesn't seem to work either please if possible and the answer may be obvious but sorry I'm a beginner and also looking at videos didn't help either.,"You have no navigate to the folder where python is downloaded and just select there. +Try the following path C:\Users\YourName\AppData\Local\Programs\Python\Python38-32\python.exe",0.6730655149877884,False,1,6556 +2020-02-14 01:43:31.803,How did scipy ver 0.18 scipy.interpolate.UnivariateSpline deal with values not strictly increasing?,"I have a program written in python 2.7.5 scipy 0.18.1 that is able to run scipy.interpolate.UnivariateSpline with arrays that are non-sequential. When I try to run the same program in python 2.7.14 / scipy 1.0.0 I get the following error: +File ""/usr/local/lib/python2.7/site-packages/scipy/interpolate/fitpack2.py"", line 176, in init + raise ValueError('x must be strictly increasing') +Usually I would just fix the arrays to remove the non-sequential values. But in this case I need to reproduce the exact same solution produced by the earlier version of python/scipy. Can anyone tell me how the earlier code dealt with the situation where the values were not sequential?",IIRC this was whatever the FITPACK (the fortran library the univariatespline class wraps) was doing. So the first stop would be to remove the check from your local scipy install and see if this does the trick,1.2,True,1,6557 +2020-02-14 09:01:36.233,Send mail via Python logging in with Windows Authentication,"I've a conceptual doubt, I don't know if it's even possible. +Assume I log on a Windows equipment with an account (let's call it AccountA from UserA). However, this account has access to the mail account (Outlook) of the UserA and another fictional user (UserX, without any password, you logg in thanks to Windows authentication), shared by UserA, UserB and UserC. +Can I send a mail from User A using the account of User X via Python? If so, how shall I do the log in? +Thanks in advance","A interesting feature with Windows Authentication is that is uses the well known Kerberos protocol under the hood. In a private environment, that means if a server trusts the Active Directory domain, you can pass the authentication of a client machine to that server provided the service is Kerberized, even if the server is a Linux or Unix box and is not a domain member. +It is mainly used for Web servers in corporate environment, but could be used for any kerberized service. Postfix for example is know to accept this kind of authentication. + +If you want to access an external mail server, you will have to store the credential in plain text on the client machine, which is bad. An acceptable way would be to use a file only readable by the current user (live protection) in an encrypted folder (at rest protection).",1.2,True,1,6558 +2020-02-14 17:19:50.673,How to switch two words around in file document in python,"I was wondering how to switch two words around in a file document in python. Example: I want to switch the words motorcycle to car, and car to motorcycle. +The way I'm doing it is making it have all the words motorcycle change to car, and because car is being switched to motorcycle, it get's switched back to car. Hopefully that makes sense.","First, replace all the motocycle to carholder +Second, replace all car to motocycle +Third, replace all carholder to car +That's it",0.6730655149877884,False,1,6559 +2020-02-15 11:54:26.760,umqtt.robust on Wemos,"I am trying to install micropython-umqtt.robust on my Wemos D1 mini. +The way i tried this is as follow. +I use the Thonny editor + +I have connected the wemos to the internet. +in wrepl type: +import upip +upip.install('micropython-umqtt.simple') +I get the folowing error: Installing to: /lib/ +Error installing 'micropython-umqtt.simple': Package not found, packages may be partially installed +upip.install('micropython-umqtt.robust') +I get the folowing error: Error installing 'micropython-umqtt.robust': Package not found, packages may be partially installed + +Can umqtt be installed on Wemos D1 mini ? if yes how do I do this ?","Thanks for your help Reilly, +The way I solved it is as follow. With a bit more understanding of mqtt and micropython I found that the only thing that happens when you try to install umqtt simple and umqtt robust,is that it makes in de lib directory of your wemos a new directory umqtt. Inside this directory it installs two files robust.py and simple.py. While trying to install them I kept having error messages. But I found a GitHub page for these two files, so I copied these files. Made the umqtt directory within the lib directory and in this umqtt directory I pasted the two copied files. Now I can use mqtt on my wemos.",0.3869120172231254,False,2,6560 +2020-02-15 11:54:26.760,umqtt.robust on Wemos,"I am trying to install micropython-umqtt.robust on my Wemos D1 mini. +The way i tried this is as follow. +I use the Thonny editor + +I have connected the wemos to the internet. +in wrepl type: +import upip +upip.install('micropython-umqtt.simple') +I get the folowing error: Installing to: /lib/ +Error installing 'micropython-umqtt.simple': Package not found, packages may be partially installed +upip.install('micropython-umqtt.robust') +I get the folowing error: Error installing 'micropython-umqtt.robust': Package not found, packages may be partially installed + +Can umqtt be installed on Wemos D1 mini ? if yes how do I do this ?","I think the MicroPython build available from micropython.org already bundles MQTT so no need to install it with upip. Try this directly from the REPL: +from umqtt.robust import MQTTClient +or +from umqtt.simple import MQTTClient +and start using it from there +mqtt = MQTTClient(id, server, user, password)",1.2,True,2,6560 +2020-02-16 04:54:39.390,how to add python in xilinx vitis,"I have implemented a Zynq ZCU102 board in vivado and I want to use final "".XSA"" file into VITIS, but after creating a new platform, its languages are C and C++, While in the documentation was told that vitis supports python. +My question is how can I add python to my vitis platform? +Thank you",Running Python in FPGA needs an Operating System. I had to run Linux OS on my FPGA using petaLinux and then run python code on it.,1.2,True,1,6561 +2020-02-16 14:44:02.093,"How to create ""add to favorites"" functional using Django Rest Framework","I just can’t find any information about the implementation of the system of adding to favorites for registered users. +The model has a Post model. It has a couple of fields of format String. The author field, which indicates which user made the POST request, etc. +But how to make it so that the user can add this Post to his “favorites”, so that later you can get a JSON response with all the posts that he added to himself. Well, respectively, so that you can remove from favorites. +Are there any ideas?",You can add a favorite_posts field (many-to-many) in your Author model.,-0.3869120172231254,False,1,6562 +2020-02-17 04:26:06.590,"how to customized hr,month,year in python date time module?","How can i customize hrs,days,months of date time module in python? +day of 5 hrs only, a month of 20 days only, and a year of 10 months only. +using date time module.","I agree with @TimPeters . This just doesn't fit in what datetime does. +For your needs, I would be inclined to start my own class from scratch, as that is pretty far from datetime. +That said...you could look into monkeypatching datetime...but I would recommend against it. It's a pretty complex beast, and changing something as fundamental as the number of hours in a day will blow away unknown assumptions within the code, and would certainly turn its unit tests upside down. +Build your own from scratch is my advice.",0.0,False,1,6563 +2020-02-17 06:51:16.120,Bad interpreter file not found error when running flask commands,"Whenever I run a flask command in my project, I get an error of the form zsh: (correct file path)/venv/bin/flask: bad interpreter: (incorrect, old file path)/venv/bin/python3. I believe the error is due to the file paths not matching, and the second file path no longer existing. I changed the name of the directory for my project when I changed the name of the project, but I don't know how to change the path that flask searches for the interpreter in. +Thanks in advance. +Edit: I just tried going into the flask file at (correct file path)/venv/bin. I saw that it still had #!(incorrect, old file path)/venv/bin/python3 at the top. I tried changing this to #!(correct file path)/venv/bin/python3, but the same error as before persisted, as well as the flask app not being able to find the flask_login module, which it was not having issues with before.","Ok, I figured out how to fix it. I had to go into my (correct file path)/venv/bin/flask file and change the file path after the #! to the correct file path. I had to do the same for pip, pip3, and pip3.7 which were all in the same location as the flask file. Then I had to reinstall the flask_login package. This fixed everything.",0.0,False,1,6564 +2020-02-17 13:37:36.463,Implementing saved python regression model to react expo application,"I have a python regression model that predicts one's level of happiness based on user-input data, i have trained and tested it using Python. +But I'm using React Native to create my mobile application. +My mobile application will take in the user-input data needed and will output a prediction on their level of happiness. Anyone has an idea on how to implement this? Any advice would be appreciated! I lack the experience, but have an interest in this area, Im still learning so please help me out :)",You need to create python API and call it from the mobile application by passing the input features. Python API will return you the forecasted value. This API will load the regression model and make a forecast on given input features. I hope It will help.,0.3869120172231254,False,1,6565 +2020-02-18 14:37:41.817,I have set up a small flask webpage but in only runs on localhost while I would like to make it run on my local network python3.7,"I have set up a small flask webpage but in only runs on localhost while I would like to make it run on my local network, how do I do that?","Just my 2 cents on this, I just did some research, there are many suggestions online... +Adding a parameter to your app.run(), by default it runs on localhost, so change it to app.run(host= '0.0.0.0') to run on your machines IP address. +Few other things you could do is to use the flask executable to start up your local server, and then you can use flask run --host=0.0.0.0 to change the default IP which is 127.0.0.1 and open it up to non local connections. +The thing is you should use the app.run() method which is much better than any other methods. +Hope it helps a little, if not good luck :)",1.2,True,1,6566 +2020-02-18 23:36:54.463,Do .py Python files contain metadata?,".doc files, .pdf files, and some image formats all contain metadata about the file, such as the author. +Is a .py file just a plain text file whose contents are all visible once opened with a code editor like Sublime, or does it also contain metadata? If so, how does one access this metadata?","On Linux and most Unixes, .py's are just text (sometimes unicode text). +On Windows and Mac, there are cubbyholes where you can stash data, but I doubt Python uses them. +.pyc's, on the other hand, have at least a little metadata stuff in them - or so I've heard. Specifically: there's supposed to be a timestamp in them, so that if you copy a filesystem hierarchy, python won't automatically recreate all the .pyc's on import. There may or may not be more.",1.2,True,1,6567 +2020-02-19 12:51:11.683,Errors such as: 'Solving environment: failed with initial frozen solve. Retrying with flexible solve' & 'unittest' tab,"I am working with spyder - python. I want to test my codes. I have followed the pip install spyder-unittest and pip install pytest. I have restarted the kernel and restarted my MAC as well. Yet, Unit Testing tab does not appear. Even when I drop down Run cannot find the Run Unit test. Does someone know how to do this?","So, I solved the issue by running the command: +conda config --set channel_priority false. +And then proceeded with the unittest download with the command run: +conda install -c spyder-ide spyder-unittest. +The first command run conda config --set channel_priority false may solve other issues such as: +Solving environment: failed with initial frozen solve. Retrying with flexible solve",1.2,True,1,6568 +2020-02-19 17:27:39.387,JupyterLab - python open() function results in FileNotFoundError,"I am trying to open an existing file in a subfolder of the current working directory. This is my command: +fyle = open('/SPAdes/default/{}'.format(file), 'r') +The filevariable contains the correct filename, the folder structure is correct (working on macOS), and the file exists. +This command, however, results if this error message: +FileNotFoundError: [Errno 2] No such file or directory: [filename] +Does it have anything to do with the way JupyterLab works? How am I supposed to specify the folder srtucture on Jupyter? I am able to create a new file in the current folder, but I am not able to create one in a subfolder of the current one (results in the same error message). +The folder structure is recognized on the same Jupyter notebook by bash commands, but I am somehow not able to access subfolders using python code. +Any idea as to what is wrong with the way I specified the folder structure? +Thanks a lot in advance.","There shouldn’t be a forward slash in front of SPAdes. +Paths starting with a slash exist high up in file hierarchy. You said this is a sub-directory of your current working directory.",0.6730655149877884,False,1,6569 +2020-02-19 18:16:29.400,What's a good way to save all data related to a training run in Keras?,"I know how to do a few things already: + +Summarise a model with model.summary(). But this actually doesn't print everything about the model, just the coarse details. +Save model with model.save() and load model with keras.models.load_model() +Get weights with model.get_weights() +Get the training history from model.fit() + +But none of these seem to give me a catch all solution for saving everything from end to end so that I can 100% reproduce a model architecture, training setup, and results. +Any help filling in the gaps would be appreciated.","model.to_json() can be used to convert model config into json format and save it as a json. +You can recreate the model from json using model_from_json found in keras.models +Weights can be saved separately using model.save_weights. +Useful in checkpointing your model. Note that model.save saves both of these together. Saving only the weights and loading them back useful when you need to work with the variables used in defining the model. In that case create the model using the code and do model.load_weights.",0.0,False,1,6570 +2020-02-20 07:22:20.357,continuous log file processing and extract required data using python,"I have to analyze a log file which will generate continuously 24*7. So, the data will be huge. I will have credentials to where log file is generating. But how can I get that streaming data ( I mean like any free tools or processes) so that I can use it in my python code to extract some required information from that log stream and will have to prepare a real time dashboard with that data. please tell some possibilities to achieve above task.","Just a suggestion +You could try with ELK: +ELK, short for Elasticsearch (ES), Logstash, and Kibana, is the most popular open source log aggregation tool. Es is a NoSQL. Logstash is a log pipeline system that can ingest data, transform it, and load it into a store like Elasticsearch. Kibana is a visualization layer on top of Elasticsearch. +or +you could use Mongo DB to handle such huge amount of data: +MongoDB is an open-source document database and leading NoSQL. Mongo DB stores data in a json format. Process the logs and store it in a json format and retrieve it for any further use. +Basically its not a simple question to explain, it depends on the scenarios.",0.0,False,1,6571 +2020-02-20 12:40:01.843,Tika in Python Azure Function,"I'm trying to create a function on Azure Function Apps that is given back a PDF and uses the python tika library to parse it. +This setup works fine locally, and I have the python function set up in Azure as well, however I cannot figure out how to include Java in the environment? +At the moment, when I try to run the code on the server I get the error message + +Unable to run java; is it installed? + Failed to receive startup confirmation from startServer.","So this isnt possible at this time. To solve it, I abstracted out the tika code into a Java Function app and used that instead.",1.2,True,1,6572 +2020-02-20 14:06:16.640,When python is referred to as single threaded why does in not have the same pitfalls in processing as something like node.js?,"I've been doing Node programming for a while and one thing I'm just very tired of is having to worry about blocking the event loop with anything that requires lots of cpu time. I'd also like to expand my language skills to something more focused on machine learning, so python seemed like a good choice based on what I've read. +However, I keep seeing that python is also single threaded, but I get the feeling this wording is being used in a different way than how it's usually used in node. Python is the go to language for a lot of heavy data manipulation so I can't imagine it blocks the same way node does. Can someone with more familiarity with python (and some with node) explain how their processing of concurrent requests differs when 1 request is cpu intensive?","First of all Python is not single-threaded, but its standard library contains everything required to manage threads. It works fine for IO bound tasks, but does not for CPU bound tasks because of the Global Interpretor Lock which prevents more than one thread to execute Python code at the same time. +For data processing tasks, several modules exist that add low level (C code level) processing and internally manage the GIL to be able to use multi-core processing. The most used modules here are scipy and numpy (scientific and numeric processing) and pandas which is an efficient data frame processing tools using numpy arrays for its underlying containers. +Long story short: For io bound tasks, Python is great. If your problem is vectorizable through numpy or pandas, Python is great. If your problem is CPU intensive and neither numpy nor pandas will be used, Python is not at its best.",0.3869120172231254,False,1,6573 +2020-02-23 01:42:23.757,subprocess.check_call command called not using threads,"I'm running the following command using subprocess.check_call +['/home/user/anaconda3/envs/hum2/bin/bowtie2-build', '-f', '/media/user/extra/tmp/subhm/sub_humann2_temp/sub_custom_chocophlan_database.ffn', '/media/user/extra/tmp/subhm/sub_humann2_temp/sub_bowtie2_index', ' --threads 8'] +But for some reason, it ignores the --threads argument and runs on one thread only. I've checked outside of python with the same command that the threads are launched. This only happens when calling from subprocess, any idea on how to fix this? +thanks","You are passing '--threads 8' and not '--threads', '8'. Although it could be '--threads=8' but I don't know the command.",1.2,True,1,6574 +2020-02-23 14:42:25.190,How to change the name of a mp4 video using python,I just want to know how can I change the name of mp4 video using python. I tried looking on the internet but could not find it. I am a beginner in python,"you can use os module to rename as follows... + +import os +os.rename('full_file_path_old','new_file_name_path)",1.2,True,1,6575 +2020-02-23 16:13:40.300,Converting depth map to pointcloud on Raspberry PI for realtime application,"I am developing a robot based on StereoPI. I have successfully calibrated the cameras and obtained a fairly accurate depth map. However, I am unable to convert my depth map to point cloud so that I can obtain the actual distance of an object. I have been trying to use cv2.reprojectImageTo3D, but see no success. May I ask if there is a tutorial or guide which teaches how to convert disparity map to point cloud? +I am trying very hard to learn and find reliable sources but see on avail. So, Thank you very much in advance.","By calibrating your cameras you compute their interior orientation parameters (IOP - or intrinsic parameters). To compute the XYZ coordinates from the disparity you need also the exterior orientation parameters (EOP). +If you want your point cloud relative to the robot position, the EOP can be simplified, otherwise, you need to take into account the robot's position and rotation, which can be retrieved with a GNSS receiver and intertial measurement unit (IMU). Note that is very likely that such data need to be processed with a Kalman filter. +Then, assuming you got both (i) the IOP and EOP of your cameras, and (ii) the disparity map, you can generate the point cloud by intersection. There are several ways to accomplish this, I suggest using the collinearity equations.",0.0,False,1,6576 +2020-02-25 03:32:31.883,What is the best way to implement Django 3 Modal forms?,"I appreciate it if somebody gives the main idea of how to handle submission/retrieval form implementation in Bootstrap modals. I saw many examples on google but it is still ambiguous for me. Why it is required to have a separate Html file for modal-forms template? Where SQL commands will be written? What is the flow in submission/retrieval forms (I mean steps)? What is the best practice to implement these kind of forms? I'm fairly new to Django, please be nice and helpful.","No need for separate file for modal-form. Here MVT structure following, whenever forms are used. Easy interaction to template. Moreover if you go through Django documentation, you will get to know easily. +Submission - mention the form action url. It will call that and check the django forms",0.0,False,1,6577 +2020-02-25 03:53:05.757,How do we calculate the accuracy of a multi-class classifier using neural network,"When the outputs (prediction) are the probabilities coming from a Softmax function, and the training target is one-hot type, how do we compare those two different kinds of data to calculate the accuracy? +(the number of training data classified correctly) / (the number of the total training data) *100%","Usually, we assign the class label with highest probability in the output of the soft max function as the label.",1.2,True,1,6578 +2020-02-25 16:58:00.407,"When switching to zsh shell on mac terminal from bash, how do you update the base python version?","Mac has recently updated its terminal shell to Zsh from bash. As a python programmer, I'd like to have a consistency in python versions across all the systems that includes terminals, & IDE. +On a bash shell, to update the python version in the terminal to 3.8.1, I had followed the below process +nano ~/.bash_profile +alias python=python3 +ctrl + x +y +enter +This enabled me to update the python version from 2.7.6 to 3.8.1. However, repeating the same steps for zsh shell didn't work out. Tried a tweak of the above process, and somehow stuck with 3.7.3 +steps followed +which python3 #Location of the python3.8.1 terminal command file is found. Installed it. +python --version #returned python 3.7.3 +PS: I am an absolute beginner in python, so please consider that in your response. I hope i am not wasting your time.","it is actually not recommendet to update the default Python executable system-wide because some applications are depending on it. +Although, you can use venv (virtual environment) or for using another version of Python within your ZSH you can also put an alias like python='python3' in your ~/.zsh_profile and source it. +Hope that helps. +Greetings",0.3869120172231254,False,1,6579 +2020-02-25 19:43:50.643,How can I darken/lighten a RGB color,"So I'm trying to make a color gradient, from a color to completely black, as well as from a color to completely white. +So say I have (175, 250, 255) and I want to darken that color exactly 10 times to end at (0, 0, 0), how could I do this? +I'd also like to brighten the color, so I'd like to brighten it exactly 10 times and end at (255, 255, 255).","Many ways to solve this one. One idea would be to find the difference between your current value to the target value and divide that by 10. +So (175, 250, 255) to (0, 0, 0) difference is (175, 250, 255), then divide that by ten to have what you would subtract each of the ten steps. So subtract (-17.5, -25, -25.5) every step, rounding when needed.",0.0,False,1,6580 +2020-02-26 11:00:22.870,Django Queryset - Can I query at specific positions in a string for a field?,"I have a table field with entries such as e.g. 02-65-04-12-88-55. +Each position (separated by -) represents something. (There is no '-' in the database, that's how it's displayed to the user). +Users would like to search by the entry's specific position. I am trying to create a queryset to do this but cannot figure it out. I could handle startswith, endswith but the rest - I have no idea. +Other thoughs would be to split the string at '-' and then query at each specific part of the field (if this is possible). +How can a user search the field's entry at say positions 0-1, 6-7, 10-11 and have the rest wildcarded and returned? +Is this possible? I may be approaching this wrong? Thoughts?","You could use a something__like='__-__-__-__-88-__' query, but it's likely to not be very efficient (since the database will have to scan through all rows to find a match). +If you need to lots of these queries, it'd be better to split these out to actual fields (something_1, something_2, etc.)",0.0,False,1,6581 +2020-02-28 11:26:45.567,Python Script to compare du and df console outputs,"As part of a larger project, I'm currently writing a python script that runs Linux commands in a vApp. +I'm currently facing an issue where after working with a mounted iso, it may or may not unmount as expected. +To check the mount status, I want to run the df -hk /directory and du -sch /directory commands respectively, and compare the outputs. +If the iso is not unmounted, the result for the df command should return a larger value than the du command as the df command includes the mount size in the result, while du does not. +I'm just wondering how can i compare these values or if there is a better way for me to run this check in the first place.","why don't you use /proc/mounts ? +First column is you blockdevice, second is the mountpoint. +If you mountpoint is not in /proc/mounts you have nothing mounted here.",0.3869120172231254,False,1,6582 +2020-02-28 16:42:15.147,Why no need to load Python formatter (black) and linter (pylint) and vs code?,"I am learning how to use VS code and in the process, I learnt about linting and formatting with ""pylint"" and ""black"" respectively. +Importantly, I have Anaconda installed as I often use conda environments for my different projects. I have therefore installed ""pylint"" and ""black"" into my conda environment. +My questions are as follows: + +If ""pylint"" and ""black"" are Python packages, why do they not need to be imported into your script when you use them? (i.e. ""import pylint"" and ""import black"" at the top of a Python script you want to run). I am very new to VS code, linting and formatting so maybe I'm missing something obvious but how does VS code know what to do when I select ""Run Linting"" or ""Format document"" in the command palette? Or is this nothing to do with VS code ? + +I guess I am just suprised at the fact we don't need to import these packages to use them. In contrast you would always be using import for other packages (sys, os, or any other). + +I'm assuming if I used a different conda environment, I then need to install pylint and black again in it right?","Yes, black and pylint are only available in the conda environment you installed them in. You can find them in the ""Scripts""-folder of your environment. +VS Code knows where to look for those scripts, I guess you can set which package is used for ""Run Linting"" or ""Format document"". +You only need to import python modules or functions that you want to use inside your python module. But that's not what you do.",0.0,False,1,6583 +2020-02-29 17:31:05.917,Dask progress during task,"With dask dataframe using +df = dask.dataframe.from_pandas(df, npartitions=5) +series = df.apply(func) +future = client.compute(series) +progress(future) +In a jupyter notebook I can see progress bar for how many apply() calls completed per partition (e.g 2/5). +Is there a way for dask to report progress inside each partition? +Something like tqdm progress_apply() for pandas.","If you mean, how complete each call of func() is, then no, there is no way for Dask to know that. Dask calls python functions which run in their own python thread (python threads cannot be interrupted by another thread), and Dask only knows whether the call is done or not. +You could perhaps conceive of calling a function which has some internal callbacks or other reporting system, but I don't think I've seen anything like that.",0.0,False,1,6584 +2020-03-02 02:33:41.653,Using a Decision Tree to build a Recommendations Application,"First of all, my apologies if I am not following some of the best practices of this site, as you will see, my home is mostly MSE (math stack exchange). +I am currently working on a project where I build a vacation recommendation system. The initial idea was somewhat akin to 20 questions: We ask the user certain questions, such as ""Do you like museums?"", ""Do you like architecture"", ""Do you like nightlife"" etc., and then based on these answers decide for the user their best vacation destination. We answer these questions based on keywords scraped from websites, and the decision tree we would implement would allow us to effectively determine the next question to ask a user. However, we are having some difficulties with the implementation. Some examples of our difficulties are as follows: +There are issues with granularity of questions. For example, to say that a city is good for ""nature-lovers"" is great, but this does not mean much. Nature could involve say, hot, sunny and wet vacations for some, whereas for others, nature could involve a brisk hike in cool woods. Fortunately, the API we are currently using provides us with a list of attractions in a city, down to a fairly granular level (for example, it distinguishes between different watersport activities such as jet skiing, or white water rafting). My question is: do we need to create some sort of hiearchy like: + +nature-> (Ocean,Mountain,Plains) (Mountain->Hiking,Skiing,...) + +or would it be best to simply include the bottom level results (the activities themselves) and just ask questions regarding those? I only ask because I am unfamiliar with exactly how the classification is done and the final output produced. Is there a better sort of structure that should be used? +Thank you very much for your help.","Bins and sub bins are a good idea, as is the nature, ocean_nature thing. +I was thinking more about your problem last night, TripAdvisor would be a good idea. What I would do is, take the top 10 items in trip advisor and categorize them by type. +Or, maybe your tree narrows it down to 10 cities. You would rank those cities according to popularity or distance from the user. +I’m not sure how to decide which city would be best for watersports, etc. You could even have cities pay to be top of the list.",0.0,False,2,6585 +2020-03-02 02:33:41.653,Using a Decision Tree to build a Recommendations Application,"First of all, my apologies if I am not following some of the best practices of this site, as you will see, my home is mostly MSE (math stack exchange). +I am currently working on a project where I build a vacation recommendation system. The initial idea was somewhat akin to 20 questions: We ask the user certain questions, such as ""Do you like museums?"", ""Do you like architecture"", ""Do you like nightlife"" etc., and then based on these answers decide for the user their best vacation destination. We answer these questions based on keywords scraped from websites, and the decision tree we would implement would allow us to effectively determine the next question to ask a user. However, we are having some difficulties with the implementation. Some examples of our difficulties are as follows: +There are issues with granularity of questions. For example, to say that a city is good for ""nature-lovers"" is great, but this does not mean much. Nature could involve say, hot, sunny and wet vacations for some, whereas for others, nature could involve a brisk hike in cool woods. Fortunately, the API we are currently using provides us with a list of attractions in a city, down to a fairly granular level (for example, it distinguishes between different watersport activities such as jet skiing, or white water rafting). My question is: do we need to create some sort of hiearchy like: + +nature-> (Ocean,Mountain,Plains) (Mountain->Hiking,Skiing,...) + +or would it be best to simply include the bottom level results (the activities themselves) and just ask questions regarding those? I only ask because I am unfamiliar with exactly how the classification is done and the final output produced. Is there a better sort of structure that should be used? +Thank you very much for your help.","I think using a decision tree is a great idea for this problem. It might be an idea to group your granular activities, and for the ""nature lovers"" category list a number of different climate types: Dry and sunny, coastal, forests, etc and have subcategories within them. +For the activities, you could make a category called watersports, sightseeing, etc. It sounds like your dataset is more granular than you want your decision tree to be, but you can just keep dividing that granularity down into more categories on the tree until you reach a level you're happy with. It might be an idea to include images too, of each place and activity. Maybe even without descriptive text.",0.0,False,2,6585 +2020-03-02 05:24:30.433,How to use an exported model from google colab in Pycharm,"I have a LSTM Keras Tensorflow model trained and exported in .h5 (HDF5) format. +My local machine does not support keras tensorflow. I have tried installing. But does not work. +Therefore, i used google colabs and exported the model. +I would like to know, how i can use the exported model in pycharm +Edit : I just now installed tensorflow on my machine +Thanks in Advance",You still need keras and tensorflow to use the model.,0.0,False,1,6586 +2020-03-02 08:41:18.990,How to make PyQt5 program starts like pycharm,"As the title says i want to know how to make PyQt5 program starts like pycharm/spyder/photoshop/etc so when i open the program an image shows with progress bar(or without) like spyder,etc",Sounds like you want a splash screen. QSplashScreen will probably be your friend.,1.2,True,1,6587 +2020-03-02 12:31:11.530,What is the point of using sys.exit (or raising SystemExit)?,"This question is not about how to use sys.exit (or raising SystemExit directly), but rather about why you would want to use it. + +If a program terminates successfully, I see no point in explicitly exiting at the end. +If a program terminates with an error, just raise that error. Why would you need to explicitly exit the program or why would you need an exit code?","Letting the program exit with an Exception is not user friendly. More exactly, it is perfectly fine when the user is a Python programmer, but if you provide a program to end users, they will expect nice error messages instead of a Python stacktrace which they will not understand. +In addition, if you use a GUI application (through tkinter or pyQt for example), the backtrace is likely to be lost, specially on Windows system. In that case, you will setup error processing which will provide the user with the relevant information and then terminate the application from inside the error processing routine. sys.exit is appropriate in that use case.",1.2,True,1,6588 +2020-03-02 23:01:44.213,"VS Code Azure Functions: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available","Trying to deploy Azure Functions written in Python and looks like the only option to do that is through VS Code. +I have Python and Azure Functions extensions, and normally use PyCharm with Anaconda interpreter. +I also have azure-functions-core-tools installed and calling ""func"" in PS works. +In the VS Code I create a virtual environment as it suggests. But when tyring to debug any Azure Function (using one of their templates for now) I get the error above. +As far as I understand it tries to install ""azure-functions"" module as specified in the ""requirements.txt"" file and tries to do that with pip. pip works normally if I use it through Anaconda prompt or with my global env python, but I have to use the virtual environment created by VS Code for this one. +Any suggestions on how to get through this? Thanks in advance.","Just solved the problem after wasting my valuable whole afternoon. The problem lies on the side of Anaconda. +As you described in your question, pip works normally (only) in your Anaconda prompt. Which means, it doesn't work anywhere outside, no matter in a CMD or a PowerShell (although pip and conda seem work outside of the prompt, SSL requests get somehow always refused). However, VS Code, when you simply press F5 instead of using func start command, uses an external PowerShell to call pip. No wonder it'll fail. +The problem can be solved, when you install Anaconda on Windows 10, by choosing to add Anaconda's root folder to PATH. This being said, Anaconda's installer strongly doesn't recommend choosing this option (conflicts with other apps blabla)... And if you try to install Anaconda through some package manager such as scoop, it'll install it without asking you for this detail, which is logical. +The ""fun"" part is philosophically Anaconda itself doesn't suggest using conda or pip command outside Anaconda Prompt, while other apps want and may have to do it the other way. Very very confusing and annoying.",0.3869120172231254,False,1,6589 +2020-03-03 11:36:54.743,wxPython wx.CallAfter(),I work with wxpython and threads in my project. I think that I didn't understand well how to use wx.CallAfter and when to us it. I read few thing but I still didn't got the point. Someone can explain it to me?,"In a nutshell, wx.CallAfter simply takes a callable and the parameters that should be passed to it, bundles that up into a custom event, and then posts that event to the application's pending event queue. When that event is dispatched the handler calls the given callable, passing the given parameters to it. +Originally wx.CallAfter was added in order to have an easy way to invoke code after the current and any other pending events have been processed. Since the event is always processed in the main UI thread, then it turns out that wx.CallAfter is also a convenient and safe way for a worker thread to cause some code to be run in the UI thread.",1.2,True,1,6590 +2020-03-03 18:37:00.133,How to use huggingface T5 model to test translation task?,"I see there exits two configs of the T5model - T5Model and TFT5WithLMHeadModel. I want to test this for translation tasks (eg. en-de) as they have shown in the google's original repo. Is there a way I can use this model from hugging face to test out translation tasks. I did not see any examples related to this on the documentation side and was wondering how to provide the input and get the results. +Any help appreciated","T5 is a pre-trained model, which can be fine-tuned on downstream tasks such as Machine Translation. So it is expected that we get gibberish when asking it to translate -- it hasn't learned how to do that yet.",0.2012947653214861,False,1,6591 +2020-03-03 19:05:01.693,Python: Create List Containing 10 Successive Integers Starting with a Number,"I want to know how to create a list called ""my_list"" in Python starting with a value in a variable ""begin"" and containing 10 successive integers starting with ""begin"". +For example, if begin = 2, I want my_list = [2,3,4,5,6,7,8,9,10,11]","Simply you can use extend method of list and range function. +start = 5 +my_list = [] +my_list.extend(range(start,start+11)) +print(my_list)",0.0,False,1,6592 +2020-03-04 04:29:00.517,How to change resetting password of django,"I am learning to use django and my question is if it is possible to change the system to reset the users' password, the default system of sending a link by mail I do not want to use it, my idea is to send a code to reset the password , but I don't know how it should be done and if possible, I would also need to know if it's safe. +What I want is for the user who wants to recover his password to go to the recovery section, fill in his email and choose to send and enable a field to put the code that was sent to the mail. +I don't know how I should do it or is there a package for this? +Thank you very much people greetings.","You can do this, when user clicks on reset password ask for users email id, verify that email id provided is same as what you have in DB. If the email id matches you can generate a OTP and save it in DB(for specific time duration like 3 mins) and send it to user's Email id. Now User enters the OTP. If the OTP provided by user matches the one you have in DB, open the page where user can enter new password.",0.0,False,1,6593 +2020-03-04 15:31:36.817,How are threads different from process in terms of how they are executed on hardware level?,"I was wondering how the threads are executed on hardware level, like a process would run on a single processing core and make a context switch on the processor and the MMU in order to switch between processes. How do threads switch? Secondly when we create/spawn a new thread will it be seen as a new process would for the processor and be scheduled as a process would? +Also when should one use threads and when a new process? +I know I probably am sounding dumb right now, that's because I have massive gaps in my knowledge that I would like fill. Thanks in advance for taking the time and explaining things to me. :)","Think of it this way: ""a thread is part of a process."" +A ""process"" owns resources such as memory, open file-handles and network ports, and so on. All of these resources are then available to every ""thread"" which the process owns. (By definition, every ""process"" always contains at least one (""main"") ""thread."") +CPUs and cores, then, execute these ""threads,"" in the context of the ""process"" which they belong to. +On a multi-CPU/multi-core system, it is therefore possible that more than one thread belonging to a particular process really is executing in parallel. Although you can never be sure. +Also: in the context of an interpreter-based programming language system like Python, the actual situation is a little bit more complicated ""behind the scenes,"" because the Python interpreter context does exist and will be seen by all of the Python threads. This does add a slight amount of additional overhead so that it all ""just works.""",0.1352210990936997,False,2,6594 +2020-03-04 15:31:36.817,How are threads different from process in terms of how they are executed on hardware level?,"I was wondering how the threads are executed on hardware level, like a process would run on a single processing core and make a context switch on the processor and the MMU in order to switch between processes. How do threads switch? Secondly when we create/spawn a new thread will it be seen as a new process would for the processor and be scheduled as a process would? +Also when should one use threads and when a new process? +I know I probably am sounding dumb right now, that's because I have massive gaps in my knowledge that I would like fill. Thanks in advance for taking the time and explaining things to me. :)","There are a few different methods for concurrency. The threading module creates threads within the same Python process and switches between them, this means they're not really running at the same time. The same happens with the Asyncio module, however this has the additional feature of setting when a thread can be switched. +Then there is the multiprocessing module which creates a separate Python process per thread. This means that the threads will not have access to shared memory but can mean that the processes run on different CPU cores and therefore can provide a performance improvement for CPU bound tasks. +Regarding when to use new threads a good rule of thumb would be: + +For I/O bound problems, use threading or async I/O. This is because you're waiting on responses from something external, like a database or browser, and this waiting time can instead be filled by another thread running it's task. +For CPU bound problems use multiprocessing. This can run multiple Python processes on separate cores at the same time. + +Disclaimer: Threading is not always a solution and you should first determine whether it is necessary and then look to implement the solution.",1.2,True,2,6594 +2020-03-05 07:24:31.123,"How can I replace an EXE's icon to the ""default"" icon?","I converted a python script to an exe using pyinstaller. I want to know how I can change the icon it gave me to the default icon. In case you don't know what I mean, look at C:\Windows\System32\alg.exe. There are many more files with that icon, but that is one of them. Sorry if this is the wrong place to ask this, and let me know if you have any questions","I would suggest to use auto-py-to-exe module for conversion of python script to exe. At first install using command pip install auto-py-to-exe after that run it through python command line just by typing auto-py-to-exe, you'll get an window where you'll get the icon option. +Please vote if you find your solution.",-0.1352210990936997,False,2,6595 +2020-03-05 07:24:31.123,"How can I replace an EXE's icon to the ""default"" icon?","I converted a python script to an exe using pyinstaller. I want to know how I can change the icon it gave me to the default icon. In case you don't know what I mean, look at C:\Windows\System32\alg.exe. There are many more files with that icon, but that is one of them. Sorry if this is the wrong place to ask this, and let me know if you have any questions","You'll need to extract the icon from the exe, and set that as the icon file with pyinstaller -i extracted.ico myscript.py. You can extract the icon with tools available online or you can use pywin32 to extract the icons.",0.0,False,2,6595 +2020-03-05 22:26:04.187,How to update python script/application remotely,"I'm trying to develop a windows gui app with python and i will distribute that later. I don't know how to set the app for some future releasing updates or bug fix from a server/remotely. How can I handle this problem? Can I add some auto-update future to app? What should write for that in my code and what framework or library should I use? +Do pyinstaller/ inno setup have some futures for this? +Thanks for your help.","How about this approach: + +You can use a version control service like github to version control your code. +Then checkout the repository on your windows machine. +Write a batch/bash script to checkout the latest version of your code and restart the app. +Then use the Windows task scheduler to periodically run this script.",1.2,True,1,6596 +2020-03-06 01:25:48.877,"While using Word2vec, how can I get a result from unseen words corpus?","I am using Word2vec model to extract similar words, but I want to know if it is possible to get words while using unseen words for input. +For example, I have a model trained with a corpus [melon, vehicle, giraffe, apple, frog, banana]. ""orange"" is unseen word in this corpus, but when I put it as input, I want [melon, apple, banana] for result. +Is this a possible situation?","The original word2vec algorithm can offer nothing for words that weren't in its training data. +Facebook's 'FastText' descendent of the word2vec algorithm can offer better-than-random vectors for unseen words – but it builds such vectors from word fragments (character n-gram vectors), so it does best where shared word roots exist, or where the out-of-vocabulary word is just a typo of a trained word. +That is, it won't help in your example, if no other words morphologically similar to 'orange' (like 'orangey', 'orangade', 'orangish', etc) were present. +The only way to learn or guess a vector for 'orange' is to have some training examples with it or related words. (If all else failed, you could scrape some examples from other large corpora or the web to mix with your other training data.)",0.6730655149877884,False,1,6597 +2020-03-06 05:12:48.407,import xmltodict module into visual studio code,"I am having a little tough time importing the xmltodict module into my visual studio code. +I setup the module in my windows using pip. it should be working on my visual studio as per the guidelines and relevant posts I found here. +but for some reasons it isn't working in the visual studio. +Please advise on how can I get the xmltodict module installed or imported on visual studio code +Thanks in Advance","I had the same issue and it turned out that it wasn't installed in that virtual environment even though that was what I had done. Try: +venv/Scripts/python.exe -m pip install xmltodict",0.0,False,1,6598 +2020-03-06 10:30:35.220,How to open a python file in Cmder Terminal Quicker?,"I want to open a python file in cmder terminal quickly. Currently, the fastest way i know how is to navigate to the directory of the python file in cmder terminal and then run it by calling ""python file.py"". This is slow and cumbersome. Is there a way for me to have a file or exe, that, when i run it (or drag the program onto it), automatically makes the program run in cmder straight away. +Windows 10 +Clarification: I'm using cmder terminal specifically because it supports text coloring. Windows terminal and powershell do not support this.",Answer: The escape codes just weren't properly configured for the windows terminals. You can get around this by using colorama's colorama.init(). It should work after that.,1.2,True,2,6599 +2020-03-06 10:30:35.220,How to open a python file in Cmder Terminal Quicker?,"I want to open a python file in cmder terminal quickly. Currently, the fastest way i know how is to navigate to the directory of the python file in cmder terminal and then run it by calling ""python file.py"". This is slow and cumbersome. Is there a way for me to have a file or exe, that, when i run it (or drag the program onto it), automatically makes the program run in cmder straight away. +Windows 10 +Clarification: I'm using cmder terminal specifically because it supports text coloring. Windows terminal and powershell do not support this.","On windows you can go to the directory with the file in the explorer and then simply hold shift as you right click at the same time. This will open the menu and there you will have the option to use the command shell/powershell and then you don't have to navigate to the directory inside the shell anymore and can just execute the python file. +I hope that helps.",0.0,False,2,6599 +2020-03-06 15:03:36.553,discord py: canceling a loop using a command,"My question is this: If I were to make a command with a loop (for example ""start"") where it would say something like:""It has been 3 hours since..."" and it loops for 10800 seconds (3 hours) and then says:""It has been 6 hours since..."" , so the part where I'm stuck is: If I were to make a command called ""stop"" how would I implement it in the command ""start"" where it would check if the command ""stop"" has been used. If yes the loop is cancelled, if it hasn't been used the loop continues.","but if you run the command several times or on different servers, one stop command stops them all. Is there not a way to stop just one loop with one command",0.0,False,1,6600 +2020-03-07 19:56:55.313,How to design a HTML parser that would follow the Single Responsibility Principle?,"I am writing an application which extracts some data from HTML using BeautifoulSoup4. These are search results of some kind, to be more specific. I thought it would be a good a idea to have a Parser class, storing default values like URL prefixes, request headers etc. After configuring those parameters, the public method would return a list of objects, each of them containing a single result or maybe even an object with a list composed into it alongside with some other parameters. I'm struggling to decouple small pieces of logic that build that parser implementation from the parser class itself. I want to write dozens of parser private utility methods like: _is_next_page_available, _are_there_any_results, _is_did_you_mean_available etc. However, these are the perfect candidates for writing unit tests! And since I want to make them private, I have a feeling that I'm missing something... +My other idea was to write that parser as a function, calling bunch of other utility functions, but that would be just equal to making all of those methods public, which doesn't make sense, since they're implementation details. +Could you please advice me how to design this properly?","I think you're interpreting the Single-Responsibility Principle (SRP) a little differently. It's actual meaning is a little off from 'a class should do only one thing'. It actually states that a class should have one and only one reason to change. +To employ the SRP you have to ask yourself to what/who would your parser module methods be responsible, what/who might make them change. If the answer for each method is the same, then your Parser class employs the SRP correctly. If there are methods that are responsible to different things (business-rule givers, groups of users etc.) then those methods should be taken out and be placed elsewhere. +Your overall objective with the SRP is to protect your class from changes coming from different directions.",0.6730655149877884,False,1,6601 +2020-03-08 18:20:41.720,How can I use the Twitter API to look up accounts from email addresses?,"I'm helping out a newly formed startup build a social media following, and I have a csv file of thousands of email addresses of people I need to follow. From looking at the twitter API, I see its possible to follow the accounts if I knew their usernames, but its unclear how to look them up by email. Any ideas?","This does not appear to be an option with their API, you can use either user_id or screen name with their GET users/show or GET users/lookup options.",0.2012947653214861,False,2,6602 +2020-03-08 18:20:41.720,How can I use the Twitter API to look up accounts from email addresses?,"I'm helping out a newly formed startup build a social media following, and I have a csv file of thousands of email addresses of people I need to follow. From looking at the twitter API, I see its possible to follow the accounts if I knew their usernames, but its unclear how to look them up by email. Any ideas?",There is no way to do a lookup based on email address in the Twitter API.,0.0,False,2,6602 +2020-03-09 06:36:25.567,Overfitting problem in convolutional neural Network and deciding the parameters of convolution and dence layer,I applied batch normalization technique to increase the accuracy of my cnn model.The accuracy of model without batch Normalization was only 46 % but after applying batch normalization it crossed 83% but a here arisen a bif overfitting problem that the model was giving validation Accuracy only 15%. Also please tell me how to decide no of filters strides in convolution layer and no of units in dence layer,"Batch normalization has been shown to help in many cases but is not always optimal. I found that it depends where it resides in your model architecture and what you are trying to achieve. I have done a lot with different GAN CNNs and found that often BN is not needed and can even degrade performance. It's purpose is to help the model generalize faster but sometimes it increases training times. If I am trying to replicate images, I skip BN entirely. I don't understand what you mean with regards to the accuracy. Do you mean it achieved 83% accuracy with the training data but dropped to 15% accuracy on the validation data? What was the validation accuracy without the BN? In general, the validation accuracy is the more important metric. If you have a high training accuracy and a low validation accuracy, you are indeed overfitting. If you have several convolution layers, you may want to apply BN after each. If you still over-fit, try increasing your strides and kernel size. If that doesn't work you might need to look at the data again and make sure you have enough and that it is somewhat diverse. Assuming you are working with image data, are you creating samples where you rotate your images, crop them, etc. Consider synthetic data to augment your real data to help combat overfiiting.",0.0,False,1,6603 +2020-03-09 09:01:08.040,How to create Dashboard using Python or R,"In my company, I have got task to create dash board using python whose complete look and feel should be like qlicksense. I am fresher in data science field I don't know how to do this. I did lots of R & D and plotly and dash is the best option as much according to R & D on internet dash table is also a good option but I am not able to create the things what it should look like. If any one know how to start plz help me ..","you can use django or other web framework to develop the solution, +keep in mind that you probably will need to handle lots of front end stuff like builiding the UI of the system, +Flask also is very lightweight option, but it needs lots of customization. +Django comes with pretty much everything you might need out of the box.",0.0,False,1,6604 +2020-03-09 17:18:29.683,is there any function or module in nlp that would find a specific paragraph headings,"I have a text file . I need to identify specific paragraph headings and if true i need to extract relevant tables and paragraph wrt that heading using python. can we do this by nlp or machine learning?. if so please help me out in gathering basics as i am new to this field.I was thinking of using a rule like: +if (capitalized) and heading_length <50: + return heading_text +how do i parse through the entire document and pick only the header names ? this is like automating human intervention of clicking document,scrolling to relevant subject and picking it up. +please help me out in this","I agree with lorg. Although you could use NLP, but that might just complicate the problem. This problem could be an optimization problem if performance is a concern.",0.0,False,2,6605 +2020-03-09 17:18:29.683,is there any function or module in nlp that would find a specific paragraph headings,"I have a text file . I need to identify specific paragraph headings and if true i need to extract relevant tables and paragraph wrt that heading using python. can we do this by nlp or machine learning?. if so please help me out in gathering basics as i am new to this field.I was thinking of using a rule like: +if (capitalized) and heading_length <50: + return heading_text +how do i parse through the entire document and pick only the header names ? this is like automating human intervention of clicking document,scrolling to relevant subject and picking it up. +please help me out in this","You probably don't need NLP or machine learning to detect these headings. Figure out the rule you actually want and if indeed it is such a simple rule as the one you wrote, a regexp will be sufficient. If your text is formatted (e.g. using HTML) it might be even simpler. +If however, you can't find a rule, and your text isn't really formatted consistently, your problem will be hard to solve.",0.2012947653214861,False,2,6605 +2020-03-10 07:31:06.813,How to find time take by whole test suite to complete in Pytest,"I want to know how much time has been taken by the whole test suite to complete the execution. How can I get it in Pytest framework. I can get the each test case execution result using pytest --durations=0 cmd. But, How to get whole suite execution time>","Use pytest-sugar +pip install pytest-sugar +Run your tests after it, +You could something like Results (10.00s) after finishing the tests",1.2,True,1,6606 +2020-03-10 16:13:15.393,"python + how to remove the message ""cryptography is not installed, use of crypto disabled""","First time programming in python and I guess you will notice it after reading my question: + + How can I remove the message ""cryptography is not installed, use of crypto disabled"" when running the application? +I have created a basic console application using the pyinstaller tool and the code is written in python. +When I run the executable, I am getting the message ""cryptography is not installed, use of crypto disabled"". The program still runs, but I would prefer to get rid off the message. +Can someone help me? +Thanks in advance.","cryptography and crypto are 2 different modules. +try: +pip install cryptography +pip install crypto",1.2,True,1,6607 +2020-03-11 11:00:09.743,Maya python (or MEL) select objects,"I need select all objects in Maya with name ""shd"" and after that I need assigned to them specific material. +I don't know how to do that because when I wrote: select -r ""shd""; it send me the message: More than one object matches name: shd // +So maybe I should select them one by one in some for loop or something. I am 3D artist so sorry for the lame question.","You can use select -r ""shd*"" to select all objects with a name stating with ""shd"".",0.0,False,1,6608 +2020-03-11 14:39:29.703,How to redirect to a different page in Django when I receive an input from a barcode scanner?,"The whole project is as follows: +I'm trying to build a Django based web-app for my college library. This app when idle will be showing a slideshow of pictures on the screen. However when an input is received from the barcode scanner, it is supposed to redirect it to a different age containing information related to that barcode. I'm not able to figure out how to get an input from the scanner and only then redirect it to the page for 3 seconds containing the relevant information, after the interval, it should redirect back to the page containing the slideshow.","you should communicate with the bar-code scanner to receive scanning-done event which has nothing to do with django but only javascript or even an interface software which the user must install, like a driver, so you can detect the bar-code scanner from javascript(web browser) then you can get your event in javascript and redirect the page on the event or do whatever you want",0.0,False,1,6609 +2020-03-11 23:42:50.313,Airflow Operator to pull data from external Rest API,"I am trying to pull data from an external API and dump it on S3 . I was thinking on writing and Airflow Operator rest-to-s3.py which would pull in data from external Rest API . +My concerns are : + +This would be a long running task , how do i keep track of failures ? +Is there a better alternative than writing an operator ? +Is it advisable to do a task that would probably run for a couple of hours and wait on it ? + +I am fairly new to Airflow so it would be helpful.","Errors - one of the benefits of using a tool like airflow is error tracking. Any failed task is subject to rerun (based on configuration) will persist its state in task history etc.. +Also, you can branch based on the task status to decide if you want to report error e.g. to email +An operator sounds like a valid option, another option is the built-in PythonOperator and writing a python function. +Long-running tasks are problematic with any design and tool. You better break it down to small tasks (and maybe parallelize their execution to reduce the run time?) Does the API take long time to respond? Or do you send many calls? maybe split based on the resulting s3 files? i.e. each file is a different DAG/branch?",0.9999092042625952,False,1,6610 +2020-03-13 05:38:38.123,How do I select a sub-folder as a directory containing tests in Python extension for Visual studio code,"I am using VScode with python code and I have a folder with sub-directories (2-levels deep) containing python tests. +When I try ""Python: Discover Tests"" it asks for a test framework (selected pytest) and the directory in which tests exist. At this option, it shows only the top-level directories and does not allow to select a sub-directory. +I tried to type the directory path but it does not accept it. +Can someone please help on how to achieve this?","Try opening the ""Output"" log (Ctrl+Shift+U) and run ""Python: Discover Tests"". Alternatively, you may type pytest --collect-only into the console. Maybe you are experiencing some errors with the tests themselves (such as importing errors). +Also, make sure to keep __init__.py file in your ""tests"" folder. +I am keeping the pytest ""tests"" folder within a subdirectory, and there are no issues with VS Code discovering the tests.",0.0,False,2,6611 +2020-03-13 05:38:38.123,How do I select a sub-folder as a directory containing tests in Python extension for Visual studio code,"I am using VScode with python code and I have a folder with sub-directories (2-levels deep) containing python tests. +When I try ""Python: Discover Tests"" it asks for a test framework (selected pytest) and the directory in which tests exist. At this option, it shows only the top-level directories and does not allow to select a sub-directory. +I tried to type the directory path but it does not accept it. +Can someone please help on how to achieve this?","There are two options. One is to leave the selection as-is and make sure your directories are packages by adding __init__.py files as appropriate. The other is you can go into your workspace settings and adjust the ""python.testing.pytestArgs"" setting as appropriate to point to your tests.",0.0,False,2,6611 +2020-03-13 10:02:01.843,how to fix CVE-2019-19646 Sqlite Vulnerability in python3,"I am facing issue with SQLite vulnerability which fixed in SQLite version 3.31.1. +I am using the python3.7.4-alpine3.10 image, but this image uses a previous version of SQLite that isn't patched. +The patch is available in python3.8.2-r1 with alpine edge branch but this image is not available in docker hub. +Please help how can i fix this issue?","Your choices are limited to two options: + +Wait for the official patched release +Patch it yourself + +Option 1 is easy, just wait and the patch will eventually propagate through to docker hub. Option 2 is also easy, just get the code for the image from github, update the versions, and run the build yourself to produce the image.",0.0,False,1,6612 +2020-03-13 18:51:28.017,How to see current cache size when using functools.lru_cache?,"I am doing performance/memory analysis on a certain method that is wrapped with the functools.lru_cache decorator. I want to see how to inspect the current size of my cache without doing some crazy inspect magic to get to the underlying cache. +Does anyone know how to see the current cache size of method decorated with functools.lru_cache?","Digging around in the docs showed the answer is calling .cache_info() on the method. + +To help measure the effectiveness of the cache and tune the maxsize parameter, the wrapped function is instrumented with a cache_info() function that returns a named tuple showing hits, misses, maxsize and currsize. In a multi-threaded environment, the hits and misses are approximate.",1.2,True,1,6613 +2020-03-14 04:25:07.913,Why use signals in Django?,"I have read lots of documentation and articles about using signals in Django, but I cannot understand the concept. + +What is the purpose of using signals in Django? +How does it work? + +Please explain the concept of signals and how to use it in Django code.","The Django Signals is a strategy to allow decoupled applications to get notified when certain events occur. Let’s say you want to invalidate a cached page everytime a given model instance is updated, but there are several places in your code base that this model can be updated. You can do that using signals, hooking some pieces of code to be executed everytime this specific model’s save method is trigged. +Another common use case is when you have extended the Custom Django User by using the Profile strategy through a one-to-one relationship. What we usually do is use a “signal dispatcher” to listen for the User’s post_save event to also update the Profile instance as well.",1.2,True,1,6614 +2020-03-14 15:27:13.413,Run generated .py files without python installation,"I am coding a PyQt5 based GUI application needs to be able to create and run arbitrary Python scripts at runtime. If I convert this application to a .exe, the main GUI Window will run properly. However, I do not know how I can run the short .py scripts that my application creates. Is it possible to runs these without a system wide Python installation? + +I don't want ways to compile my python application to exe. This problem relates to generated .py scripts","No, to run a Python file you need an interpreter. +It is possible that your main application can contain a Python interpreter so that you don't need to depend on a system-wide Python installation.",0.3869120172231254,False,1,6615 +2020-03-15 10:28:17.703,Can manim be used in pycharm?,"I have been programming with python for about half a year, and I would like to try manim ( the animation programme of 3blue1brown from youtube), but I am not sure where to start. I have not installed it, but I have tried to read up on it. And to be honest I do not understand much of the requirements of the program, and how to run it. +Google has left me without much help, so I decided to check here to see if anyone here is able to help. +From what I understand, you run manim directly in python and the animations are based on a textfile with code i assume is LaTex. I have almost no experience with python itself, but I have learned to use it through Thonny, and later Pycharm. +My main questions are: (Good sources to how to do this without being a wizard would be really helpful if they exist☺️) + +Is it possible to install manim in pycharm, and how? Do i need some extra stuff installed to pycharm in order to run it? (I run a windows 64-bit computer) +If i manage to do this in pycharm, Will I then be able to code the animations directly in pycharm (in .py or .txt files), or is it harder to use in pycharm? + +All help or insights is very appreciated As I said I am not extremely knowledgeable in computers, but I am enjoying learning how to code and applications of coding","Yes, you can +1.Write your code in pycharm +2.save it +3.copy that .py file to where you installed manim. In my case, it is + +This pc>> C drive >> manim-master >> manim-master + +4.select on the path and type ""cmd"" to open terminal from there + +Type this on the terminal + +python -m manim -pql projectname.py +This will do. +To play back the animation or image, open the media folder.",0.0,False,1,6616 +2020-03-15 13:08:38.213,"FFmpeg is in Path, but running in the CMD results in ""FFmpeg not recognized as internal or external command""","FFmpeg is installed in C:\FFmpeg, and I put C:\FFmpeg\bin in the path. Does anyone know how to fix? +Thanks!","You added C:\FFmpeg\bin\ffmpeg.exe to your path, instead, you need to add only the directory: +C:\FFmpeg\bin\",-0.3869120172231254,False,1,6617 +2020-03-15 16:27:58.057,How to put an icon for my android app using kivy-buildozer?,"I made an android app using python-kivy (Buildozer make it to apk file) +Now I want to put an image for the icon of the application. I mean the picture for the app-icon on your phone. +how can I do this? I cannot find any code in kv",Just uncomment icon.filename: in the buildozer spec file and write a path to your icon image.,0.3869120172231254,False,1,6618 +2020-03-15 19:50:38.793,How to activate google colab gpu using just plain python,"I'm new to google colab. +I'm trying to do deep learning there. +I have written a class to create and train a LSTM net using just python - not any specific deep learning library as tensorflow, pytorch, etc. +I thought I was using a gpu because I had chosen the runtime type properly in colab. +During the code execution, however, I was sometimes getting the message to quit gpu mode because I was not making use of it. +So, my question: how can one use google colab gpu, using just plain python, without special ai libraries? Is there something like ""decorator code"" to put in my original code so that the gpu get activated?","It's just easier to use frameworks like PyTorch or Tensorflow. +If not, you can try pycuda or numba, which are closer to ""pure"" GPU programming. That's even harder than just using PyTorch.",0.2012947653214861,False,1,6619 +2020-03-16 16:42:55.520,Overriding button functionality in kivy using an another button,Currently I am making a very simple interface which asks user to input parameters for a test and then run the test. The test is running brushless dc motor for several minutes. So when the run button is pressed the button is engaged for the time period till the function is finished executing. I have another stop button which should kill the test but currently cant use it since the run button is kept pressed till the function is finished executing and stop button cant be used during the test. I want to stop the test with pressing the stop button even if the run button function is currently being executed. The run button should release and the function should continuously check the stop function for stopping the test. Let me know how this can be executed.,"Your problem is that all your code it taking place sequentially in a single thread. Once your first button is pressed, all of the results of that pressing are followed through before anything else can happen. +You can avoid this by running the motor stuff in a separate thread. Your stop button will then need to interrupt that thread.",1.2,True,1,6620 +2020-03-17 13:45:02.310,how to compute the sum for each pair of rows x in matrice X and y in matrice Y?,"I am trying to write a function in python that takes as input two matrices X and Y and computes for every pair of rows x in X and y in Y, the norm ||x - y|| . I would like to do it without using for loops. +Do you have an idea about how to do it ?","I just solve it :D +instead of len(np.trnspose(y)) i had to do len(y) and it perfectly worked with a for loop.",0.0,False,1,6621 +2020-03-18 08:43:05.267,How to set text color to gradient texture in kivy?,"I have used to create a Texture with gradient color and set to the background of Label, Button and etc. But I am wondering how to set this to color of Label?","You can't set the color property to a gradient, that just isn't what it does. Gradients should be achieved using images or textures directly applied to canvas vertex instructions.",0.0,False,1,6622 +2020-03-18 13:18:18.393,'odict_items' object is not subscriptable how to deal with this?,"I've tried to run this code on Jupyter notebook python 3: +class CSRNet(nn.Module): + def __init__(self, load_weights=False): + super(CSRNet, self).__init__() + self.frontend_feat = [64, 64, 'M', 128, 128, 'M', 256, 256, 256, 'M', 512, 512, 512] + self.backend_feat = [512, 512, 512,256,128,64] + self.frontend = make_layers(self.frontend_feat) + self.backend = make_layers(self.backend_feat,in_channels = 512,dilation = True) + self.output_layer = nn.Conv2d(64, 1, kernel_size=1) + if not load_weights: + mod = models.vgg16(pretrained = True) + self._initialize_weights() + for i in range(len(self.frontend.state_dict().items())): + self.frontend.state_dict().items()[i][1].data[:] = mod.state_dict().items()[i][1].data[:] +it displays 'odict_items' object is not subscriptable as an error in the last line of code!!how to deal with this?","In python3, items() returns a dict_keys object, you should try to convert it to a list: + +list(self.frontend.state_dict().items())[i][1].data[:] = +list(mod.state_dict().items())[i][1].data[:]",0.3869120172231254,False,1,6623 +2020-03-18 14:26:59.470,Is there any way that I can insert a python file into a html page?,"I am currently trying to create a website that displays a python file (that is in the same folder as the html file) on the website, but I'm not sure how to do so. +So I just wanted to ask if anyone could describe the process of doing so (or if its even possible at all).","Displaying ""a python file"" and displaying ""the output"" (implied ""of a python script's execution) are totally different things. For the second one, you need to configure your server to run Python code. There are many ways to do so, but the two main options are +1/ plain old cgi (slow, outdated and ugly as f..k but rather easy to setup - if your hosting provides support for it at least - and possibly ok for one single script in an otherwise static site) +and +2/ a modern web framework (flask comes to mind) - much cleaner, but possibly a bit overkill for one simple script. +In both cases you'll have to learn about the HTTP protocol.",0.0,False,1,6624 +2020-03-19 00:25:35.587,How to append data to specific column Pandas?,"I have 2 dataframes: +FinalFrame: +Time | Monday | Tuesday | Wednesday | ... +and df (Where weekday is the current day, whether it be monday tuesday etc): +WEEKDAY +I want to append the weekday's data to the correct column. I will need to constantly keep appending weekdays data as weeks go by. Any ideas on how to tackle this?","You can add index of week days instead of their name. For example, +weekdays = ['Mon', Tue', 'Wed', 'Thu', 'Fri','Sat', 'Sun'] +Time | 0 | 1 | 2 ....",0.0,False,2,6625 +2020-03-19 00:25:35.587,How to append data to specific column Pandas?,"I have 2 dataframes: +FinalFrame: +Time | Monday | Tuesday | Wednesday | ... +and df (Where weekday is the current day, whether it be monday tuesday etc): +WEEKDAY +I want to append the weekday's data to the correct column. I will need to constantly keep appending weekdays data as weeks go by. Any ideas on how to tackle this?",So the way you could do it isolates the series by saying weekday[whatever day you are looking at .append.,0.0,False,2,6625 +2020-03-20 17:35:30.097,Displaying data from my python script on a webpage,"My case: +I want to display the meal plan from my University on my own online ""Dashboard"". I've written my python script to scrape that data and I get the data I need (plain Text). Now I need to put it on my website but I don't know how to start. On my first searching sessions, I have found something with CGI but I have no clue how to use it:( Is there maybe an even easier way to solve my problem? +Thanks","I suggest you to use the Django, if you don't want to use django, you can edit your output in HTML formate and publish html page, directly.",0.0,False,1,6626 +2020-03-21 17:11:32.527,How to read the documentation of a certain module?,"I've just finished my course of Python, so now I can write my own script. So to do that I started to write a script with the module Scapy, but the problem is, the documentation of Scapy is used for the interpreter Scapy, so I don't know how to use it, find the functions, etc. +I've found a few tutorials in Internet with a few examples but it's pretty hard. For example, I've found in a script the function ""set_payload"" to inject some code in the layer but I really don't know where he found this function. +What's your suggestion for finding how a module works and how to write correctly with it? Because I don't really like to check and pick through other scripts on Internet.","If I have understood the question correctly, roughly what you are asking is how to find the best source to understand a module. +If you are using an inbuilt python module, the best source is the python documentation. +Scapy is not a built-in python module. So you may have some issues with some of the external modules (by external I mean the ones you need to explicitly install). +For those, if the docs aren't enough, I prefer to look at some of the github projects that may use that module one way or the other and most of the times it works out. If it doesn't, then I go to some blogs or some third party tutorials. There is no right way to do it, You will have to put in the effort where its needed.",1.2,True,1,6627 +2020-03-21 17:12:42.693,Efficient Way to Run Multiple Instances of the Same Discord Bot (Discord),"I have a Discord bot I use on a server with friends. +The problem is some commands use web scraping to retrieve the bot response, so until the bot is finished retrieving the answer, the bot is out of commission/can't handle new commands. +I want to run multiple instances of the same bot on my host server to handle this, but don't know how to tell my code ""if bot 1 is busy with a command, use bot 2 to answer the command"" +Any help would be appreciated!","async function myFunction () {} +this should fix your problem +having multiple instances could be possible with threads, +but this is just a much more easy way",-0.2012947653214861,False,1,6628 +2020-03-21 18:13:00.810,Efficient unions and intersections in 2D plane when y_min = 0,"If got the following problem: +Given a series of rectangles defined by {x_min, height and x_max}, I want to efficiently compute their intersection and union, creating a new series. +For instance, if I got S1 = [{1,3,3}] and S2 = [{2,3,5}], the union would result in S3 = [{1,3,5}] and intersection in S3 = [{2,3,3}]. This would be a fairly simple case, but when S1 and S2 are a list of rectangles (unordered) It get's a little bit tricky. +My idea is trying some divide and conquer strategy, like using a modificated mergesort, and in the merge phase try to also merge those buildings. But I'm a little bit unsure about how to express this. +Basically I can't write down how to compare two rectangles with those coordinates and decide if they have to be in S3, or if I have to create a new one (for the intersection). +For the union I think the idea has to be fairly similar, but the negation (i.e. if they don't interesct). +This has to be O(nlogn) for sure, given this is in a 2D plane I surely have to sort it. Currently my first approach is O(n^2). +Any help how to reduce the complexity? +PD: The implementation I'm doing is in Python","I tried to write the whole thing out in psudo-code, and found that it was too psudo-y to be useful and too code-y to be readable. Here's the basic idea: +You can sort each of your input lists in O(n*log(n)). +Because we assume there's no overlap within each series, we can now replace each of those lists with lists of the form {start, height}. We can drop the ""end"" attribute by having a height-0 element start where the last element should have ended. (or not, if two elements were already abutting.) +Now you can walk/recurse/pop your way through both lists in a single pass, building a new list of {start, height} outputs as you go. I see no reason you couldn't be building both your union and intersection lists at the same time. +Cleanup (conversion to a minimal representation in the original format) will be another pass, but still O(n). +So the problem is O(n*log(n)), and could be O(n) if you could finagle a way to get your input pre-sorted.",0.0,False,1,6629 +2020-03-22 20:43:39.077,Python Methods (where to find additional resources),"I am learning Python by reading books, and I have a question about methods. Basically, all of the books that I am reading touch on methods and act like they just come out of thin air. For example, where can I find a list of all methods that can be applied? I can't find any documentation that lists all methods. +The books are using things like .uppercase and .lowercase but is not saying where to find other methods to use, or how to see which ones are available and where. I would just like to know what I am missing. Thanks. Do I need to dig into Python documentation to find all of the methods?","There is a lot of function in Python's modules. If you want to learn were you can find them, you should ask what you want. For example there is a random module and you can find some functions like random.randint.",0.0,False,1,6630 +2020-03-23 18:58:48.680,How to reach and add new row to web server database which made in Django framework?,"I am trying to create a web server which has Django framework and I am struggling with outer world access to server. While saying outer world I am trying to say a python program that created out of Django framework and only connects it from local PC which has only Internet connection. I can't figured it out how can I do this. +I am building this project in my local host, so I create the ""outer world python program"" outside of the project file. I think this simulation is proper. +I am so new in this web server/Django field. So maybe I am missing an essential part. If this happened here I'm sorry but I need an answer and I think it is possible to do. +Thanks in advance...","Django generated fields in database are just standard fields. The tables are named like 'applicationname'_'modelname', you are free to do requests to the database directly, without django. +If you want to do it through django, your outer program can request a web page from your web server, and deal with it. (You may want to take a look at RESTs frameworks)",1.2,True,1,6631 +2020-03-23 22:03:37.527,Failed to load dynlib/dll (Pyintaller),"After using the pyintaller to transfer the py file to exe file, the exe file throws the error: ""Failed to load dynlib/dll"". Here is the error line: + +main.PyInstallerImportError: Failed to load dynlib/dll 'C:\Users\YANGYI~1\AppData\Local\Temp\_MEI215362\sklearn\.libs\vcomp140.dll'. + Most probably this dynlib/dll was not found when the application was + frozen. [1772] Failed to execute script 2 + +after get this, I did check the path and I did not find a folder called ""_MEI215362"" in my Temp folder, I have already made all files visible. Also, I have re-download the VC but and retransferring the file to exe, but it didn't work. Any ideas how to fix the issue? Thank you in advance!","I also encountered a similar problem like Martin. +In my case, however, it was the ANSI64.dll missing... +So, I simply put the particular dll file into the dist directory. +Lastly, I keep the exe and related raw data files (e.g. xlsx, csv) inside the ""dist"" folder and to run the compiled program. It works well for me.",0.0,False,1,6632 +2020-03-23 23:50:42.940,How to delete drawn objects with OpenCV in Python?,"How to delete drawn objects with OpenCV in Python ? + +I draw objects on click (cv2.rectangle, cv2.circle) ... +Then I would like to delete only drawn objects. +I know that i need to make a layer in behind of the real image and to draw on another one. +But I do not know how to implement this in code.","Have a method or something that when it's executed, will replace the image with stuff drawn on it with an original unaltered image. It's best to create a clone of your original image to draw on.",0.0,False,1,6633 +2020-03-24 23:04:42.153,"Explain the necessity of database drivers, libraries, dlls in a python application that interacts with a remote database?","I have written a python script that connects to a remote Oracle database and inserts some data into its tables. +In the process I had to first import cx_Oracle package and install Oracle InstantClient on my local computer for the script to execute properly. +What I don't understand is why did I have to install InstantClient? +I tried to read through the docs but I believe I am missing some fundamental understanding of how databases work and communicate. +Why do I need all the external drivers, dlls, libraries for a python script to be able to communicate with a remote db? I believe this makes packaging and distribution of a python executable much harder. +Also what is InstantClient anyway? +Is it a driver? What is a driver? Is it simply a collection of ""programs"" that know how to communicate with Oracle databases? If so, why couldn't that be accomplished with a simple import of a python package? +This may sound like I did not do my own research beforehand, but I'm sorry, I tried, and like I said, I believe I am missing some underlying fundamental knowledge.","We have a collection of drivers that allow you to communicate with an Oracle Database. Most of these are 'wrappers' of a sort that piggyback on the Oracle Client. Compiled C binaries that use something we call 'Oracle Net' (not to be confused with .NET) to work with Oracle. +So our python, php, perl, odbc, etc drivers are small programs written such that they can be used to take advantage of the Oracle Client on your system. +The Oracle Client is much more than a driver. It can include user interfaces such as SQL*Plus, SQL*Loader, etc. Or it can be JUST a set of drivers - it depends on which exact package you choose to download and install. And speaking of 'install' - if you grab the Instant Client, there's nothing to install. You just unzip it and update your environment path bits appropriately so the drivers can be loaded.",1.2,True,1,6634 +2020-03-25 10:26:21.650,Module not appearing in jupyter,"I'm having issues with importing my modules into jupyter. I did the following: + +Create virtual env +Activate it (everything below is in the context of my venv) +install yahoo finance module: pip install yfinance +open python console and import it to test if working > OK! +open jupyter notebook +import yfinance throws ModuleNotFoundError: No module named 'yfinance' + +Any suggestions on how to fix this?","try this one in your jupyter and the run it +!pip install yfinance",0.0,False,1,6635 +2020-03-26 04:29:58.543,How do I create a template to store my HTML file when creating a web app with Python's Flask Framework in the PyCharm IDE?,I am trying to do a tutorial through FreeCodeCamp using Python's Flask Framework to create a web app in PyCharm and I am stuck on a section where it says 'Flask looks for HTML files in a folder called template. You need to create a template folder and put all your HTML files in there.' I am confused on how to make this template folder; is it just a regular folder or are there steps to create it and drag/drop the HTML files to it? Any tips or info would be of great help!!!,"As the tutorial ask you, you have to create a folder call ""templates"" (not ""template""). In PyCharm you can do this by right-clicking on the left panel and select New I Directory. In this folder you can then create your template files (right click on the newly created folder and select New I File, then enter the name of your file with the .html extension). +By default, flask looks in the ""templates"" folder to find your template when you call render_template(""index.html""). Notice that you don’t put the full path of your file at the first parameter but just the relative path to the ""templates"" folder.",1.2,True,1,6636 +2020-03-26 08:51:13.303,How to implement dct when the input image size is not a scale of 8?,"I learned that if one needs to implement dct on a image of size (H, W), one needs a matrix A that is of size (8, 8), and one needs to use this A to compute with a (8, 8) region F on the image. That means if the image array is m, one needs to compute m[:8, :8] first, and then m[8:16, 8:16], and so on. +How could I implement this dct when input image size is not a scale of 8. For example, when image size is (12, 12) that cannot hold two (8, 8) windows, how could I implement dct ? I tried opencv and found that opencv can cope with this scenario, but I do not know how it implemented it.","The 8x8 is called a ""Minimum Coded Unit"" (MCU) in the specification, though video enthusiasts call them ""macroblocks"". +Poorer implementations will pad to fill with zeroes - which can cause nasty effects. +Better implementations pad to fill by repeating the previous pixel from the left if padding to the right, or from above if padding downwards. +Note that only the right side and bottom of an image can be padded.",1.2,True,1,6637 +2020-03-26 10:29:19.013,Re-assign backslash to three dots in Python,"Is it possible in Python to re-assign the backslash character to something else, like to the three dots? +I hate the backslash character. It looks ugly. +There’s a long line in my code I really need to use the \ character. But I’d rather use the ... character. +I just need a simple yes/no answer. Is it possible? And in the case of yes, tell me how to re-assign that ugly thing.","Python syntactically uses the backslash to represent the escape character, as do other languages such as Java and C. As far as I am aware this cannot be overwritten unless you want to change the language itself.",0.0,False,1,6638 +2020-03-26 16:45:21.790,How do I receive a variable from python flask to JavaScript?,"I've seen how to make a post request from JavaScript to get data from the server, but how would I do this flipped. I want to trigger a function in the flask server that will then dynamically update the variable on the JavaScript side to display. Is there a way of doing this in a efficient manner that does not involve a periodic iteration. I'm using an api and I only want to the api to be called once to update.","There are three basic options for you: + +Polling - With this method, you would periodically send a request to the server (maybe every 5 seconds for example) and ask for an update. The upside is that it is easy to implement. The downside is that many requests will be unnecessary. It sounds like this isn't a great option for you. +Long Polling - This method means you would open a request up with the server and leave the request open for a long period of time. When the server gets new information it will send a response and close the request - after which the client will immediately open up a new ""long poll"" request. This eliminates some of the unnecessary requests with regular polling, but it is a bit of a hack as HTTP was meant for a reasonably short request response cycle. Some PaaS providers only allow a 30 second window for this to occur for example. +Web Sockets - This is somewhat harder to setup, but ultimately is the best solution for real time server to client (and vice versa) communication. A socket connection is opened between the server and client and data is passed back and forth whenever either party would like to do so. Javascript has full web socket support now and Flask has some extensions that can help you get this working. There are even great third party managed solutions like Pusher.com that can give you a working concept very quickly.",1.2,True,1,6639 +2020-03-26 20:40:16.497,Display result (image) of computation in website,"I have a python script that generates a heightmap depending on parameters, that will be given in HTML forms. How do I display the resulting image on a website? I suppose that the form submit button will hit an endpoint with the given parameters and the script that computes the heightmap runs then, but how do I get the resulting image and display it in the website? Also, the computation takes a few seconds, so I suppose I need some type of task queue to not make the server hang in the meanwhile. Tell me if I'm wrong. +It's a bit of a general question because I myself don't know the specifics of what I need to use to accomplish this. I'm using Flask in the backend but it's a framework-agnostic question.","Save the image to a file. Return a webpage that contains an element. The SRC should be a URL pointing at the file. +For example, suppose you save the image to a file called ""temp2.png"" in a subdirectory called ""scratch"" under your document root. Then the IMG element would be . +If you create and save the image in the same program that generates the webpage that refers to it, your server won't return the page until the image has been saved. If that only takes a few seconds, the server is unlikely to hang. Many applications would take that long to calculate a result, so the people who coded the server would make sure it can handle such delays. I've done this under Apache, Tomcat, and GoServe (an OS/2 server), and never had a problem. +This method does have the disadvantage that you'll need to arrange for each temporary file to be deleted after an expiry period such as 12 hours or whenever you think the user won't need it any more. On the webpage you return, if the image is something serious that the user might want to keep, you could warn them that this will happen. They can always download it. +To delete the old files, write a script that checks when they were last updated, compares that with the current date and time, and deletes those files that are older than your expiry period. +You'll need a way to automatically run it repeatedly. On Unix systems, if you have shell access, the ""cron"" command is one way to do this. Googling ""cron job to delete files older than 1 hour on web server"" finds a lot of discussion of methods. +Be very careful when coding any automatic-deletion script, and test it thoroughly to make sure it deletes the right files! If you make your expiry period a variable, you can set it to e.g. 1 minute or 5 minutes when testing, so that you don't need to wait for ages. +There are ways to stream your image back without saving it to a file, but what I'm recommending is (apart possibly from the file deleter) easy to code and debug. I've used it in many different projects.",1.2,True,1,6640 +2020-03-26 22:11:19.490,How to create a dynamic website using python connected to a database,"I would like to create a website where I show some text but mainly dynamic data in tables and plots. Let us assume that the user can choose whether he wants to see the DAX or the DOW JONES prices for a specific timeframe. I guess these data I have to store in a database. As I am not experienced with creating websites, I have no idea what the most reasonable setup for this website would be. + +Would it be reasonable for this example to choose a database where every row corresponds of 9 fields, where the first column is the timestamp (lets say data for every minute), the next four columns correspond to the high, low, open, close price of DAX for this timestamp and columns 5 to 9 correspond to high, low, open, close price for DOW JONES? +Could this be scaled to hundreds of columns with a reasonable speed +of the database? +Is this an efficient implementation? +When this website is online, you can choose whether you want to see DAX or DOW JONES prices for a specific timeframe. The corresponding data would be chosen via python from the database and plotted in the graph. Is this the general idea how this will be implemented? +To get the data, I can run another python script on the webserver to dynamically collect the desired data and write them in the database? + +As a total beginner with webhosting (is this even the right term?) it is very hard for me to ask precise questions. I would be happy if I could find out whats the general structure I need to create the website, the database and the connection between both. I was thinking about amazon web services.","You could use a database, but that doesn't seem necessary for what you described. +It would be reasonable to build the database as you described. Look into SQL for doing so. You can download a package XAMPP that will give you pretty much everything you need for that. This is easily scalable to hundreds of thousands of entries - that's what databases are for. +If your example of stock prices is actually what you are trying to show, however, this is completely unnecessary as there are already plenty of databases that have this data and will allow you to query them. What you would really want in this scenario is an API. Alpha Vantage is a free service that will serve you data on stock prices, and has plenty of documentation to help you get it set up with python. +I would structure the project like this: +Use the python library Flask to set up the back end. +In addition to instantiating the Flask app, instantiate the Alpha Vantage class as well (you will need to pip install both of these). +In one of the routes you declare under Flask, use the Alpha Vantage api to get the data you need and simply display it to the screen. +If I am assuming you are a complete beginner, one or more of those steps may not make sense to you, in which case take them one at a time. Start by learning how to build a basic Flask app, then look at the API. +YouTube is your friend for both of these things.",0.0,False,1,6641 +2020-03-27 01:17:46.150,"Python3: Does the built-in function ""map"" have a bug?","The following I had with Python 3.8.1 (on macOS Mojave, 10.14.6, as +well as Python 3.7 (or some older) on some other platforms). I'm new +to computing and don't know how to request an improvement of a +language, but I think I've found a strange behaviour of the built-in +function map. +As the code next(iter(())) raises StopIteration, I expected to +get StopIteration from the following code: +tuple(map(next, [iter(())])) +To my surprise, this silently returned the tuple ()! +So it appears the unpacking of the map object stopped when +StopIteration came from next hitting the ""empty"" iterator +returned by iter(()). However, I don't think the exception was +handled right, as StopIteration was not raised before the ""empty"" +iterator was picked from the list (to be hit by next). + +Did I understand the behaviour correctly? +Is this behaviour somehow intended? +Will this be changed in a near future? Or how can I get it? + +Edit: The behaviour is similar if I unpack the map object in different ways, such as by list, for for-loop, unpacking within a list, unpacking for function arguments, by set, dict. So I believe it's not tuple but map that's wrong. +Edit: Actually, in Python 2 (2.7.10), the ""same"" code raises +StopIteration. I think this is the desirable result (except that map in this case does not return an iterator).","Did I understand the behavior correctly? + + +Not quite. map takes its first argument, a function, and applies it to every item in some iterable, its second argument, until it catches the StopIteration exception. This is an internal exception raised to tell the function that it has reached the end of the object. If you're manually raising StopIteration, it sees that and stops before it has the chance to process any of the (nonexistent) objects inside the list.",0.1352210990936997,False,1,6642 +2020-03-27 03:41:18.327,SocketIO + Flask Detect Disconnect,"I had a different question here, but realized it simplifies to this: +How do you detect when a client disconnects (closes their page or clicks a link) from a page (in other words, the socket connection closes)? I want to make a chat app with an updating user list, and I’m using Flask on Python. When the user connects, the browser sends a socket.emit() with an event and username passed in order to tell the server a new user exists, after which the server will message all clients with socket.emit(), so that all clients will append this new user to their user list. However, I want the clients to also send a message containing their username to the server on Disconnect. I couldn’t figure out how to get the triggers right. Note: I’m just using a simple html file with script tags for the page, I’m not sure how to add a JS file to go along with the page, though I can figure it out if it’s necessary for this.","Figured it out. socket.on('disconnect') did turn out to be right, however by default it pings each user only once a minute or so, meaning it took a long time to see the event.",1.2,True,1,6643 +2020-03-27 05:09:55.327,Is it possible to create labels.txt manually?,"I recently convert my model to tensorflow lite but I only got the .tflite file and not a labels.txt for my Android project. So is it possible to create my own labels.txt using the classes that I used to classify? If not, then how to generate labels.txt?","You should be able to generate and use your own labels.txt. The file needs to include the label names in the order you provided them in training, with one name per line.",1.2,True,1,6644 +2020-03-27 17:12:09.890,Python 3.7 pip install - The system cannot find the path specified,"I am using Python 3.7 (Activestate) on a windows 10 laptop. All works well until I try to use pip to install a package (any package). From command prompt, when entering ""pip install anyPackage"" I get an error - ""The system cannot find the path specified."" no other explanation or detail. +Python is installed in ""C:\Python37"" and this location is listed in the Control Panel > System > Environment Variables > User Variables. +In the Environment Variables > System Variables I have: +C:\Python37\ +C:\Python37\DLLs\ +C:\Python37\Script\ +C:\Python37\Tools\ +C:\Python37\Tools\ninja\ +Any suggestions on how to get rid of that error, and make pip work? +Many thanks to all","Short : make sure that pip.exe and python.exe are running from the same location. If they don't (perhaps due to PATH environment variable), just delete the one that you don't need. +Longer: +when running pip install, check out where it tries to get python +For instance, in my own computer, it was: + +pip install +Fatal error in launcher: Unable to create process using '""c:\program files\python39\python.exe"" ""C:\Program Files\Python39\Scripts\pip.exe"" ': The system cannot find the file specified. + +Then I ran: +'where python.exe' // got several paths. +'where pip.exe' // got different paths. +removed the one that I don't use. Voila.",0.9950547536867304,False,1,6645 +2020-03-28 04:17:15.583,Change which python im using in terminal MacOs Catalina,"First of all, im really new at Machine Learning and Anaconda +Recently I´ve Installed Anaconda for MachineLearning but now when i try to run my old scripts from my terminal, all my packages are not there, even pip or numpy or pygame y don´t know how to change to my old python directory, I really don´t know how this works, please help me. I´m on MacOs Catalina","First of all, Python 3 is integrated in macOS X Catalina, just type python3. For pip, you can use pip3. Personally, I would prefer native over conda when using mac. +Next, you need to get all the modules up from your previous machine by pip freeze > requirements.txt or pip3 freeze > requirements.txt +If you have the list already, either it's from your previous machine or from a GitHub project repo, just install it via pip3 in your terminal: pip3 install -r requirements.txt +If not, you have to manually install via pip3, for example: pip3 install pygame etc. +After all dependencies are done installed, just run your .py file as usual. +Last, but not least, welcome to the macOS X family!",0.5457054096481145,False,1,6646 +2020-03-28 05:07:30.247,How to locate module inside PyCharm?,"I am a beginner in python 3. I want to locate where the time module is in PyCharm to study it's aspects/functions further. I can't seem to find it in the library. Can someone show me an example on how to find it ? +I know there are commands to find files, but I am not advanced enough to use them.","I think you may have a misconception - the time module is part of your Python installation, which PyCharm makes use of when you run files. Depending on your setup, you may be able to view the Python files under ""external libraries"" in your project viewer, but you could also view them from your file system, wherever Python is installed.",0.0,False,1,6647 +2020-03-28 05:40:42.997,How to emit different messages to different users based on certain criteria,"I am building a chat application using flask socketio and I want to send to a specific singular client and I'm wondering how to go about this. +I get that emit has broadcast and include_self arguments to send to all and avoid sending oneself, but how exactly would I go about maybe emitting to a single sid? +I've built this application using standard TCP/UDP socket connection where upon client connecting, there socket info was stored in a dictionary mapped to their user object with attributes that determined what would be sent and when I wanted to emit something to the clients I would iterate through this and be able to control what was being sent. +I'm hoping some mastermind could help me figure out how to do this in flask socket io","I ended up figuring it out. Using the flask request module, you can obtain the users sid using request.sid, which can be stored and emitted to within the room parameter emit(..... room=usersid",0.2012947653214861,False,1,6648 +2020-03-28 11:38:23.503,How to populate module internal progress status to another module?,"let us say I have a python 3.7+ module/script A which does extensive computations. Furthermore, module A is being used inside another module B, where module A is fully encapsulated and module B doesn't know a lot of module's A internal implementation, just that it somehow outputs the progress of its computation. +Consider me as the responsible person (person A) for module A, and anyone else (person B) that doesn't know me, is writing module B. So person A is writing basically an open library. +What would be the best way of module A to output its progress? I guess it's a design decision. + +Would a getter in module A make sense so that module B has to always call this getter (maybe in a loop) in order to retrieve the progress of A? +Would it possible to somehow use a callback function which is implemented in module A in such a way that this function is called every time the progress updates? So that this callback returns the current progress of A. +Is there maybe any other approach to this that could be used? + +Pointing me towards already existing solutions would be very helpful!","Essentially module B want to observe module A as it goes though extensive computation steps. And it is up to module A to decide how to compute progress and share this with module B. Module B can't compute progress as it doesn't know details of computation. So its is good use of observer pattern. Module A keeps notifying B about its progress. Form of progress update is also important. It can in terms of percentage, or ""step 5 of 10"" or time. It will actually define the notification payload structure with which module A will notify module B.",0.0,False,1,6649 +2020-03-28 15:31:06.740,Where does kivy.storage.jsonstore saves its files?,"I have a kivy app, where I use JsonStorage. Where does kivy save the json files, so how can I find it?",I just found out the json file is on the same level as the kivy_venv folder,1.2,True,1,6650 +2020-03-30 13:27:37.467,Python wait for request to be processed by queue and continue processing based on response,"I have the following setup: + +One thread which runs a directory crawler and parses documents +Another thread which processes database requests it gets in a queue - there are two basic database requests that come through - mark document processed (write operation) and is document already +processed (select operation) + +I understand that an sqlite connection object cannot be shared across threads, so the connection is maintained in the database thread. I am new to threading though and in my parser thread I want to check first if a document has been processed which means a database call, but obviously cannot do this call directly and have to send the request to the database thread which is fine. +However, where I am stuck is I am not sure how to make the parser thread wait for the result of the ""has document been processed"" request in the database thread. Is this where a threading event would come in? +Thanks in advance for your help!","Thanks to stovfl, used a threading event to realise this. Thanks again!",0.0,False,1,6651 +2020-03-30 18:29:23.523,How to accesss a python virtual enviroment when the command prompt is accidentally closed?,"I opened a virtual enviroment and accidentally closed the command prompt window in Windows. +I wanted to delete the virtual enviroment folder, but when I tried, it says program is running which still uses the files. +So how do I get back to the virtual enviroment, without opening a new one?",Just kill the daemon-process by command in Ctrl+Alt+Del interface. Then you can delete a folder,0.0,False,1,6652 +2020-03-30 19:49:43.310,Recommended python scientific workflow management tool that defines dependency completeness on parameter state rather than time?,"It's past time for me to move from my custom scientific workflow management (python) to some group effort. In brief, my workflow involves long running (days) processes with a large number of shared parameters. As a dependency graph, nodes are tasks that produce output or do some other work. That seems fairly universal in workflow tools. +However, key to my needs is that each task is defined by the parameters it requires. Tasks are instantiated with respect to the state of those parameters and all parameters of its dependencies. Thus if a task has completed its job according to a given parameter state, it is complete and not rerun. This parameter state is NOT the global parameter state but only what is relevant to that part of the DAG. This reliance on parameter state rather than time completed appears to be the essential difference between my needs and existing tools (at least what I have gathered from a quick look at Luigi and Airflow). Time completed might be one such parameter, but in general it is not the time that determines a (re)run of the DAG, but whether the parameter state is congruent with the parameter state of the calling task. There are non-trivial issues (to me) with 'parameter explosion' and the relationship to parameter state and the DAG, but those are not my question here. +My question -- which existing python tool would more readily allow defining 'complete' with respect to this parameter state? It's been suggested that Luigi is compatible with my needs by writing a custom complete method that would compare the metadata of built data ('targets') with the needed parameter state. +How about Airflow? I don't see any mention of this issue but have only briefly perused the docs. Since adding this functionality is a significant effort that takes away from my 'scientific' work, I would like to start out with the better tool. Airflow definitely has momentum but my needs may be too far from its purpose. +Defining the complete parameter state is needed for two reasons -- 1) with complex, long running tasks, I can't just re-run the DAG every time I change some parameter in the very large global parameter state, and 2) I need to know how the intermediate and final results have been produced for scientific and data integrity reasons.","I looked further into Luigi and Airflow and as far as I could discern neither of these is suitable for modification for my needs. The primary incompatibility is that these tools are fundamentally based on predetermined DAGs/workflows. My existing framework operates on instantiated and fully specified DAGs that are discovered at run-time rather than concisely described externally -- necessary because knowing whether each task is complete, for a given request, is dependent on many combinations of parameter values that define the output of that task and the utilized output of all upstream tasks. By instantiated, I mean the 'intermediate' results of individual runs each described by the full parameter state (variable values) necessary to reproduce (withstanding any stochastic element) identical output from that task. +So a 'Scheduler' that operates on a DAG ahead of time is not useful. +In general, most existing workflow frameworks, at least in python, that I've glanced at appear more to be designed to automate many relatively simple tasks in an easily scalable and robust manner with parallelization, with little emphasis put on the incremental building up of more complex analyses with results that must be reused when possible designed to link complex and expensive computational tasks the output of which may likely in turn be used as input for an additional unforeseen analysis. +I just discovered the 'Prefect' workflow this morning, and am intrigued to learn more -- at least it is clearly well funded ;-). My initial sense is that it may be less reliant on pre-scheduling and thus more fluid and more readily adapted to my needs, but that's just a hunch. In many ways some of my more complex 'single' tasks might be well suited to wrap an entire Prefect Flow if they played nicely together. It seems my needs are on the far end of the spectrum of deep complicated DAGs (I will not try to write mine out!) with never ending downstream additions. +I'm going to look into Prefect and Luigi more closely and see what I can borrow to make my framework more robust and less baroque. Or maybe I can add a layer of full data description to Prefect... +UPDATE -- discussing with Prefect folks, clear that I need to start with the underlying Dask and see if it is flexible enough -- perhaps using Dask delayed or futures. Clearly Dask is extraordinary. Graphchain built on top of Dask is a move in the right direction by facilitating permanent storage of 'intermediate' output computed over a dependency 'chain' identified by hash of code base and parameters. Pretty close to what I need, though with more explicit handling of those parameters that deterministically define the outputs.",0.3869120172231254,False,1,6653 +2020-04-01 00:12:57.697,"Is it possible to ""customize"" python?","Can I change the core functionality of Python, for example, rewrite it to use say(""Hello world"") instead of print(""Hello world"")? +If this is possible, how can this be done?","yes you can just write +say = print +say(""hello"")",0.0,False,1,6654 +2020-04-01 14:28:25.297,Python Arcsin Arccos radian and degree,"I am working on wind power and speed +u and vare zonal and meridional wind. (I have the values of these 2 vectors) +The wind speed is calculated by V = np.sqrt(u2*v2) +Wind direction is given by α between 0 and 360 degree +I know this relation holds - u / V = sin( abs(α)) and - v / V = cos( abs(α)) +In python I am using np.arccos and np.arcsin to try to find α between 0 and 360 with the 2 equation above. For the first one, it returns the radian so I convert with np.rad2deg(...) but it gives me a value between 0 and 180 degree for the second one, I also try to convert but it returns me a valus between 0 and 90. +Anyone knows how to code it? I am lost :(","The underlying problem is mathematics: cos(-x) == cos(x), so the function acos has only values in the [0,pi] interval. And for equivalent reasons asin has values in [-pi/2,pi/2] one. +But trigonometric library designers know about that, and provide a special function (atan2) which uses both coordinates (and not a ratio) to give a value in the [-pi, pi] interval. +That being said, be careful when processing wind values. A 360 wind is a wind coming from the North, and 90 is a wind coming from the East. Which is not the way mathematicians count angles...",0.3869120172231254,False,1,6655 +2020-04-01 19:04:15.633,How to play ogg files on python,"I looked everywhere, I don't find a way to properly play Ogg files, they all play wav! +My question is: Does somebody knows how to play Ogg files in python? +If somebody knows how I'll be very thankful :) +(I am on windows)","The easiest way is probably to start a media player application to play the file using subprocess.Popen. +If you already have a media player associated with Ogg files installed, using the start command should work.",0.0,False,1,6656 +2020-04-02 14:27:00.470,Restore file tabs above main editor in Spyder,I was modifying the layout in Spyder 4.1.1 and somehow lost the filename tabs (names of opened .py files) that used to appear above the central editor window. These were the tabs that had the 'X' button in them that allowed you to quickly close them. I've been toggling options in the View and Tools menus but can't seem to get it back. Anyone know how to restore this?,Try it. From menu View --> Panes --> Editor. Clicking on Editor and putting a tick there should bring that back if I understand your question properly,0.2012947653214861,False,2,6657 +2020-04-02 14:27:00.470,Restore file tabs above main editor in Spyder,I was modifying the layout in Spyder 4.1.1 and somehow lost the filename tabs (names of opened .py files) that used to appear above the central editor window. These were the tabs that had the 'X' button in them that allowed you to quickly close them. I've been toggling options in the View and Tools menus but can't seem to get it back. Anyone know how to restore this?,"(Spyder maintainer here) You can restore the tab bar in our editor by going to the menu +Tools > Preferences > Editor > Display +and selecting the option called Show tab bar.",1.2,True,2,6657 +2020-04-02 15:13:40.530,"In a child widget, how do I get the instance of a parent widget in kivy",How do I get the instance of a parent widget from within the child widget in kivy? This is so that I can remove the child widget from within the child widget class from the parent widget.,use parent. or root.ids.,0.0,False,1,6658 +2020-04-02 23:53:56.067,Python version in Visual Studio console,I have set the interpreter to 3.8.2 but when I type in the console python --version it gives me the python 2.7.2. Why is that and how to change the console version so I can run my files with Python 3? In windows console I have of course python 3 when I type the --version.,"The console displayed by VSCode is basically an ordinary terminal. When you run the python file from VSCode using the green arrow at the top, it will call the appropriate python version displayed at the bottom of the VSCode window. You can also see what VSCode executes in the terminal seeing to which python its pointing to.",0.2012947653214861,False,2,6659 +2020-04-02 23:53:56.067,Python version in Visual Studio console,I have set the interpreter to 3.8.2 but when I type in the console python --version it gives me the python 2.7.2. Why is that and how to change the console version so I can run my files with Python 3? In windows console I have of course python 3 when I type the --version.,"(Assuming you use Visual Studio Code with the Python Extension) +The interpreter set in visual studio has nothing to do with the terminal python version when you run python --version. +python --version is bound to what python version is bound to 'python' in your environment variables. +Try python3 --version in the visual studio console to see what version is bound to python3. +If this is the right version, use python3 in the visual studio console from now on.",0.0,False,2,6659 +2020-04-03 15:17:33.063,Print an UTF8-encoded smiley,"I am writing an ReactionRoles-Discord-Bot in Python (discord.py). +This Bot saves the ReactionRoles-Smileys as UFT8-Encoded. +The type of the encoded is bytes but it's converted to str to save it. +The string looks something like ""b'\\xf0\\x9f\\x98\\x82'"". +I am using EMOJI_ENCODED = str(EMOJI.encode('utf8')) to encode it, but bytes(EMOJI_ENCODED).decode('utf8') isn't working. +Do you know how to decode it or how to save it in a better way?","The output of str() is a Unicode string. EMOJI is a Unicode string. str(EMOJI.encode('utf8')) just makes a mangled Unicode string. +The purpose of encoding is to make a byte string that can be saved to a file/database/socket. Simply do b = EMOJI.encode() (default is UTF-8) to get a byte string and s = b.decode() to get the Unicode string back.",0.0,False,1,6660 +2020-04-06 15:12:45.273,How can I see the source code for a python library?,"I currently find myself using the bs4/BeautifulSoup library a lot in python, and have recently been wondering how it works. I would love to see the source code for the library and don't know how. Does anyone know how to do this? Thanks.","If you are using any IDE, you can right click on imported line and goto Implementation. +Otherwise you can find the source code in \Lib\site-packages directory.",0.1352210990936997,False,2,6661 +2020-04-06 15:12:45.273,How can I see the source code for a python library?,"I currently find myself using the bs4/BeautifulSoup library a lot in python, and have recently been wondering how it works. I would love to see the source code for the library and don't know how. Does anyone know how to do this? Thanks.","Go to the location where python is installed and inside the python folder, you will have a folder called Lib you can find all the packages there open the required python file you will get the code. +example location: C:\Python38\Lib",0.0,False,2,6661 +2020-04-08 01:37:55.407,Identifying positive pixels after color deconvolution ignoring boundaries,"I am analyzing histology tissue images stained with a specific protein marker which I would like to identify the positive pixels for that marker. My problem is that thresholding on the image gives too much false positives which I'd like to exclude. +I am using color deconvolution (separate_stains from skimage.color) to get the AEC channel (corresponding to the red marker), separating it from the background (Hematoxylin blue color) and applying cv2 Otsu thresholding to identify the positive pixels using cv2.threshold(blur,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU), but it is also picking up the tissue boundaries (see white lines in the example picture, sometimes it even has random colors other than white) and sometimes even non positive cells (blue regions in the example picture). It's also missing some faint positive pixels which I'd like to capture. +Overall: (1) how do I filter the false positive tissue boundaries and blue pixels? and (2) how do I adjust the Otsu thresholding to capture the faint red positives? +Adding a revised example image - + +top left the original image after using HistoQC to identify tissue regions and apply the mask it identified on the tissue such that all of the non-tissue regions are black. I should tru to adjust its parameters to exclude the folded tissue regions which appear more dark (towards the bottom left of this image). Suggestions for other tools to identify tissue regions are welcome. +top right hematoxylin after the deconvolution +bottom left AEC after the deconvolution +bottom right Otsu thresholding applied not the original RGB image trying to capture only the AEC positives pixels but showing also false positives and false negatives + +Thanks","I ended up incorporating some of the feedback given above by Chris into the following possible unconventional solution for which I would appreciate getting feedback (to the specific questions below but also general suggestions for improvement or more effective/accurate tools or strategy): + +Define (but not apply yet) tissue mask (HistoQC) after optimizing HistoQC script to remove as much of the tissue folds as possible without removing normal tissue area +Apply deconvolution on the original RGB image using hax_from_rgb +Using the second channel which should correspond to the red stain pixels, and subtract from it the third channel which as far as I see corresponds to the background non-red/blue pixels of the image. This step removes the high values in the second channel that which up because of tissue folds or other artifacts that weren't removed in the first step (what does the third channel correspond to? The Green element of RGB?) +Blur the adjusted image and threshold based on the median of the image plus 20 (Semi-arbitrary but it works. Are there better alternatives? Otsu doesn't work here at all) +Apply the tissue regions mask on the thresholded image yielding only positive red/red-ish pixels without the non-tissue areas +Count the % of positive pixels relative to the tissue mask area + +I have been trying to apply, as suggested above, the tissue mask on the deconvolution red channel output and then use Otsu thresholding. But it failed since the black background generated by the applying the tissue regions mask makes the Otsu threshold detect the entire tissue as positive. So I have proceeded instead to apply the threshold on the adjusted red channel and then apply the tissue mask before counting positive pixels. I am interested in learning what am I doing wrong here. +Other than that, the LoG transformation didn't seem to work well because it produced a lot of stretched bright segments rather than just circular blobs where cells are located. I'm not sure why this is happening.",0.1016881243684853,False,1,6662 +2020-04-09 08:59:03.497,Python: how to write a wrapper to make all variables decalared inside a function globals?,"I want a function to be run as if it was written in the main program, i.e. all the variables defined therein can be accessed from the main program. I don't know if there's a way to do that, but I thought a wrapper that gives this behaviour would be cool. It's just hacky and I don't know how to start writing it.","I have pieces of code written inside functions, and I really want to run them and have all the variables defined therein after run without having to write the lengthy return statements. How can I do that? + +That's what classes are for. Write a class with all your functions as methods, and use instance attributes to store the shared state. Problem solved, no global required.",1.2,True,1,6663 +2020-04-09 15:52:14.077,Python time series using FB Prophet with covid-19,"I have prepared a time series model using FB Prophet for making forecasts. The model forecasts for the coming 30 days and my data ranges from Jan 2019 until Mar 2020 both months inclusive with all the dates filled in. The model has been built specifically for the UK market +I have already taken care of the following: + +Seasonality +Holidaying Effect + +My question is, that how do I take care of the current COVID-19 situation into the same model? The cases that I am trying to forecast are also dependent on the previous data at least from Jan 2020. So in order to forecast I need to take into account the current coronavirus situation as well that would impact my forecasts apart from seasonality and holidaying effect. +How should I achieve this?","I have had the same issue with COVID at my work with sales forecasting. The easy solution for me was to make an additional regressor which indicates the COVID period, and use that in my model. Then my future is not affected by COVID, unless I tell it that it should be.",0.0,False,1,6664 +2020-04-10 21:53:54.647,How to get auto completion on jupyter notebook?,"I am new to Python language programming. I found that we can have auto completion on Jupyter notebook. I found this suggestion: +""The auto-completion with Jupyter Notebook is so weak, even with hinterland extension. Thanks for the idea of deep-learning-based code auto-completion. I developed a Jupyter Notebook Extension based on TabNine which provides code auto-completion based on Deep Learning. Here's the Github link of my work: jupyter-tabnine. +It's available on pypi index now. Simply issue following commands, then enjoy it:) +pip3 install jupyter-tabnine, +jupyter nbextension install --py jupyter_tabnine, +jupyter nbextension enable --py jupyter_tabnine, +jupyter serverextension enable --py jupyter_tabnine"" +I did 4 steps installation and it looked installed well. However, when I tried using Jupyter notebook its auto completion didn't work. Basically my question is please help how to get auto completion on Jupiter notebook? Thank you very much.",Press tab twice while you are writing your code and the autocomplete tab will show for you. Just select one and press enter,0.5457054096481145,False,2,6665 +2020-04-10 21:53:54.647,How to get auto completion on jupyter notebook?,"I am new to Python language programming. I found that we can have auto completion on Jupyter notebook. I found this suggestion: +""The auto-completion with Jupyter Notebook is so weak, even with hinterland extension. Thanks for the idea of deep-learning-based code auto-completion. I developed a Jupyter Notebook Extension based on TabNine which provides code auto-completion based on Deep Learning. Here's the Github link of my work: jupyter-tabnine. +It's available on pypi index now. Simply issue following commands, then enjoy it:) +pip3 install jupyter-tabnine, +jupyter nbextension install --py jupyter_tabnine, +jupyter nbextension enable --py jupyter_tabnine, +jupyter serverextension enable --py jupyter_tabnine"" +I did 4 steps installation and it looked installed well. However, when I tried using Jupyter notebook its auto completion didn't work. Basically my question is please help how to get auto completion on Jupiter notebook? Thank you very much.","After installing Nbextensions, go to Nbextensions in jupyter notebook, tick on Hinterland. Then reopen your jupyter notebook.",1.2,True,2,6665 +2020-04-10 22:10:08.740,Get pixel boundary coordinates from binary image in Python (not edges),"I have a binary image containing a single contiguous blob, with no holes. I would like create a polygon object based on the exterior edges of the edge pixels. I know how to get the edge pixels themselves, but I want the actual coordinates of the pixel boundaries, sorted clockwise or counter-clockwise. All of the pixels have integer coordinates. +For example, say I have a single pixel at (2,2). The vertices of the polygon would be: +(2.5, 2.5) +(2.5, 1.5) +(1.5, 1.5) +(1.5, 2.5) +(2.5, 2.5) +Is there an exact, non-approximate way to do this? Preferably in Python?","Based on the comments, here is the approach that I implemented: + +multiply all pixel coordinates by 10, so that we'll only deal with integers. + +For each pixel, generate the 4 corners by adding +/- 5. For example, for (20,20), the corners are (25, 25) (25, 15) (15, 15) (15, 25) (25, 25). And store all the corners in a list. + +Count the occurrences of each corner. If the count is odd, it is a corner to the blob. Making the coordinates integers makes this step easy. Counting floats has issues. + +Divide the blob corner coordinates by 10, getting back the original resolution. + +Sort the corners clockwise using a standard algorithm.",1.2,True,1,6666 +2020-04-11 11:45:48.813,Packaging Kivy application to Android - Windows,"I finished writing the code for a simple game using Kivy. I am having a problem converting it to Android APK, since I am using a windows computer. From some earlier research I got to know that using a Virtual machine is recommended, but I have no idea on how to download and use one :(, and if my slow PC can handle it... please help me. If possible, kindly recommend another way to convert to APK. +I am a beginner at coding as a whole, please excuse me if my question is stupid.",you could just try downloading a virtual box and installing linux operating system or you could directly install it and keep it a drive called F or E and you could just install python on that and all the required pakages and start the build using buildozer as it is not available for windows. So try doing it. But I need to do it just now. Tell me after you have tried that cuz there are a lot of people online on youtube who would heloo you doing that work,0.0,False,1,6667 +2020-04-11 14:36:32.187,How to stop vscode python terminal without deleting the log?,"when clicking ""Run Python file in terminal"" how do I stop the script? the only way that I found is by clicking the trashcan which deletes the log in the terminal.",When a Python file is running in the terminal you can hit Ctrl-C to try and interrupt it.,1.2,True,1,6668 +2020-04-11 21:09:01.457,python equivalent to matlab mvnrnd?,"I was just wondering how to go from mvnrnd([4 3], [.4 1.2], 300); in MATLAB code to np.random.multivariate_normal([4,3], [[x_1 x_2],[x_3 x_4]], 300) in Python. +My doubt namely lays on the sigma parameter, since, in MATLAB, a 2D vector is used to specify the covariance; whereas, in Python, a matrix must be used. +What is the theoretical meaning on that and what is the practical approach to go from one to another, for instance, in this case? Also, is there a rapid, mechanical way? +Thanks for reading.","Although python expects a matrix, it is essentially a symmetric covariance matrix. So it has to be a square matrix. +In 2x2 case, a symmetric matrix will have mirrored non diagonal elements. +I believe in python, it should look like [[.4 1.2],[1.2 .4]]",0.0,False,1,6669 +2020-04-12 14:40:25.627,how to get value of decision variable after maximum iteration limit in gekko,"I have written my code in python3 and solved it using Gekko solver. +After 10000 iterations, I am getting the error maximum iteration reached and solution not found. +So can I get the value of decision variables after the 10000th iteration? +I mean even when the maximum iteration is reached the solver must have a value of decision variable in the last iteration. so I want to access that values. how can I do that?","Question: +1) I am solving an MINLP problem with APOPT Solver. And my decision variables are defined as integer. I have retrieved the result of 10,000th iteration as you suggested. but the Decision variables values are non-integer. So why APOPT Solver is calculating a non-integer solution? +Answer: +There is an option on what is classified as an integer. The default tolerance is any number within 0.05 of an integer value. +you can change this by: +m.solver_options = ['minlp_integer_tol 1'] +2) I am running the code for ""m.options.MAX_ITER=100"" and using m = GEKKO() i.e. using remote server. But my code is still running for 10000th iterations. +Answer: Can do it alternatively by: +m.solver_options = ['minlp_maximum_iterations 100'] +Thanks a lot to Prof. John Hedengren for the prompt replies. +Gekko",0.0,False,1,6670 +2020-04-12 17:33:33.530,How to find the index of each leaf or node in a Decision Tree?,"The main question is to find which leaf node each sample is classified. There are thousands of posts on using tree.apply. I am well aware of this function, which returns the index of the leaf node. +Now, I would like to add the leaf index in the nodes of the graph (which I generate by using Graphviz). +Drawing the enumeration technique used for the indexes won't work. The decision tree that I am developing is quite big. Therefore, I need to be able to print the leaf index in the graph. +Another option that I am open to is to generate an array with all the leaf indexes (in the same order) of the leaf nodes of the decision tree. Any hint on how to do this?","There is a parameter node_ids of the command export_graphviz. When this parameter is set to True, then the indexes are added on the label of the decision tree.",1.2,True,1,6671 +2020-04-12 18:23:13.403,"Is it possible to reuse a widget in Tkinter? If so, how can I do it using classes?","I'm using classes and such to make a calculator in Tkinter, however I want to be able to be able to reuse widgets for multiple windows. How can I do this if this is possible?","A widget may only exist in one window at a time, and cannot be moved between windows (the root window and instances of Toplevel).",0.2012947653214861,False,2,6672 +2020-04-12 18:23:13.403,"Is it possible to reuse a widget in Tkinter? If so, how can I do it using classes?","I'm using classes and such to make a calculator in Tkinter, however I want to be able to be able to reuse widgets for multiple windows. How can I do this if this is possible?","As you commented: + +I'm making a calculator, as mentioned and I want to have a drop down menu on the window, that when selected it closes the root window and opens another, and I want to have the drop down menu on all the different pages, 5 or 6 in all + +In this case, just write a function that creates the menu. +Then call that function when creating each of the windows.",1.2,True,2,6672 +2020-04-12 23:48:11.210,Distributed computing for multiplying numbers,"Can you show me how I can multiply two integers which are M bits long using at most O(N^1.63) processors in O(N) parallel time in python. +I think that karatsuba algorithm would work but I don't understand how can I implement it parallely.","Yes, It is parallel karatsuba algorithm.",-0.3869120172231254,False,1,6673 +2020-04-13 08:07:07.280,how can i find IDLE in my mac though i installed my python3 with pip?,"I entered '''idle''' on terminal +and it only shows me python2 that has already been here. +How can i see python3 idle on my mac +while i installed python3 with pip?","you can specify the version +idle3",0.0,False,1,6674 +2020-04-13 10:32:47.843,how i ask for input in my telegram chat bot python telebot,"I am trying to get input from the user and send this input to all bot subscribers. +so I need to save his input in variable and use it after this in send_message method but I don't know how to make my bot wait for user input and what method I should use to receive user input +thanks :]","If you want to get an user input, the logic is a bit different. I suppose you are using longpolling. +When the bot asks the user for input, you can just save a boolean/string in a global variable, let's suppose the variable is user_input: +You receive the update, and ask the user for input, then you set user_input[user's id]['input'] = true +Then when you receive another update you just check that variable with an if (if user_input[userid]['input']: # do something). + +If your problem is 403 Forbidden for ""user has blocked the bot"", you can't do anything about it.",0.0,False,1,6675 +2020-04-13 10:39:34.980,How to monitor key presses in Python 3.7 using IDLE on Mac OSX,"Using Python 3.7 with IDLE, on Mac. I want to be able to monitor key presses and immediately return either the character or its ASCII or Unicode value. I can't see how to use pynput with Idle. Any ideas please?","You can't. IDLE uses the tkinter interface to the tcl/tk GUI framework. The IDLE doc has a section currently title 'Running user code' with this paragraph. + +When Shell has the focus, it controls the keyboard and screen. This is normally transparent, but functions that directly access the keyboard and screen will not work. These include system-specific functions that determine whether a key has been pressed and if so, which.",1.2,True,1,6676 +2020-04-13 14:37:13.480,OpenCV built from source: Pycharm doesn't get autocomplete information,"I'm trying to install OpenCV into my python environment (Windows), and I'm almost all of the way there, but still having some issues with autocomplete and Pycharm itself importing the library. I've been through countless other related threads, but it seems like most of them are either outdated, for prebuilt versions, or unanswered. +I'm using Anaconda and have several environments, and unfortunately installing it through pip install opencv-contrib-python doesn't include everything I need. So, I've built it from source, and the library itself seem to be working fine. The build process installed some things into ./Anaconda3/envs/cv/Lib/site-packages/cv2/: __init__.py, some config py files, and .../cv2/python-3.8/cv2.cp38-win_amd64.pyd. I'm not sure if it did anything else. +But here's where I'm at: + +In a separate environment, a pip install opencv-contrib-python both runs and has autocomplete working +In this environment, OpenCV actually runs just fine, but the autocomplete doesn't work and Pycharm complains about everything, eg: Cannot find reference 'imread' in '__init__.py' +Invalidate Caches / Restart doesn't help +Removing and re-adding the environment doesn't help +Deleting the user preferences folder for Pycharm doesn't help +Rebuilding/Installing OpenCV doesn't help +File->Settings->Project->Project Interpreter is set correctly +Run->Edit Configuration->Python Interpreter is set correctly + +So my question is: how does Pycharm get or generate that autocomplete information? It looks like the pyd file is just a dll in disguise, and looking through the other environment's site-packages/cv2 folder, I don't see anything interesting. I've read that __init__.py has something to do with it, but again the pip version doesn't contain anything (except there's a from .cv2 import *, but I'm not sure how that factors in). The .whl file you can download is a zip that only contains the same as what 'pip install' gets. +Where does the autocomplete information get stored? Maybe there's some way to copy it from one environment to another? It would get me almost all the way there, which at this point would be good enough I think. Maybe I need to rebuild it with another flag I missed?","Got it finally! Figures that would happen just after posting the question... +Turns out .../envs/cv/site-packages/cv2/python-3.8/cv2.cp38-win_amd64.pyd needed to be copied to .../envs/cv/DLLs/. Then PyCharm did it's magic and is now all good.",0.6730655149877884,False,2,6677 +2020-04-13 14:37:13.480,OpenCV built from source: Pycharm doesn't get autocomplete information,"I'm trying to install OpenCV into my python environment (Windows), and I'm almost all of the way there, but still having some issues with autocomplete and Pycharm itself importing the library. I've been through countless other related threads, but it seems like most of them are either outdated, for prebuilt versions, or unanswered. +I'm using Anaconda and have several environments, and unfortunately installing it through pip install opencv-contrib-python doesn't include everything I need. So, I've built it from source, and the library itself seem to be working fine. The build process installed some things into ./Anaconda3/envs/cv/Lib/site-packages/cv2/: __init__.py, some config py files, and .../cv2/python-3.8/cv2.cp38-win_amd64.pyd. I'm not sure if it did anything else. +But here's where I'm at: + +In a separate environment, a pip install opencv-contrib-python both runs and has autocomplete working +In this environment, OpenCV actually runs just fine, but the autocomplete doesn't work and Pycharm complains about everything, eg: Cannot find reference 'imread' in '__init__.py' +Invalidate Caches / Restart doesn't help +Removing and re-adding the environment doesn't help +Deleting the user preferences folder for Pycharm doesn't help +Rebuilding/Installing OpenCV doesn't help +File->Settings->Project->Project Interpreter is set correctly +Run->Edit Configuration->Python Interpreter is set correctly + +So my question is: how does Pycharm get or generate that autocomplete information? It looks like the pyd file is just a dll in disguise, and looking through the other environment's site-packages/cv2 folder, I don't see anything interesting. I've read that __init__.py has something to do with it, but again the pip version doesn't contain anything (except there's a from .cv2 import *, but I'm not sure how that factors in). The .whl file you can download is a zip that only contains the same as what 'pip install' gets. +Where does the autocomplete information get stored? Maybe there's some way to copy it from one environment to another? It would get me almost all the way there, which at this point would be good enough I think. Maybe I need to rebuild it with another flag I missed?","Alternatively add the directory containing the .pyd file to the interpreter paths. +I had exactly this problem with OpenCV 4.2.0 compiled from sources, installed in my Conda environment and PyCharm 2020.1. +I solved this way: + +Select project interpreter +Click on the settings button next to it and then clicking on the Show paths for selected interpreter +adding the directory containing the cv2 library (in my case in the Conda Python library path - e.g. miniconda3/lib/python3.7/site-packages/cv2/python-3.7). In general check the site-packages/cv2/python-X.X directory)",0.6730655149877884,False,2,6677 +2020-04-14 08:45:43.027,How to classify English words according to topics with python?,"How to classify English words according to topics with python? Such as THE COUNTRY AND GOVERNMENT: regime, politically, politician, official, democracy......besides, there are other topics: education/family/economy/subjects and so on. +I want to sort out The Economist magazine vocabularies and classify these according to frequency and topic. +At present, I have completed the words frequency statistics, the next step is how to classify these words automatically with python?","It sounds quite tough to handle it. Also it is not a simple task. If I were you, I consider 2 ways to do what you ask. + +Make your own rule for it + +If you complete counting the words, then you should match those word to topic. There is no free lunch. Make own your rule for classifying category. e.g. Entertainment has many ""TV"" and ""drama"" so If some text has it, then we can guess it belongs to Entertainment. + +Machine learning. + +If you can't afford to make rules, let machine do it. But even in this case, you should label the article with your desired class(topics). +Unsupervised pre-training(e.g. clustering) can also be used here. but at last, we need supervised data set with topics. +You should decide taxonomy of topics. + + +Welcome to ML world. +Hope it helps to get the right starting point.",0.0,False,1,6678 +2020-04-15 06:06:44.530,Can I use JWTAuthentication twice for a login authentication?,"In my login First place I wanted to send OTP and second place I wanted to verify the OTP and then return the token. +I am using rest_framework_simplejwt JWTAuthentication. First place I am verifying the user and sending the OTP, not returning the token and second place I am verifying the OTP and returning the token. +Let me know If this is the correct way to use? If not how can I implement this using JWTAuthentication. +OR If this is not correct way to use, can I implement like first place use Basic authentication to verify the user and second place jwt authentication to verify the OTP and send the tokens. Let me know your solution.","What I understood? +You need to send an OTP to the current user who is hitting your send_otp route after checking if the user exists or not in your system and then verify_otp route which will verify the OTP that the user has sent in the API alongwith it's corresponding mobile_number/email_id. +How to do it? + +send_otp - Keep this route open, you don't need an authentication for this, not even Basic Auth (that's how it works in industry), just get the mobile_number from the user in the request, check whether it exists in the DB, and send the OTP to this number, and set the OTP to the corresponding user in your cache maybe for rechecking (redis/memcache). Use throttling for this route so that nobody will be able to exploit this API of yours. +verify_otp - This route will also be open (no authentication_class/permission_classes), get the mobile_number/email id + OTP from the user, verify it in cache, if verified, generate the token using TokenObtainPairSerializer and send the refresh + access token in the response, if the OTP is incorrect, send 401.",0.0,False,1,6679 +2020-04-15 11:29:23.330,send request in selenium without clicking on the send button in python,"I have python script that use selenium to login website, you should insert the username and password and captcha for submit button to login.after this login webpage have send button for send form information with post request, how can i bypass this clicking in button and send the post request without clicking on the button ?","If you mean that you want to try and bypass the captcha and go straight to the send button, I doubt that's possible. If you need to solve recaptchas, check out 2captcha.com and use their API to solve it - which will unlock the send button, theoretically.",0.0,False,1,6680 +2020-04-15 23:29:13.073,What is the use of Celery in python?,I am confused in celery.Example i want to load a data file and it takes 10 seconds to load without celery.With celery how will the user be benefited? Will it take same time to load data?,"Celery, and similar systems like Huey are made to help us distribute (offload) the amount of processes that normally can't execute concurrently on a single machine, or it would lead to significant performance degradation if you do so. The key word here is DISTRIBUTED. +You mentioned downloading of a file. If it is a single file you need to download, and that is all, then you do not need Celery. How about more complex scenario - you need to download 100000 files? How about even more complex - these 100000 files need to be parsed and the parsing process is CPU intensive? +Moreover, Celery will help you with retrying of failed tasks, logging, monitoring, etc.",1.2,True,2,6681 +2020-04-15 23:29:13.073,What is the use of Celery in python?,I am confused in celery.Example i want to load a data file and it takes 10 seconds to load without celery.With celery how will the user be benefited? Will it take same time to load data?,"Normally, the user has to wait to load the data file to be done on the server. But with the help of celery, the operation will be performed on the server and the user will not be involved. Even if the app crashes, that task will be queued. + +Celery will keep track of the work you send to it in a database + back-end such as Redis or RabbitMQ. This keeps the state out of your + app server's process which means even if your app server crashes your + job queue will still remain. Celery also allows you to track tasks + that fail.",0.0,False,2,6681 +2020-04-16 12:20:31.583,Set Custom Discord Status when running/starting a Program,"I am working on a application, where it would be cool to change the Status of your Discord User you are currently logged in to. For example when i start the appplication then the Status should change to something like ""Playing Program"" and when you click on the User's Status then it should display the Image of the Program. +Now i wanted to ask if this is somehow possible to make and in which programming Languages is it makeable? +EDIT: Solved the Problem with pypresence","In your startup, where DiscordSocketClient is available, you can use SetGameAsync(). This is for C# using Discord.NET. +To answer your question, I think any wrapper for Discord's API allows you to set the current playing game.",0.0,False,1,6682 +2020-04-16 23:05:48.100,Save periodically gathered data with python,"I periodically receive data (every 15 minutes) and have them in an array (numpy array to be precise) in python, that is roughly 50 columns, the number of rows varies, usually is somewhere around 100-200. +Before, I only analyzed this data and tossed it, but now I'd like to start saving it, so that I can create statistics later. +I have considered saving it in a csv file, but it did not seem right to me to save high amounts of such big 2D arrays to a csv file. +I've looked at serialization options, particularly pickle and numpy's .tobytes(), but in both cases I run into an issue - I have to track the amount of arrays stored. I've seen people write the number as the first thing in the file, but I don't know how I would be able to keep incrementing the number while having the file still opened (the program that gathers the data runs practically non-stop). Constantly opening the file, reading the number, rewriting it, seeking to the end to write new data and closing the file again doesn't seem very efficient. +I feel like I'm missing some vital information and have not been able to find it. I'd love it if someone could show me something I can not see and help me solve the problem.","Saving on a csv file might not be a good idea in this case, think about the accessibility and availability of your data. Using a database will be better, you can easily update your data and control the size amount of data you store.",0.3869120172231254,False,1,6683 +2020-04-17 01:04:58.020,Tkinter - how to prevent user window resize from disabling autoresize?,"I have a question related to an annoying behavior I have observed recently in tkinter. When there's no fixed window size defined, the main window is expanded when adding new frames, which is great. However, if prior to adding a new widget the user only so much as touches the resizing handles, resizing the main window manually, then the window does not expand to fit the new widget. Why is that so and is there a way to prevent this behavior? +Thanks in advance!","The why is because tkinter was designed to let the user ultimately control the size of the window. If the user sets the window size, tkinter assumes it was for a reason and thus honors the requested size. +To get the resize behavior back, pass an empty string to the geometry method of the window.",0.3869120172231254,False,1,6684 +2020-04-17 06:16:21.087,how to get s3 object key by object url when I use aws lambda python?or How to get object by url?,"I use python boto3 +when I upload file to s3,aws lambda will move the file to other bucket,I can get object url by lambda event,like +https://xxx.s3.amazonaws.com/xxx/xxx/xxxx/xxxx/diamond+white.side.jpg +The object key is xxx/xxx/xxxx/xxxx/diamond+white.side.jpg +This is a simple example,I can replace ""+"" get object key, there are other complicated situations,I need to get object key by object url,How can I do it? +thanks!!","You should use urllib.parse.unquote and then replace + with space. +From my knowledge, + is the only exception from URL parsing, so you should be safe if you do that by hand.",0.2012947653214861,False,1,6685 +2020-04-17 17:10:44.803,Django REST Cache Invalidation,"I have a Django project and API view implemented with the Rest framework. I'm caching it using the @cache_page decorator but I need to implement a cache invalidation and I'm not seeing how to do that - do I need a custom decorator? +The problem: +The view checks the access of the API KEY and it caches it from the previous access check but, if the user changes the API KEY before the cache expires, the view will return an OK status of the key that no longer exists.","Yes, you'll need a cache decorator that takes the authentication/user context into account. cache_page() only works for GET requests, and keys based on the URL alone. +Better yet, though, + +Don't use a cache until you're sure you need one +If you do need it (think about why; cache invalidation is one of the two hard things), use a more granular cache within your view, not cache_page().",1.2,True,1,6686 +2020-04-17 17:23:20.373,Python3: can't open file 'sherlock.py' [Errno 2] No such file or directory,"So I am new to Kali Linux and I have installed the infamous Sherlock, nonetheless when I used the command to search for usernames it didn't work (Python3: can't open file 'sherlock.py' [Errno 2] No such file or directory). Naturally I tried to look up at similiar problems and have found that maybe the problem is located on my python path. +Which is currently located in /usr/bin/python/ and my pip is in /usr/local/bin/pip. Is my python and pip installed correctly in the path? If not, how do I set a correct path? +However if it is right and has no correlation with the issue, then what is the problem?",You have to change directory to sherlock twice. (it works for me),0.2012947653214861,False,1,6687 +2020-04-17 22:40:16.480,How to create individual node sets using abaqus python scripting?,"I am new to Python scripting in Abaqus. I am aware how to use the GUI but not really familiar with the scripting interface. However, I would like to know one specific thing. I would like to know how to assign a set to each individual node on a geometry's edges. I have thought about referencing the node numbers assigned to the geometry edges but don't know how I will do it. +The reason for creating a set for each node is that I would like to apply Periodic Boundary Conditions (PBC). Currently my model is a 2D Repeating Unit Cell (RUC) and I would like to apply a constraint equation between the opposite nodes on the opposite edges. To do that, I need to create a set for each node and then apply an equation on the corresponding set of nodes. +Just to add that the reason why I would like to use the Python scripting interface is because through the GUI, I can only make sets of nodes and create constraint equations for a simple mesh. But for a refined mesh, there will be a lot more constraint equations and a whole lot more sets. +Any suggestion of any kind would be really helpful.","One of the way would be with the help of getByBoundingBox(...) method available for selecting nodes inside of a particular bounding box. + +allNodes = mdb.models[name].parts[name].nodes + allNodes.getByBoundingBox(xMin, yMin, zMin, xMax, yMax, zMax) + mdb.models[name].parts[name].Set(name=, region=) + +One could always look for pointers in the replay file *.rpy of the current current session, which is mostly machine generated python code of the manual steps done in CAE. +Abaqus > Scripting Reference > Python commands > Mesh commands > MeshNodeArray object and Abaqus > Scripting Reference > Python commands > Region commands > Set object contains the relevant information.",1.2,True,1,6688 +2020-04-19 16:28:41.883,Python Seperate thread for list which automatically removes after time limit,"I want to have a list which my main process will add data to and this seperate thread will see the data added, wait a set amount of eg 1 minute then remove it from the list. Im not very experience with multi-threading in python so i dont know how to do this.","The way you could achieve this is by using a global variable as your list, as your thread will be able to access data from it. You can use a deque from the collections library, and each time you add something in the queue, you spawn a new thread that will just pop from the front after waiting that set amount of time. +Although, you have to be careful with the race conditions. It may happen that you try to write something at one end in your main thread and at the same time erase something from the beginning in one of your new threads, and this will cause unexpected behavior. +Best way to avoid this is by using a lock.",0.0,False,1,6689 +2020-04-20 05:00:44.977,How do you pass session object in TensorFlow v2?,"I have a function change_weight() that modifies weights in any given model. This function resides in a different python file. +So if I have a simple neural network that classifies MNIST images, I test the accuracy before and after calling this function and I see that it works. This was easy to do in TensorFlow v1, as I just had to pass the Session sess object in the function call, and I could get the weights of this session in the other file. +With eager execution in TensorFlow v2, how do I do this? I don't have a Session object anymore. What do I pass?",I was able to do this by passing the Model object instead and getting the weights by model.trainable_variables in the other function.,1.2,True,1,6690 +2020-04-20 14:29:58.670,PyQt5 Designer is not working: This application failed to start because no Qt platform plugin could be initialized,"i have a problem with PyQt5 Designer. I install PyQt with -pip install PyQt5 and then -pip install PyQt5-tools +everything OK. But when i try to run Designer it open messagebox with error: This application failed to start because no Qt platform plugin could be initialized! +how to deal with it?","Go to => +Python38>lib>site-packages>PyQt5>Qt>plugins +In plugins copy platform folder +After that go to +Python38>lib>site-packages>PyQt5_tools>Qt>bin +paste folder here . Do copy and replace. + +This will surely work.. +Now you can use designer tool go and do some fun with python...",0.9999999406721016,False,3,6691 +2020-04-20 14:29:58.670,PyQt5 Designer is not working: This application failed to start because no Qt platform plugin could be initialized,"i have a problem with PyQt5 Designer. I install PyQt with -pip install PyQt5 and then -pip install PyQt5-tools +everything OK. But when i try to run Designer it open messagebox with error: This application failed to start because no Qt platform plugin could be initialized! +how to deal with it?","I found a way of solving this: +Go to you python instalation folder Python38\Lib\site-packages\PyQt5\Qt\bin +Then copy all of that files to your clipboard and paste them at Python38\Lib\site-packages\pyqt5_tools\Qt\bin +Then open the designer.exe and it should work.",0.4961739557460144,False,3,6691 +2020-04-20 14:29:58.670,PyQt5 Designer is not working: This application failed to start because no Qt platform plugin could be initialized,"i have a problem with PyQt5 Designer. I install PyQt with -pip install PyQt5 and then -pip install PyQt5-tools +everything OK. But when i try to run Designer it open messagebox with error: This application failed to start because no Qt platform plugin could be initialized! +how to deal with it?","Try running it using command: pyqt5designer +It should set all the paths for libraries. +Works on Python 3.8, pyqt5-tool 5.15",0.9974579674738372,False,3,6691 +2020-04-21 06:23:06.150,What happens in background when we pass the command python manage.py createsuperuser in Django?,"I'm working on Django and I know to create a account to log in into admin page I have to create a superuser.And for that we have to pass the command python manage.py createsuperuser. +But my question is when we pass this command what happens first and because of what in the background and after that what happens?? Which all methods and classes are called to create a superuser?? +I know its a weird question but I wanted to know how this mechanism works.. +Thanks in advance!!","Other people will answer this in detail but let me tell you in short what happens. +First when you pass the command python manage.py createsuperuser you will be prompted to fill the fields mentioned in USERNAME_FIELD and REQUIERD_FIELDS, when you will fill those fields then django will call your user model manager to access your create_superuser function and then code in that will execute to return a superuser. +I hope this will help you.",1.2,True,1,6692 +2020-04-21 12:05:53.207,Stripe too many high risk payments,"I'm using the stripe subscription API to provide multi tier accounts for my users. but about 50% of the transactions that i get in stripe are declined and flagged as fraudulent. how can i diagnose this issue knowing that i'm using the default base code provided in the stripe documentation (front end) and using the stripe python module (backend). +I know that i haven't provided much information, but that is only because there isn't much to provide. the code is known to anyone who has used stripe before, and there isn't any issue with it as there are transaction that work normally. +Thank you !","After contacting stripe support, i found that many payments were done by people from an IP address that belongs to a certain location with a card that is registered to a different location. +for example if someone uses a French debit card from England. i did ask stripe to look into this issue.",1.2,True,1,6693 +2020-04-21 13:14:00.810,how to make my python project as a software in ubuntu,"I've made a python program using Tkinter(GUI) and I would like to enter it by creating a dedicated icon on my desktop (I want to send the file to my friend, without him having to install python or any interpreter). +The file is a some-what game that I want to share with friends and family, which are not familiar with coding. +I am using Ubuntu OS.","you can use pip3 install pyinstaller then use pyinstaller to convert your file to a .exe file than can run on windows using this command pyninstaller --onefile -w yourfile. +it can now run without installing anything on windows. and you can use wine to run it on ubuntu",1.2,True,1,6694 +2020-04-21 19:42:41.703,How to set attribute in nifi processor using pure Python not jython?,"How to set properties (attribute) in nifi processor using pure Python in ExecuteStreamCommand processor +I don't want to use Jython, I know it can be done using pinyapi. But don't know how to do it. I just want to create an attribute using Python script.","How to set properties(attribute) in nifi processor using pure python in ExecuteStreamCommand processor I don't want to use Jython + +You can't do it from ExecuteStreamCommand. The Python script doesn't have the ability to interact with the ProcessSession, which is what it would need to set an attribute. You'd need to set up some operations after it to add the attributes like an UpdateAttribute instance.",0.0,False,1,6695 +2020-04-22 10:04:50.737,Navigating through Github repos,"I am currently trying to find end-to-end speech recognition solutions to implement in python (I am a data science student btw). I have searched for projects on github and find it very hard to comprehend how these repositories work and how I can use them for my own project. +I am mainly confused with the following: + +how do repositories usually get used by other developers and how can I use them best for my specific issue? +How do I know if the proposed solution is working in python? +What is the usual process in installing the project from the repo? + +Sorry for the newbie question but I am fairly new to this. +Thank you","You can read the documentation(README.md) there you can have all the information you need. +You can install the project from a repo by cloning or by downloading zip.",0.0,False,1,6696 +2020-04-22 14:02:22.120,"Agent repeats the same action circle non stop, Q learning","How can you prevent the agent from non-stop repeating the same action circle? +Of course, somehow with changes in the reward system. But are there general rules you could follow or try to include in your code to prevent such a problem? + +To be more precise, my actual problem is this one: +I'm trying to teach an ANN to learn Doodle Jump using Q-Learning. After only a few generations the agent keeps jumping on one and the same platform/stone over and over again, non-stop. It doesn't help to increase the length of the random-exploration-time. +My reward system is the following: + ++1 when the agent is living ++2 when the agent jumps on a platform +-1000 when it dies + +An idea would be to reward it negative or at least with 0 when the agent hits the same platform as it did before. But to do so, I'd have to pass a lot of new input-parameters to the ANN: x,y coordinates of the agent and x,y coordinates of the last visited platform. +Furthermore, the ANN then would also have to learn that a platform is 4 blocks thick, and so on. +Therefore, I'm sure that this idea I just mentioned wouldn't solve the problem, contrarily I believe that the ANN would in general simply not learn well anymore, because there are too many unuseful and complex-to-understand inputs.","This is not a direct answer to the very generally asked question. + +I found a workaround for my particular DoodleJump example, probably someone does something similar and needs help: + +While training: Let every platform the agent jumped on disappear after that, and spawn a new one somewhere else. +While testing/presenting: You can disable the new ""disappear-feature"" (so that it's like it was before again) and the player will play well and won't hop on one and the same platform all the time.",1.2,True,1,6697 +2020-04-22 19:47:18.237,Is vectorization a hardware/framework specific feature or is it a good coding practice?,"I am trying to wrap my head around vectorization (for numerical computing), and I'm coming across seemingly contradictory explanations: + +My understanding is that it is a feature built into low-level libraries that takes advantage of parallel processing capabilities of a given processor to perform operations against multiple data points simultaneously. +But several tutorials seem to be describing it as a coding practice that one incorporates into their code for more efficiency. How is it a coding practice, if it is also a feature you have or you don't have in the framework you are using. + +A more concrete explanation of my dilemma: + +Let's say I have a loop to calculate an operation on a list of numbers in Python. To vectorize it, I just import Numpy and then use an array function to do the calculation in one step instead of having to write a time consuming loop. The low level C routines used by Numpy will do all the heavy lifting on my behalf. + +Knowing about Numpy and how to import it and use it is not a coding practice, as far as I can tell. It's just good knowledge of tools and frameworks, that's all. +So why do people keep referring to vectorization as a coding practice that good coders leverage in their code?","Vectorization can mean different things in different contexts. In numpy we usually mean using the compiled numpy methods to work on whole arrays. In effect it means moving any loops out of interpreted Python and into compiled code. It's very specific to numpy. +I came to numpy from MATLAB years ago, and APL before that (and physics/math as a student). Thus I've been used to thinking in terms of whole arrays/vectors/matrices for a long time. +MATLAB now has a lot just-in-time compiling, so programmers can write iterative code without a performance penalty. numba (and cython) lets numpy users do some of the same, though there are still a lot of rough edges - as can be seen in numpa tagged questions. +Parallelization and other means of taking advantage of modern multi-core computers is a different topic. That usually requires using additional packages. +I took issue with a comment that loops are not Pythonic. I should qualify that a bit. Python does have tools for avoiding large, hard to read loops, things like list comprehensions, generators and other comprehensions. Performing a complex task by stringing together comprehensions and generators is good Python practice, but that's not 'vectorization' (in the numpy sense).",0.5916962662253621,False,2,6698 +2020-04-22 19:47:18.237,Is vectorization a hardware/framework specific feature or is it a good coding practice?,"I am trying to wrap my head around vectorization (for numerical computing), and I'm coming across seemingly contradictory explanations: + +My understanding is that it is a feature built into low-level libraries that takes advantage of parallel processing capabilities of a given processor to perform operations against multiple data points simultaneously. +But several tutorials seem to be describing it as a coding practice that one incorporates into their code for more efficiency. How is it a coding practice, if it is also a feature you have or you don't have in the framework you are using. + +A more concrete explanation of my dilemma: + +Let's say I have a loop to calculate an operation on a list of numbers in Python. To vectorize it, I just import Numpy and then use an array function to do the calculation in one step instead of having to write a time consuming loop. The low level C routines used by Numpy will do all the heavy lifting on my behalf. + +Knowing about Numpy and how to import it and use it is not a coding practice, as far as I can tell. It's just good knowledge of tools and frameworks, that's all. +So why do people keep referring to vectorization as a coding practice that good coders leverage in their code?","Vectorization leverage the SIMD (Single Instruction Multiple Data) instruction set of modern processors. For example, assume your data is 32 bits, back in the old days one addition would cost one instruction (say 4 clock cycles depending on the architecture). Intel's latest SIMD instructions now process 512 bits of data all at once with one instruction, enabling you to make 16 additions in parallel. +Unless you are writing assembly code, you better make sure that your code is efficiently compiled to leverage the SIMD instruction set. This is being taking care of with the standard packages. +Your next speed up opportunities are in writing code to leverage multicore processors and to move your loops out of the interpreted python. Again, this is being taking care of with libraries and frameworks. +If you are a data scientist, you should only care about calling the right packages/frameworks, avoid reimplementing logic already offered by the libraries (with loops being a major example) and just focus on your application. If you are a framework/low-level code developer, you better learn the good coding practices or your package will never fly.",0.2655860252697744,False,2,6698 +2020-04-23 09:33:37.790,How to fix not updating problem with static files in Django port 8000,"So when you make changes to your CSS or JS static file and run the server, sometimes what happens is that the browser skips the static file you updated and loads the page using its cache memory, how to avoid this problem?",U have DEBUG = False in your settings.py. Switch on DEBUG = True and have fun,0.0,False,2,6699 +2020-04-23 09:33:37.790,How to fix not updating problem with static files in Django port 8000,"So when you make changes to your CSS or JS static file and run the server, sometimes what happens is that the browser skips the static file you updated and loads the page using its cache memory, how to avoid this problem?","Well there are multiple ways to avoid this problem + +the simplest way is by: + +if you are using Mac: Command+Option+R +if you are using Windows: Ctrl+F5 + + +What it does is that it re-downloads the cache files enabling the update of the static files in the browser. + +Another way is by: + +making a new static file and pasting the existing code of the previously used static file and then +running the server + + +What happens, in this case, is that the browser doesn't use the cache memory for rendering the page as it assumes it is a different file.",1.2,True,2,6699 +2020-04-23 13:21:50.967,How to monitor memory usage of individual celery tasks?,"I would like to know the max memory usage of a celery task, but from the documentations none of the celery monitoring tools provide the memory usage feature. How can one know how much memory a task is taking up? I've tried to get the pid with billiard.current_process and use that with memory_profiler.memory_usage but it looks like the current_process is the worker, not the task. +Thanks in advance.","Celery does not give this information unfortunately. With little bit of work it should not be difficult to implement own inspect command that actually samples each worker-process. Then you have all necessary data for what you need. If you do this, please share the code around as other people may need it...",0.0,False,1,6700 +2020-04-23 16:53:28.387,How can I use the PyCharm debugger with Google Cloud permissions?,"I have a simple flask app that talks to Google Cloud Storage. +When I run it normally with python -m api.py it inherits Google Cloud access from my cli tools. +However, when I run it with the PyCharm debugger it can no longer access any Google Services. +I've been trying to find a way to have the PyCharm debugger inherit the permissions of my usual shell but I'm not seeing any way to do that. +Any tips on how I can use the PyCharm debugger with apps that require access to Google Cloud?","I usually download the credentials file and set GOOGLE_APPLICATION_CREDENTIALS=""/home/user/Downloads/[FILE_NAME].json environment variable in PyCharm. +I usually create a directory called auth and place the credential file there and add that directory to .gitignore +I don't know if it is a best practice or not but it gives me an opportunity to limit what my program can do. So if I write something that may have disrupting effect, I don't have to worry about it. Works great for me. I later use the same service account and attach it to the Cloud Function and it works out just fine for me.",1.2,True,1,6701 +2020-04-24 02:29:15.327,How often should i run requirements.txt file in my python project?,Working on a python project and using pycharm . Have installed all the packages using requirements.txt. Is it a good practice to run it in the beginning of every sprint or how often should i run the requirements.txt file ?,"The answer is NO. +Let's say you're working on your project, already installed all the packages in the requirements.txt into your virtual environment, etc etc, at this point your environment is already setup. +Keep working on the project and installed a new package with pip or whatever, now your environment is ok but you're requirements.txt is not up to date, you need to update it adding the new package, but you don't need to reinstall all the packages in it every time this happens. +You only runs pip install -r requirements.txt when you want to run your project on a different virtual environment",0.0,False,1,6702 +2020-04-24 18:18:18.077,"Converting days into years, months and days","I know I can use relativedelta to calculate difference between two dates in the calendar. However, it doesn't feet my needs. +I must consider 1 year = 365 days and/or 12 months; and 1 month = 30 days. +To transform 3 years, 2 months and 20 days into days, all I need is this formula: (365x3)+(30x2)+20, which is equal to 1175. +However, how can I transform days into years, months and days, considering that the amount of days may or may not be higher than 1 month or 1 year? Is there a method on Python that I can use? +Mathemacally, I could divide 1175 by 365, multiply the decimals of the result by 365, divide the result by 30 and multiply the decimals of the result by 30. But how could I do that in Python?",You can use days%365 to get number of years from days.,-0.3869120172231254,False,1,6703 +2020-04-25 11:10:01.107,Microsoft Visual C++ 14.0 is required error while installing a python module,"I was trying to pip install netfilterqueue module with my Windows 7 system, in python 3.8 +It returned an error ""Microsoft Visual C++ 14.0 is required"" +My system already has got a Microsoft Visual C++ 14.25. Do I still need to install the 14.0, or is there a way that I can get out of this error? +If no, how do I install a lower version without uninstalling or replacing the higher version?","Alright, try uninstalling the higher version and go for the lower version making sure you download it with the same computer not with another, remembering that windows 7 no longer support some operations, and i will advice you upgrade to windows 10",0.3869120172231254,False,1,6704 +2020-04-25 16:20:35.730,how do i go back to my system python using pyenv in Ubuntu,i installed pyenv and switched to python 3.6.9 (using pyenv global 3.6.9). How do i go back to my system python? Running pyenv global system didnt work,"pyenv sets the python used according to ~/.pyenv/version. For a temporary fix, you can write system in it. Afterwards, you'll need to fiddle through your ~/.*rc files and make sure eval ""$(pyenv init -)"" is called after any changes to PATH made by other programs (such as zsh).",0.1352210990936997,False,1,6705 +2020-04-25 17:06:38.983,Advanced game made in pygame is too slow,"I've been working on a game for a month and it's quite awesome. I'm not very new to game developing. +There are no sprites and no images, only primitive drawn circles and rectangles. +Everything works well except that the FPS gets slow the more I work on it, and every now and then the computer starts accelerating and heating up. +My steps every frame (besides input handling): + +updating every object state (physics, collision, etc), around 50 objects some more complex than the other +drawing the world, every pixel on (1024,512) map. +drawing every object, only pygame.draw.circle or similar functions + +There is some text drawing but font.render is used once and all the text surfaces are cached. +Is there any information on how to increase the speed of the game? +Is it mainly complexity or is there something wrong with the way I'm doing it? There are far more complex games (not in pygame) that I play with ease and high FPS on my computer. +Should I move to different module like pyglet or openGL? +EDIT: thank you all for the quick response. and sorry for the low information. I have tried so many things but in my clumsiness I heavent tried to solve the ""draw every pixel every single frame proccess"" I changed that to be drawn for changes only and now it runs so fast I have to change parameters in order to make it reasonably slow again. thank you :)","Without looking at the code its hard to say something helpful. +Its possible that you got unnecessary loops/checks when updating objects. +Have you tried increasing/decreasing the amount of objects? +How does the performance change when you do that? +Have you tried playing other games made with pygame? +Is your pc just bad? +I dont think that pygame should have a problem with 50 simple shapes. I got some badly optimized games with 300+ objects and 60+ fps (with physics(collision, gravity, etc.)) so i think pygame can easily handle 50 simple shapes. You should probably post a code example of how you iterate your objects and what your objects look like.",1.2,True,1,6706 +2020-04-26 18:20:13.677,Are there any other ways to share / run code?,"So I just created a simple script with selenium that automates the login for my University's portal. The first reaction I got from a friend was: ah nice, you can put that on my pc as well. That would be rather hard as he'd have to install python and run it through an IDE or through his terminal or something like that and the user friendliness wouldn't be optimal. +Is there a way that I could like wrap it in a nicer user interface, maybe create an app or something so that I could just share that program? All they'd have to do is then fill in their login details once and the program then logs them in every time they want. I have no clue what the possibilities for that are, therefore I'm asking this question. +And more in general, how do I get to use my python code outside of my IDE? Thusfar, I've created some small projects and ran them in PyCharm and that's it. Once again, I have no clue what the possibilities are so I also don't really know what I'm asking. If anyone gets what I mean by using my code further than only in my IDE, I'd love to hear your suggestions!","The IDE running you program is the same as you running your program in the console. But if you dont want them to have python installed (and they have windows) you can maybe convert them to exe with py2exe. But if they have linux, they probably have python installed and can run you program with ""python script.py"". But tell your friends to install python, if they program or not, it will always come in handy",0.3869120172231254,False,1,6707 +2020-04-27 17:40:11.477,Modular python admin pages,"I'm building a personal website that I need to apply modularity to it for purpose of learning. What it means is that there is a model that contains x number of classes with variations, as an example a button is a module that you can modify as much depending on provided attributes. I also have a pages model that need to select any of created modules and render it. I can't find any documentation of how to access multiple classes from one field to reference to. +Model structure is as below: + +Modules, contains module A and module B +Pages should be able to select any of module A and order its structure. + +Please let me know if not clear, this is the simplest form I could describe. Am I confusing this with meta classes? How one to achieve what I'm trying to achieve?","I ended up using Proxy models but will also try polymorphic approach. This is exactly what is designed to do, inherit models from a parent model in both one to many and many to many relationships.",1.2,True,1,6708 +2020-04-27 18:30:21.580,"How to deploy changes made to my django project, which is hosted on pythonanywhere?","I am new to git and Pythonanywhere. So, I have a live Django website which is hosted with the help of Pythonanywhere. I have made some improvements to it. I have committed and pushed that changes to my Github repository. But, now I don't know that how to further push that changes to my Pythonanywhere website. I am so confused. Please help!!! Forgive me, I am new to it.","You need to go to the repo on PythonAnywhere in a bash console, run git pull (You may need to run ./mange.py migrate if you made changes to your models) and then reload the app on ""Web"" configuration page on PythonAnywhere. .",1.2,True,1,6709 +2020-04-30 04:45:05.280,How is variable assignment implemented in CPython?,"I know that variables in Python are really just references/pointers to some underlying object(s). And since they're pointers, I guess they somehow ""store"" or are otherwise associated with the address of the objects they refer to. +Such an ""address storage"" probably happens at a low level in the CPython implementation. But +my knowledge of C isn't good enough to infer this from the source code, nor do I know where in the source to begin looking. +So, my question is: +In the implementation of CPython, how are object addresses stored in, or otherwise associated with, the variables which point to them?","In module scope or class scope, variables are implemented as entries in a Python dict. The pointer to the object is stored in the dict. In older CPython versions, the pointer was stored directly in the dict's underlying hash table, but since CPython 3.6, the hash table now stores an index into a dense array of dict entries, and the pointer is in that array. (There are also split-key dicts that work a bit differently. They're used for optimizing object attributes, which you might or might not consider to be variables.) +In function scope, Python creates a stack frame object to store data for a given execution of a function, and the stack frame object includes an array of pointers to variable values. Variables are implemented as entries in this array, and the pointer to the value is stored in the array, at a fixed index for each variable. (The bytecode compiler is responsible for determining these indices.)",1.2,True,1,6710 +2020-04-30 09:44:08.403,How to access Flask API from Flask Frontend?,"I am using Blueprints to create two separate modules, one for api and one for website. My APIs have a route prefix of api. Now, I am having a route in my website called easy and it will be fetching a JSON from a route in api called easy and it's route is /api/easy. +So, how can i call /api/easy from /easy. +I have tried using requests to call http:localhost:5000/api/easy and it works fine in development server but when I am deploying it on Nginx server, it fails probably because I am exposing port 80 there. +When I deploy my webapp on nginx, it show up perfectly just that route /easy throws Internal Server Error.","Okay so what worked for me is I simply ended up calling the api function from the frontend rather than doing the POST requests. Obviously, it makes no sense creating backend routes for flask seperately when you are using Flask too in frontend. Simply, a seperate utility function would be fine.",1.2,True,1,6711 +2020-05-01 14:00:39.287,How to acknowledge the waypoints are done [DJI ROS Python],"I have DJI M600 Drone and I'm using ROS DJI SDK on Raspberry PI to communicate with it. +I can successfully send waypoint commands and execute them. However, I don't know how to acknowledge that the waypoints are finished. What comes to my mind is that I can check where the drone is in order to compare it with the coordinates I sent. The second solution might be to check how many waypoints are left (haven't tried it yet). +I wonder if there is a topic that I can subscribe to so that I can ask if the waypoints are completed. What is the proper way to do that? +Thanks in advance, +Cheers","I use a different SDK so can't help with code example but I think you need to look into: +the wayPointEventCallback and wayPointCallback.",1.2,True,1,6712 +2020-05-01 23:28:20.050,Does pywin32 install cause any changes to registry settings that could affect MAPI,"I recently installed pywin32 at a client site and after this occurred, they started experiencing MAPI errors. I cannot see how the install would have had any effect on their emails. pywin32 was simply installed with no errors. I am a novice with Python so I apologise if there is not enough detail or for the lack of understanding on my part. +Pywin32 was installed on remote desktop and the error they were receiving around this time was ""241938E error - can't open default message store (MAPI)"". The actual python script using win32.com makes no use of MAPI (simply used for word application tasks) and worked without any issues. +The IT firm for the client wants to know if pywin32 causes any changes to registry settings that could have impacted them and caused this error? Incidentally, they had an office365 change around the same time. I think the 'finger pointing' is more in that direction but I do need to rule out any related registry setting changes that pywin32 may make on install that could have caused or contributed to the problem they were experiencing.",SOLVED: Problem found to be a Microsoft error - reported April 27,0.3869120172231254,False,1,6713 +2020-05-02 12:55:13.677,Python: Extracting Text from Applications?,"I spend each month a lot of time extracting numbers from an application into an Excel-spreadsheet where our company saves numbers, prices, etc. This application is not open-source or so, so unfortunately, sharing the link might not help. +Now, I was wondering whether I could write a Python program that would do this for me instead? But I'm not sure how to do this, particularly the part with extracting the numbers. Once this is done, transfering this to an Excel spreadsheet is particularly trivial.","1)For this you can create a general function like getApplicationError(), +2)in this method you can get the text of the Application Error(create xpath of the application error, and check that if that element is visible than get text) and throw an exception to terminate the Script and you can send that got message into Exception constructor and print that message with Exception. +As you are creating this method for general use so you need to call this method every posible place from where the chances are to get Application Error. like just after click(Create,Save,Submit,Delet,Edit, also just entering value in mendatory Fields)",0.0,False,1,6714 +2020-05-02 14:39:50.133,NiFi Parse PDF using Python Tika error: ExecuteStreamCommand,"I'm trying to do the following, but I'm getting errors on my ExecuteStreamCommand: +Cannot run program ""C:\Python36\pythonscript.py"" error=193 not a valid Win32 application"" +This is being run on my home Windows work station. + +GetFile (Get my PDF) +ExecuteStreamCommand (Call Python script to parse PDF with Tika, and create JSON file) +PutFile (Output file contains JSON that I will use later) + +Does NiFi have a built in PDF parser? Is there something more NiFi compatible that Tika? +If not, how do I call one from ExecuteStreamCommand? +Regards and thanks in advance!","Cannot run program ""C:\Python36\pythonscript.py"" error=193 not a valid Win32 application"" + +You need to add a reference to your Python executable to the command to run with ExecuteStreamCommand as you cannot run Python scripts on Windows with the shebang (#!/usr/bin/python for example on Linux).",0.0,False,1,6715 +2020-05-02 16:30:41.347,How can i get someone telegram chat id with python?,"Hi everyone i want to create a new telegram bot similar to @usinifobot. +this is how it works: +you just send someone username to this bot and it will give you back his/her chat id. +i want to do same thing but i dont khow how to do it with python-telegram-bot.","python-telegram-bot can't help with this, because telegram bot api can't provide ids of unrelated entities to the bot - only ones with which bot iteracts +you need telegram client api for this and to hold a real account (not a bot) online to make checks by another library +and with bot library like python-telegram-bot you could only get ids of users who write to bot, channels and groups bot is in and reposted messages from other users +I created similar bot @username_to_id_bot for getting ids of any entity and faced all these moments",0.0,False,1,6716 +2020-05-02 16:39:53.077,Image not loading on mobile device,"I have an app that includes some images, however when I package for my android phone the images are blank. Right now in my kv file, the images are being loaded from my D drive, so how would I get them to load on my phone?",Include the images during the packaging and then load them using a file path relative to your main.py.,0.0,False,1,6717 +2020-05-02 20:44:09.857,What options are there to setup automatic reporting processes for Pandas on AWS?,"I'm currently using elastic beanstalk and apscheduler to run Pandas reports everyday automatically on it. The data set is getting larger and i've already increased the memory size 3x. +Elastic Beanstalk is running Dash - dashboard application and runs the automated Pandas reports once every night. +I've tried setting up AWS Lambda to run Pandas reports on there but I couldn't figure out how to use it. +I'm looking for the most cost-effective way to run my reports without having to increase memory usage on Beanstalk. When I run it locally it takes 1gb but running it on beanstalk, it's using more than 16gb. +Curious if someone else has a better option or process how they automatically run their Pandas reports.","Create an .exe using Pyinstaller +Schedule .exe on Task Scheduler on computer +Cheaper than scaling AWS Beanstalk resources which use more resources calculating pandas than your computer locally at least for my case.",0.0,False,1,6718 +2020-05-03 11:20:16.410,"How to estimate the optimal model, following from the granger causality test?","Suppose I run the GC-test: +grangercausalitytests(np.vstack((df['target'], df['feature'])).T, maxlag=5) +I can pick the lag of the ""feature"" variable, which most likely Granger-causes the ""target"" variable. + +But what number of lags does the ""target"" variable have in this model? +Further, how do I estimate this ADL model (some autoregressive lags + some lags of the independent variable)? I've seen somewhere, that ADL should be substituted with OLS/FGLS in Python, since there is no package for ADL. Yet I do not understand how to do that","I found out that the model, corresponding to each particular number +of lags in the GC-test has already been fit and is contained in the +test return. The output looks messy, but it's there. +Unfortunately, +there seems to be no capacity to estimate ADL models in Python yet +:(",1.2,True,1,6719 +2020-05-03 19:56:51.107,Updating code for my application every week,"I’m creating a bot app in python using selenium, for people, but I would need to change the xpath code every week, how do I do this once I distribute the app to people? +Thanks In advance","I think the best approach is to locate selectors using Id rather than XPath since there won't be any change to Id selector once a new feature(adding a table/div to the HTML)is added. Also, this reduces the rework effort to a large extend.",0.0,False,1,6720 +2020-05-03 20:50:01.953,How to managing a large number of clients in the socket programming,"In examples, I saw of socket programming projects (most of which were chat projects), they often saved all the clients in one array, and when a message was received from a client, in addition to saving it in the database, to all clients also was sent. +The question that comes to my mind is: How can this message received from the client and saved in the database and send to clients when number of clients is very large? (I mean, the number of customers is so large that a single server can't meet their demand alone, and several servers are needed to connect sockets). +In this case, not all clients can be managed through the array. So how do you transfer a message that is now stored on another server (by another customer) to a customer on this server? (Speed ​​is important). +Is there a way to quickly become aware of database changes and provide them to the customer? (For example, Telegram.) +I'm looking for a perspective, not a code.","You should use your database as your messaging center. Have other servers watch for changes in the database either by subscription or by pulling on a time interval. Obviously subscription would be fastest possible. +When a message is inserted, each server picks this up and sends to their list of clients. This should be quite fast for broadcasting messages.",1.2,True,1,6721 +2020-05-03 23:39:19.313,Command payload validation in event sourced micro-service architecture,"I am confused about how to realize the data validation in event sourced micro-service architecture. +Let sum up some aspects that related to the micro-services. +1. Micro-services must be low coupled. +2. Micro-services better to be domain oriented +Then due to tons of materials in the internet and the books in DDD (Domain Driven Design) +I create the next event sourced micro-service architecture. +Components +1. API getaway to receive the REST calls from the clients and transform them into the commands. +2 Command handler as a service. Receive the commands from API getaway make the validations. Save the events to the event store and publish events to the event bus. +3. Event store is the storage for all events in the system. Allows us to recreate the state of the app. The main state of truth. +4. Micro-services is small services responsible to handle the related to its domain event. Make some projections to the local private databases. Make some events too. +And I have questions that I could not answer both by myself and the internet. +1. What is actually aggregates. They are the class objects/records in databases as I think or what? +2. Who carry about aggregates. I found example that is some cases command handler use them. But in that way if aggregates stored in the private micro-services databases then we will have very high coupling between the command handler and the each of micro-services and it is wrong due to micro-service concept. +To sum up. +I am confused about how to implement aggregation in event source micro service architecture. +For example let focus on the user registration implementation in event source micro-service architecture. +We have the user domain so the architecture will be next. +API getaway +Command handler +Auth micro-service +User micro-service +Please explain me the realization of command validation due to example above.","Command handler as a service + +I think this is the main source of your confusion. +The command handler isn't normally a service in itself. It is a pattern. It will normally be running in the same process as the ""microservice"" itself. +IE: the command handler reads a message from so storage, and itself invokes the microservice logic that computes how to integrate the information in this message into its own view of the world. + +What is actually aggregates + +""Aggregate"" is a lifecycle management pattern; an aggregate is a graph of one or more domain entities that together will establish and maintain some interesting invariant. It's one of three patterns described in detail in the Domain Driven Design book written by Eric Evans. +The command handler plus your aggregate is, in a sense, your microservice. The microservice will typically handle messages for several instances of a single aggregate - it will subscribe to all of the input messages for that kind of aggregate. The ""handler"" part just reads the next message, loads the appropriate instance of the aggregate, then executes the domain logic (defined within the aggregate entities) and stores the results.",0.3869120172231254,False,1,6722 +2020-05-04 07:09:36.600,List Comprehension to remove unwanted objects. Validating it works as expected,"I'm using Python 3. I am trying to remove certain lists from a list of lists. I found an excellent article that explained how to do that using list comprehension. It appears to work as expected, but it got me thinking ... In my original efforts I was appending any list object that was to be deleted to a new list. I could then actually look at these objects and assure myself the right ones were being removed. With the comprehension method I can only ""see"" the ones that remain. Is there a way of ""seeing"" what's ""failed"" the list comprehension condition? It would be reassuring to know that only the correct objects gave been removed.","I actually managed to answer my own question by making a mistake. To see what will be removed from a list by the list comprehension, simply temporarily invert the condition logic. This will allow you to look at all the elements that will be removed. If you're happy that the removals are as you expect, then simply re-invert the logic again, back to original and execute.",0.0,False,1,6723 +2020-05-04 07:38:36.543,Installing python 3.5 or higher in a virtual environment on a raspberry pi,"I am new to this, so apologize if the step is easy. +I have a Device which I am programming, which uses a raspberry pi (Debian). I have connected via SSH using PuTTY. +I wish to create a virtual environment, and test a program on the device to search the WiFi network SSIDs and pick them up. I found that a great package to use is wpa_supplicant. +However, here is the problem: +The device currently has Python 2.7.9 on it. When ever I create a virtual environment using python3, it creates a venv with python 3.4. Unfortunately, wpa_supplicantm requires python 3.5 or higher to work. +When I run sudo apt-get install python3-venv, I can see in the prompt that it automatically starts installing packages for python3.4. +Does anyone know how I can specify that I wish to install python 3.5 or 3.7? +Any help would be greatly appreciated. +Regards +Scott","Does it not have the python3.7 command? +I just checked a venv I have running on a 3b+ and it seems to have it.",0.0,False,1,6724 +2020-05-04 12:17:02.553,import sqlite3.dll from from another file location python,"I new to python but how do I import the sqlite3.dll file from a custom file location as I can't find anything about it. I can accept any option including building a new pyd,dll,etc file. +Edit: +I need it to be in a separate location.","Note: The following answers the above question with more thorough steps. +I had the same issue as administrative rights to the default python library is blocked in a corporate environment and its extremely troublesome to perform installations. +What works for me: + +Duplicate the sqlite3 library in a new location +Put in the latest sqlite3.dll (version you want from sqlite3 web) and the old _sqlite3.pyd into the new location or the new sqlite3 library. The old _sqlite3.pyd can be found in the default python library lib/DLLs folder. +Go to the new sqlite3 library and amend the dbapi2.py as follows: Change ""from _sqlite3 import *"" to ""from sqlite3._sqlite3 import *"" +Make sure python loads this new sqlite3 library first. Add the path to this library if you must.",0.0,False,1,6725 +2020-05-04 13:11:48.527,How do i check if the elements in a list are contained in other list?,"I´m new to Python and I´m having a problem. I have 2 lists containing the names of the columns of a dataset: one has all the columns names (columnas = total.columns.values.tolist()); and the other one has a subset of them ( in the form of ""c = [a,b,c,d,c,e,...]"". +I would like to know how could I check if each element in ""c"" is contained in the longer list ""columnas"". The result i have been trying to get is as it follows ( this is just an example): +a: True +b: True +c: False +... +Looking forward to your answers, Santiago","a=[ ] +for i in c: + if i in columns: + a.append(true) + else: + a.append(false) +a=[ ] +for i in c: + if i in columns: + a.append(true) + else: + a.append(false)",0.2012947653214861,False,1,6726 +2020-05-04 15:25:36.053,Why does deleting a variable assigned to another variable not influence the new variable?,"If I do li = [1,2,3], and then do a = li, a is assigned to li, right? However, when I do del li and then print a, it still shows [1,2,3]. When I do li.append(4) and print a then, why does it show [1,2,3,4]? +I understand that a didn't make a copy of li (as the .copy() method is used for that), but why would a still show the value li used to have?","del does not delete the variable. del only deletes the name, and the garbage collector will (on its own time) search for variables that aren't referenced by anything, and properly deallocate their memory. +In this case, you're assigning the name a to reference the same variable that the name li is referencing. When you use .append(), it modifies the variable, and all names referencing the variable will be able to see the change. And when you do del li to remove the name li, it doesn't remove the name a, which is still referencing the variable. Thus, the variable doesn't get deallocated and removed.",0.3869120172231254,False,1,6727 +2020-05-05 01:52:32.367,Splitting a Large S3 File into Lines per File (not bytes per file),"I have an 8 GB file with text lines (each line has a carriage return) in S3. This file is custom formatted and does NOT follow any common format like CSV, pipe, JSON ... +I need to split that file into smaller files based on the number of lines, such that each file will contains 100,000 lines or less +(assuming the last file can have the remainder of the lines and thus may have less than 100,000 lines). + +I need a method that is not based on the file size (i.e. bytes), but the number of lines. Files can't have a single line split across the two. +I need to use Python. +I need to use server-less AWS service like Lambda, Glue ... I can't spin up instances like EC2 or EMR. + +So far I found a lot of posts showing how to split by byte size but not by number of lines. +Also, I do not want to read that file line by line as it will be just too slow an not efficient. +Could someone show me a starter code or method that could accomplish splitting this 6 GB file that would +run fast and not require more than 10 GB of available memory (RAM), at any point? +I am looking for all possible options, as long as the basic requirements above are met... +BIG thank you! +Michael","boto3.S3.Client.get_object() method provides object of type StreamingBody as a response. +StreamingBody.iter_lines() method documentation states: + +Return an iterator to yield lines from the raw stream. +This is achieved by reading chunk of bytes (of size chunk_size) at a + time from the raw stream, and then yielding lines from there. + +This might suit your use case. General idea is to get that huge file streaming and process its contents as they come. I cannot think of a way to do this without reading the file in some way.",0.3869120172231254,False,1,6728 +2020-05-05 09:27:57.100,Is there any way to use the python IDLE Shell in visual studio code?,"I was programming python in Visual Studio Code and every time that I ran something it would use the integrated terminal (logically, because I have not changed any settings) and I was wondering, how could I get it to use the Python IDLE's shell instead of the integrated terminal (which for me is useless)? +I have also got Python IDLE installed in my mac but due to Visual Studio Code having ""intellisense"", it is way easier.","In VS Code you should be able to select the file which is supposed to be used in the terminal. +Under : +Preferences -> Settings -> Terminal",0.0,False,1,6729 +2020-05-05 12:56:51.043,How to work with virtual environment and make it default,"I have created a virtual environment named knowhere and I activate it in cmd using code .\knowhere\Scripts\activate. I have installed some libraries into this environment. +I have some python scripts stored on my pc. When I try to run them they are not working since they are not running in this virtual environment. Now how to make these scripts run. +Also is there any way to make ""knowhere"" as my default environment.","Virtual environments are only necessary when you want to work on two projects that use different versions of the same external dependency, e.g. Django 1.9 and Django 1.10 and so on. In such situations virtual environment can be really useful to maintain dependencies of both projects. +If you simply want your scripts to use Python libraries just install them on your system and you won't have that problem.",1.2,True,1,6730 +2020-05-05 14:28:18.167,Pandas/Dask - Very long time to write to file,"I have a few files. The big one is ~87 million rows. I have others that are ~500K rows. Part of what I am doing is joining them, and when I try to do it with Pandas, I get memory issues. So I have been using Dask. It is super fast to do all the joins/applies, but then it takes 5 hours to write out to a csv, even if I know the resulting dataframe is only 26 rows. +I've read that some joins/applies are not the best for Dask, but does that mean it is slower using Dask? Because mine have been very quick. It takes seconds to do all of my computations/manipulations on the millions of rows. But it takes forever to write out. Any ideas how to speed this up/why this is happening?",You can use Dask Parallel Processing or try writing into Parquet file instead of CSV as Parquet operation is very fast with Dask,0.0,False,1,6731 +2020-05-05 16:01:09.690,Combining C with Python,"I'd like to mix C code with Python GUI libraries. I thought about creating C library and using it with ctypes. How to create library for both Linux and Windows at the same time? On Linux, I simply use gcc -fPIC -shared -o lib.so main.c, but how to do that for Windows?","Many IDE for C/C++ already prepared DLL program template,such as Visual Studio,Code::Blocks,VC++6.0 etc.. Using DLL files is similar to using SO files",-0.3869120172231254,False,1,6732 +2020-05-06 05:20:34.160,How to use multimetric python library for calculating code parameters?,"I am working on project which deals with calculation of halsted matrix and mccabe cyclomatic complexity for the codes in various languages. I found this library multimeric but its documentation is not intuitive. Please explain to me how to use this library for finding code metrics. +if you know any other library which does this work then please suggest.","install multimetric follow the instruction from PyPI. go to the code(example.py) location. e.g. cd /user/Desktop/code +Then type these in terminal: +multimetric example.py +then you can see the result.",0.3869120172231254,False,1,6733 +2020-05-06 07:01:59.710,Passing authorization code to Python Notebook,"As I am trying to connect to Google's BigQuery environment from a Python notebook using the google.cloud library, the response from the server is to visit a link that generates a code and to ""Enter the authorization code:"" . However, as this response is just text, I do not know how to pass the code back to the server response. I am running this notebook in a Databricks environment. +Does anyone know how I can push this code back to the server and complete the authorization?",It doesnn't look like you are using the correct . The flow which you mentioned will work on a UI not not with any automation . I suggest you to share more dtails here and also check for more documenataion on the same .,0.0,False,1,6734 +2020-05-06 13:48:33.700,Python pptx - pass html formatted text to paragraph in powerpoint,"I have string with html tags and I would like to pass formatting to power point. +The only idea I have now is to split it using some xml library and add bunch of ifs adding formatting to run depending on a tag. +Did you encounter similar problem or have better idea how to approach it?","I don't think there is a method of doing this. For a start, some HTML elements and attributes aren't likely to translate. +I've done a very limited amount of this - and actually it was mostly Markdown I was translating. (The HTML relevance is that I did work with entity references and also
.) +I'm sorry to say my code is useless to you. +My advice would be to support a small subset of HTML. Perhaps with some limited styling and things like
.",0.3869120172231254,False,1,6735 +2020-05-07 13:35:13.030,how do i divide a number by two multiple times,"Can you help me help my son with python homework? +His homework this week is on iteration. We've worked through most of it, but we can't make much headway with the following: +""• Write a program that will ask a user to enter a number between 1 and 100. The program should keep dividing the number by 2 until it reaches a number less than 2. The program should tell the user how many times it had to divide by 2. "" +Can you help us with this, and preferably include some # lines in the code so we can better understand what's happening?","Great that you're helping your son with his homework! Very exciting! +If I summarize the question, it is: + +take a number n +divide it by 2 +repeat step 2 until your number is less than 2 +output how often it had to be divided + +Let's do this by hand: + +I take a number, 15: +I divide once, I get 7.5 +it's not less than 2, so I continue +I divide by 2 again (2 times total), I get 3.75 +it's not less than 2, so I continue +I divide by 2 again (3 times total), I get 1.875 +it's less than 2, so I stop + +I had to divide by three times total. +If you were to take these steps and write it in code, how would you do this? (Hint: use a while loop!)",0.9866142981514304,False,1,6736 +2020-05-08 16:25:25.377,Why is my python discord bot suddenly duplicating responses to commands,"Some people were using my bot on a server I am a part of, and for some reason, the bot suddenly started duplicating responses to commands. Basically, instead of doing an action once, it would do it twice. I tried restarting it multiple times which didn't work, and I know it isn't a problem with my code because it was working perfectly well a few seconds ago. It probably wasn't lag either, because only a couple of people were using it. Any ideas on why this may be and how to fix it? I am also hosting it on repl.it, just so you know what ide Im using",Its probably because you run the script and run the host at them same time so it sends the command thorught host and code. If you dont run the code but just the host and it still dupliactes it might be an error with the host or it runs somewhere else in the backround.,0.0,False,1,6737 +2020-05-09 10:23:55.847,Prevent the user with session from entering the URL in browser and access the data in Python Django Application,"I have a Python Django web application. +In Get method how to prevent the user from entering url and access the Data. +How do i know weather the url accessed by Code or Browser. +I tried with sessionid in Cookie, But if session exist's it allow to access the data. +Thanks.","To detect if request is from browser, you can check HTTP_USER_AGENT header +request.META.get(""HTTP_USER_AGENT"")",0.0,False,2,6738 +2020-05-09 10:23:55.847,Prevent the user with session from entering the URL in browser and access the data in Python Django Application,"I have a Python Django web application. +In Get method how to prevent the user from entering url and access the Data. +How do i know weather the url accessed by Code or Browser. +I tried with sessionid in Cookie, But if session exist's it allow to access the data. +Thanks.","I achieve it by +if 'HTTP_REFERER' not in request.META: +it not exist's when hit directly from browser url.",0.0,False,2,6738 +2020-05-09 19:15:59.793,How to add a Spacy model to a requirements.txt file?,"I have an app that uses the Spacy model ""en_core_web_sm"". I have tested the app on my local machine and it works fine. +However when I deploy it to Heroku, it gives me this error: +""Can't find model 'en_core_web_sm'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory."" +My requirements file contains spacy==2.2.4. +I have been doing some research on this error and found that the model needs to be downloaded separately using this command: +python -m spacy download en_core_web_sm +I have been looking for ways to add the same to my requirements.txt file but haven't been able to find one that works! +I tried this as well - added the below to the requirements file: +-e git://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz#egg=en_core_web_sm==2.2.0 +but it gave this error: +""Cloning git://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz to /app/.heroku/src/en-core-web-sm +Running command git clone -q git://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz /app/.heroku/src/en-core-web-sm +fatal: remote error: + explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz is not a valid repository name"" +Is there a way to get this Spacy model to load from the requirements file? Or any other fix that is possible? +Thank you.","Ok, so after some more Googling and hunting for a solution, I found this solution that worked: +I downloaded the tarball from the url that @tausif shared in his answer, to my local system. +Saved it in the directory which had my requirements.txt file. +Then I added this line to my requirements.txt file: ./en_core_web_sm-2.2.5.tar.gz +Proceeded with deploying to Heroku - it succeeded and the app works perfectly now.",1.2,True,1,6739 +2020-05-10 05:44:15.673,How to be undetectable with chrome webdriver?,"I've already seen multiple posts on Stackoverflow regarding this. However, some of the answers are outdated (such as using PhantomJS) and others didn't work for me. +I'm using selenium to scrape a few sports websites for their data. However, every time I try to scrape these sites, a few of them block me because they know I'm using chromedriver. I'm not sending very many requests at all, and I'm also using a VPN. I know the issue is with chromedriver because anytime I stop running my code but try opening these sites on chromedriver, I'm still blocked. However, when I open them in my default web browser, I can access them perfectly fine. +So, I wanted to know if anyone has any suggestions of how to avoid getting blocked from these sites when scraping them in selenium. I've already tried changing the '$cdc...' variable within the chromedriver, but that didn't work. I would greatly appreciate any ideas, thanks!","Obviously they can tell you're not using a common browser. Could it have something to do with the User Agent? +Try it out with something like Postman. See what the responses are. Try messing with the user agent and other request fields. Look at the request headers when you access the site with a regular browser (like chrome) and try to spoof those. +Edit: just remembered this and realized the page might be performing some checks in JS and whatnot. It's worth looking into what happens when you block JS on the site with a regular browser.",0.3869120172231254,False,1,6740 +2020-05-10 12:01:13.383,"Allow End User To Add To Model, Form, and Template Django","Is there anything that someone could point me towards (a package, an example, a strategy, etc) of how I could implement the ability for an end user of my app to create a new field in a model, then add that model field to a model form and template? I’m thinking of the way that Salesforce allows users to add Custom fields. +I don’t really have any start point here I am only looking to learn if/how this might be possible in Django. +Thanks!","I'm also looking for same type of solution. But with some research, I came to know that we have this using ContentTypes framework. +How to do it? We can utilize ContentType's GenericForeignKeys and GenericRelations.",0.0,False,1,6741 +2020-05-11 16:59:06.173,Python - save BytesIO in database,"So I am trying to create a binary file and save it into my database. I am using REDIS and SQLALCHEMY as a framework for my database. I can use send_file to send the actual file whenever the user accesses a URL but how do I make sure that the file is saved in the route and it could stay there every time a user accesses the URL. + +I am sending the file from a client-python it's not in my + directory + +what I need in a nutshell is to save the file from the client-python to a database to ""downloadable"" it to the browser-client so it would actually be available for the browser-client is there any way of doing this? Maybe a different way that I didn't think about","I had to encode the data with base64, send it to the database and then decode it and send the file as binary data.",1.2,True,1,6742 +2020-05-12 11:13:21.930,How to use html file upload method for google site verification for a flask app,"The pretty straight forward way to do this is to upload the google-provided.html file to the root folder of your app on the server. But how to do it for a flask application? +For example, I have a flask app running on heroku and I want to do the site verification for my app using html file upload method(though alternative methods are available). I tried uploading the google-provided.html in the templates folder. Verification failed! +I have searched the internet but found no relevant answers.","Everything mentioned in the above answer is correct. But, just make sure that you don't rename the file given from google search console. Use the same name as it is.",-0.2012947653214861,False,1,6743 +2020-05-12 21:08:40.313,How do I open the 'launch.json' file in Visual Studio Code?,"I am a new programmer that started learning Python, but there's something bothering me which I'd like to change. +As I've seen that it is possible to remove the unwanted path from the terminal when executing code, I cannot figure out how to access the Visual Studio Code launch.json file and all of the explanations on Google are quite confusing.","Note that if Visual Studio Code hasn't created a launch.json file for your project yet, do the following: + +Click the Run | Add Configuration menu option, and one will automatically be generated for you, and opened in the editor.",0.3869120172231254,False,1,6744 +2020-05-13 01:59:52.960,How to install Beautiful Soup 4 without *any* assumptions,"I need to install Beautiful Soup 4, but every tutorial or list of instructions seems to assume I know more than I do. I am here after a number of unsuccessful attempts and at this point I am afraid of damaging something internally. +Apparently I need something called pip. I have Python 3.8, so everyone says I should have pip. Great. I have found no less than 14 different ways to check if I actually have pip and am using it. They all say to type something. One of them said to type pip --version. We are already assuming too much. Where do I type it? IDLE? The Cmd prompt? The Python shell? What folder do I need to be in? Etc Etc. I need someone to assume I am a complete beginner. +Then, how do I use it to install bs4? Again, I am supposed to type things, but no one says where. One person said to go to the folder where python is installed in the command line. So, I did, and surprise surprise, pip is not ""valid syntax"". How can I proceed with this?","With a little help from the kind user Tenacious B, I have solved my problem, I think. In the command prompt, I needed to type +cd C:\Users\%userprofilenamegoeshere%\AppData\Local\Programs\Python\Python38-32\scripts +No source that I found in my initial search included that last bit: \scripts. From here, the common suggestion of pip install beautifulsoup4 seems to have worked.",0.0,False,1,6745 +2020-05-13 07:06:12.187,Run multiple python version on SQL Server (2017),"Is it possible to run multiple Python versions on SQL Sever 2017? +It is possible to do on Windows (2 Python folders, 2 shortcuts, 2 environment paths). But how to launch another Python version if I run Python via sp_execute_external_script in SQL Management Studio 18? +In SQL server\Launchpad\properties\Binary path there is the parameter -launcher Pythonlauncher. Probably, by changing this, it is possible to run another Python version. +Other guess: to create multiple Python folders C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\PYTHON_SERVICES. But how to switch them? +Other guess: in C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Binn\pythonlauncher.config - in PYTHONHOME and ENV_ExaMpiCommDllPath parameters substitute the folder C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\PYTHON_SERVICES\ with the folder with new Python version.","The answer is: + +Copy in + + +C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\ + +folder as many Python versions as you want (Python version = folder with Python like PYTHON_SERVICES) + +Stop Launchpad +Change in + + +C:\Program Files\Microsoft SQL + Server\MSSQL14.MSSQLSERVER\MSSQL\Binn\pythonlauncher.config + +file: in PYTHONHOME and ENV_ExaMpiCommDllPath parameters substitute the folder + +C:\Program Files\Microsoft SQL + Server\MSSQL14.MSSQLSERVER\PYTHON_SERVICES\ + +with the folder with new Python version. + +Start Launchpad",0.3869120172231254,False,1,6746 +2020-05-13 14:06:05.600,"What do I do when the terminal says ""Check the logs for full command output""?","When I type pip install pygame or pip3 install pygame on terminal, it says ""check the logs for full command output"". I already upgraded pip and it still says that. Can you tell me what this means and how to fix it?","You can try running the pip command by adding the --verbose flag. This will print out the logs in the Terminal, which you then can inspect. These logs often help you indicate the cause of the error. +For example: +pip install --verbose pygame +or +pip3 install --verbose pygame",0.3869120172231254,False,2,6747 +2020-05-13 14:06:05.600,"What do I do when the terminal says ""Check the logs for full command output""?","When I type pip install pygame or pip3 install pygame on terminal, it says ""check the logs for full command output"". I already upgraded pip and it still says that. Can you tell me what this means and how to fix it?","When you get this message, there will be a few lines above it which tell you where the log file is and some more details about what went wrong.",0.0,False,2,6747 +2020-05-13 16:21:22.403,Use pipenv whenever possible in vscode,"How could I force vscode to always find and prefer pipenv's virtual environment for python instead of the python's global settings? +When I create a pipenv environment on my workspace, it keeps using the global python version at /usr/bin/python (as defined in settings as ""python.pythonPath"": ""/usr/bin/python"") but I wonder how could I switch to something like ~/.local/share/virtualenvs/Selenium-10eAXqZ4/bin/python automatically when there is Pipenv environment detected. +Is this even possible? If this is how can I configure it? +(I'm not talking about simply overriding the python.pythonPath with local .vscode/settings.json I need this to detect the path from pipenv automatically when it exists for the current project)",Add PIPENV_VENV_IN_PROJECT=1 to your environment and the .venv folder will be added to your project root. VSCode has zero problems picking up Python from there. (I find it also very convenient to have everything in one place and not spread around on the entire disk.),1.2,True,1,6748 +2020-05-13 17:15:13.727,How to speed up large data frame joins in Spark,"I have 2 dataframes in Spark 2.4, they are close to the same size. Each has about 40 million records. One is generated simply by loading the dataframe from S3, the other loads a bunch of dataframes and uses sparkSQL to generate a big dataframe. Then I join these 2 dataframes together multiple times into multiple dataframes and try to write them as CSV to S3... However I am seeing my write times upwards of 30 minutes, I am not sure if it is re-evaluating the dataframe or if perhaps I need more CPUs for this task. Nonetheless, I was hoping someone may have some advice on how to optimize these write times.","So when a dataframe is created from other dataframes it seems an execution plan is what is first created. Then when executing a write operation that plan gets evaluated. +The best way to take care of this particular situation is to take advantage of the spark lazy-loading caching (I have not seen an eager-loading solution for spark but if that exists it could be even better). +By doing: +dataframe1.cache() +And +dataframe2.cache() +when you join these 2 dataframes the first time both dataframes are evaluated and loaded into cache. Then when joining and writing again the 2 dataframe execution plans are already evaluated and the join and write becomes much faster. +This means the first write still takes over 30 minutes but the other 2 writes are much quicker. +Additionally, you can increase performance with additional CPUs and proper paritioning and coalesce of the dataframes. That could help with the evaluation of the first join and write operation. +Hope this helps.",1.2,True,1,6749 +2020-05-14 14:44:06.843,Flask Python - multiple URL parameter with brackets,"hope you are all doing well. +Im working on api project using python and flask. +The question I have to ask is, how can I get the values of multiple query string parameter? +The api client is built in PHP, and when a form is submitted, if some of the parameters are multiple the query string is built like filter[]=1&filter[]=2&filter[]=3... and so on. +When I dump flask request, it shows something like (filter[], 1), (filter[], 2), (filter[], 3), it seems ok, but then when I do request.args.get('filter[]') it returns only the first item in the args ImmutableDict, filter[]=1, and I can't access the other values provided. +Any help regarding this issue would be aprreciated. +Happy programming!",try this request.args.to_dict(flat=False) to convert,0.0,False,1,6750 +2020-05-14 16:41:02.153,Accessing Pyramid Settings throughout the program,"I have a pyramid API which has basically three layers. + +View -> validates the request and response +Controller -> Does business logic and retrieves things from the DB. +Services -> Makes calls to external third party services. + +The services are a class for each external API which will have things like authentication data. This should be a class attribute as it does not change per instance. However, I cannot work out how to make it a class attribute. +Instead I extract the settings in the view request.registry.settings pass it to the controller which then passes it down in the init() for the service. This seems unnecessary. +Obviously I could hard code them in code but that's an awful idea. +Is there a better way?","Pyramid itself does not use global variables, which is what you are asking for when you ask for settings to be available in class-level or module-level attributes. For instance-level stuff, you can just pass the settings from Pyramid into the instance either from the view or from the config. +To get around this, you can always pass data into your models at config-time for your Pyramid app. For example, in your main just pull settings = config.get_settings() and pass some of them to where they need to be. As a general rule, you want to try to pass things around at config-time once, instead of from the view layer all the time. +Finally, a good way to do that without using class-level or module-level attributes is to register instances of your services with your app. pyramid_services library provides one approach to this, but the idea is basically to instantiate an instance of a service for your app, add it to your pyramid registry config.registry.foo = ... and when you do that you can pass in the settings. Later in your view code you can grab the service from there using request.registry.foo and it's already setup for you!",0.6730655149877884,False,1,6751 +2020-05-15 11:10:49.963,Django: safely deleting an unused table from database,"In my django application, I used to authenticate users exploiting base django rest framework authentication token. Now I've switched to Json Web Token, but browsing my psql database, I've noticed the table authtoken_token, which was used to store the DRF authentication token, is still there. I'm wondering how to get rid of it. I've thought about 2 options: + +deleting it through migration: I think this is the correct and safer way to proceed, but in my migrations directory inside my project folder, I didn't find anything related to the tokens. Only stuff related to my models; +deleting it directly from the database could be another option, but I'm afraid of messing with django migrations (although it shoudn't have links with other tables anymore) + +I must clarify I've already removed rest_framework.authtoken from my INSTALLED_APPS","You can choose the first option. There are 3 steps should you do to complete uninstall authtoken from your Django app + +Remove rest_framework.authtoken from INSTALLED_APPS, this action will tell your Django app to do not take any migrations file from that module +Remove authtoken_token table, if you will +Find the record with authtoken app name in table django_migrations, you can remove it. + +Note: There are several error occurs in your code, because authtoken module is removed from your INSTALLED_APPS. My advice, backup your existing database first before you do above step",0.2012947653214861,False,1,6752 +2020-05-16 15:11:39.083,Can't find 'Scripts' folder or 'pip' file in Python 3.8.2 folder for Windows 10,Can't find 'Scripts' folder or 'pip' file in Python 3.8.2 folder for Windows 10. Trying to install pip for python. Any ideas how I can get past this problem?,"As others answered already you should have got pip already as you installed python. Well pip isnt the apllication. You use pip in the application: Command prompt. You have to search for command prompt on your computer (if you have python you already have it installed) and then in command prompt you install packages that you still son't have. +For example you wan't pygame you write: pip install pygame. If you have PyCharm then there is something else you need to do. If you have PyCharm tell me as a comment to this answer and I'll tell you what to do then because command prompt would almost be useless",0.0,False,2,6753 +2020-05-16 15:11:39.083,Can't find 'Scripts' folder or 'pip' file in Python 3.8.2 folder for Windows 10,Can't find 'Scripts' folder or 'pip' file in Python 3.8.2 folder for Windows 10. Trying to install pip for python. Any ideas how I can get past this problem?,"Pip should have already been installed when you install your python, if you wanna check if you pip is install try typing pip in your command prompt or terminal and if you wanna see the file directory of the pip you have installed say pip show (here you put name of file like pygame)",0.0,False,2,6753 +2020-05-16 17:56:13.050,Python not operating with super long list,"Hi i have a list with 15205 variables inside, im trying to find the relative frequency of each variable but python don't react with such a big size. +if i try len(list) it works, but max(list) gives me '>' not supported between instances of 'list' and 'int', and set(list) gives me 'type' object is not utterable. If i try to work with it as a data frame it gives me TypeError: unhashable type: 'list' +Plus, if i use a small sample of the list everything works fine. +Can anyone explain me why does this happen and how can i work it out? +thanks","Firstly, you shouldn't name your list 'list', since this is a reserved word in Python referring to the type. This is the origin of your 'set(list)' error. +As for the other error, at least one of the items in your list appears to be itself a list, and you can't compare the magnitude of a list and an integer.",0.6730655149877884,False,1,6754 +2020-05-16 19:30:33.470,How do i run a python project nonstop ( even when i close the computer ),I have a discord.py bot using the datetime and random libraries ( and discord.py of course ). My question is how can i run it even when my computer is off. I think the answer is a rented server but i think there are cheeper options,"You'll either have to run it on a machine you don't turn off. Or deploy it to a server. You can get cheap servers through Linode, Digital Ocean and others.",0.0,False,1,6755